-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Make tests work with Karma and Chrome (Closes #60) * Fix the version of UglifyJS to prevent an issue with our files
- Loading branch information
Showing
7 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
sudo: required | ||
dist: trusty | ||
addons: | ||
apt: | ||
sources: | ||
google-chrome | ||
packages: | ||
google-chrome-stable | ||
before_install: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- sleep 3 # give xvfb some time to start | ||
- export CHROME_BIN=google-chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"env": { | ||
"mocha": true, | ||
"node": true, | ||
}, | ||
"globals": { | ||
"assert": true, | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import moment from 'components/moment'; | ||
import IntentParser from 'js/lib/intent-parser'; | ||
|
||
describe('intent-parser', function() { | ||
describe('Properly parses expected reminder sentences', function() { | ||
const fixtures = [ | ||
{ | ||
sentence: 'Remind me to go to the office by 5pm', | ||
parsed: { | ||
users: ['me'], | ||
action: 'go to the office', | ||
confirmation: | ||
'OK, I\'ll remind you to go to the office at 5 PM today.', | ||
time: moment({ hour: 17 }).toDate(), | ||
}, | ||
}, | ||
{ | ||
sentence: 'Remind John by tomorrow to take out trash', | ||
parsed: { | ||
users: ['John'], | ||
action: 'take out trash', | ||
confirmation: | ||
'OK, I\'ll remind John to take out trash at 12 PM tomorrow.', | ||
time: moment({ hour: 12 }).add(1, 'day').toDate(), | ||
}, | ||
}, | ||
]; | ||
|
||
fixtures.forEach(({ sentence, parsed }) => { | ||
it(sentence, function() { | ||
const intentParser = new IntentParser(); | ||
return intentParser.parse(sentence).then((result) => { | ||
assert.deepEqual(result, parsed); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint no-var: "off" */ | ||
|
||
var allTestFiles = []; | ||
var TEST_REGEXP = /(spec|test)\.js$/i; | ||
|
||
// Get a list of all the test files to include | ||
Object.keys(window.__karma__.files).forEach(function(file) { | ||
if (TEST_REGEXP.test(file)) { | ||
// Normalize paths to RequireJS module names. | ||
allTestFiles.push(file.replace(/^\/base\/|\.js$/g, '')); | ||
} | ||
}); | ||
|
||
require.config({ | ||
// Karma serves files under /base, which is the basePath from config file. | ||
baseUrl: '/base', | ||
deps: allTestFiles, | ||
callback: window.__karma__.start, | ||
|
||
// ReactDOM expects "react" module to be defined, but it is not. | ||
map: { | ||
'*': { | ||
'react': 'components/react', | ||
}, | ||
}, | ||
|
||
paths: { | ||
'js': 'dist/tests/unit', | ||
// Addons include React TestUtils. | ||
'components/react': 'node_modules/react/dist/react-with-addons', | ||
'components/react-dom': 'node_modules/react-dom/dist/react-dom', | ||
'components/chrono': 'node_modules/chrono-node/chrono.min', | ||
'components/moment': 'node_modules/moment/moment', | ||
'components/cldr/core': 'node_modules/twitter_cldr/min/core.min', | ||
'components/cldr/en': 'node_modules/twitter_cldr/min/en.min', | ||
'rxjs': 'node_modules/rxjs/bundles/Rx.umd', | ||
}, | ||
}); |