Compare commits

...

19 Commits

Author SHA1 Message Date
akashnimare
292e1b4d15 test: set default language for spellchecker 2017-12-15 19:21:07 +05:30
akashnimare
64a12dca09 test: run all the tests on appveyor. 2017-12-14 00:26:07 +05:30
akashnimare
d1d19327ba travis: rename tests. 2017-12-14 00:03:46 +05:30
Akash Nimare
dc6a1c3c0b travis: only run e2e & linting test on Linux 2017-12-13 23:46:57 +05:30
simplyahmazing
63005d20ca combine test cmds into one cmd 2017-12-13 10:10:02 -05:00
simplyahmazing
600e8acdfa Merge branch 'master' into setup-karma-for-unit-tests 2017-12-13 09:54:05 -05:00
simplyahmazing
3f01774d0a fix app starts e2e test 2017-12-11 16:42:09 -05:00
simplyahmazing
808dffd2ed merge upstream master 2017-12-11 16:37:32 -05:00
simplyahmazing
6b51f6d9a6 enable spellchecker via config for test 2017-12-11 16:34:23 -05:00
simplyahmazing
36342145da remove flag to force enable spellchecker 2017-12-11 16:20:52 -05:00
simplyahmazing
7b639129b3 merge upstream master 2017-12-06 11:53:50 -05:00
simplyahmazing
89ae4585e6 rename test file 2017-12-06 11:45:02 -05:00
simplyahmazing
469b827425 remove unused dep section from package.json 2017-12-06 11:43:52 -05:00
simplyahmazing
7feb0e4280 remove karma-coverage 2017-12-06 11:33:58 -05:00
simplyahmazing
8cd8bac6a7 remove browserify dep 2017-12-06 06:51:30 -05:00
simplyahmazing
ce1e902e89 run unit tests on travis/appveyor 2017-12-05 13:34:25 -05:00
simplyahmazing
3baa2c6ca5 setup spellchecker test 2017-12-05 13:27:07 -05:00
simplyahmazing
2114ccfb40 setup karma for running renderer process tests 2017-12-05 13:25:51 -05:00
simplyahmazing
c6f1f99fe9 move integration tests into e2e dir 2017-11-30 20:47:25 -05:00
12 changed files with 76 additions and 14 deletions

3
.gitignore vendored
View File

@@ -26,6 +26,7 @@ yarn-error.log*
config.gypi
# Test generated files
tests/package.json
tests/e2e/package.json
coverage
.python-version

View File

@@ -6,7 +6,7 @@ os: Previous Visual Studio 2015
cache:
- node_modules
install:
- ps: Install-Product node 6 x64
- git reset --hard HEAD
@@ -20,5 +20,4 @@ install:
build: off
test_script:
- npm run test
- npm run test-e2e
- npm run test-all

View File

@@ -30,7 +30,7 @@ gulp.task('reload:renderer', done => {
});
gulp.task('test-e2e', () => {
return gulp.src('tests/*.js')
return gulp.src('tests/e2e/*.js')
.pipe(tape({
reporter: tapColorize()
}));

21
karma.conf.js Normal file
View File

@@ -0,0 +1,21 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
browsers: ['Electron'],
preprocessors: {
'**/*.js': ['electron']
},
files: [
{pattern: './karma.shim.js', watched: true, included: true, served: true},
{pattern: './tests/unit/*.js', watched: true, included: true, served: true},
{pattern: './app/renderer/**/*.js', watched: true, included: false, served: true}
],
reporters: ['mocha'],
client: {
captureConsole: true,
useIframe: false
},
singleRun: true
});
};

5
karma.shim.js Normal file
View File

@@ -0,0 +1,5 @@
window.require = window.parent.require;
window.process = window.parent.process;
window.__dirname = window.parent.__dirname;
require('module').globalPaths.push('./node_modules');
require('module').globalPaths.push('./app/renderer');

View File

@@ -21,8 +21,10 @@
"start": "electron app --disable-http-cache",
"reinstall": "rm -rf node_modules; rm -rf app/node_modules; npm install",
"postinstall": "electron-builder install-app-deps",
"test": "xo",
"lint": "xo",
"test-e2e": "gulp test-e2e",
"test-unit": "karma start karma.conf.js",
"test-all": "xo && npm run test-unit && npm run test-e2e",
"dev": "gulp dev",
"pack": "electron-builder --dir",
"dist": "electron-builder",
@@ -30,7 +32,7 @@
"travis": "cd ./scripts && ./travis-build-test.sh"
},
"pre-commit": [
"test"
"lint"
],
"build": {
"appId": "org.zulip.zulip-electron",
@@ -116,10 +118,17 @@
"gulp": "3.9.1",
"gulp-tape": "0.0.9",
"is-ci": "^1.0.10",
"jasmine": "^2.8.0",
"karma": "^1.7.1",
"karma-electron": "^5.2.2",
"karma-electron-launcher": "^0.2.0",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.5",
"pre-commit": "1.2.2",
"spectron": "3.7.2",
"tap-colorize": "^1.2.0",
"tape": "^4.8.0",
"watchify": "^3.9.0",
"xo": "0.18.2"
},
"xo": {
@@ -153,7 +162,8 @@
}
],
"ignore": [
"tests/*.js"
"tests/e2e/*.js",
"tests/unit/*"
],
"envs": [
"node",

View File

@@ -10,8 +10,14 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
xdpyinfo | grep dimensions
fi
npm run test
# macOS
# Run all the tests
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
npm run test-e2e
npm run test-all
fi
# Linux
# Only run linting test on Linux
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
npm run lint
fi

View File

@@ -22,7 +22,7 @@ module.exports = {
function createApp (t) {
generateTestAppPackageJson()
return new Application({
path: path.join(__dirname, '..', 'node_modules', '.bin',
path: path.join(__dirname,'..', '..', 'node_modules', '.bin',
'electron' + (process.platform === 'win32' ? '.cmd' : '')),
args: [path.join(__dirname)], // Ensure this dir has a package.json file with a 'main' entry piont
env: {NODE_ENV: 'test'},
@@ -34,9 +34,9 @@ function createApp (t) {
// Reads app package.json and updates the productName to config.TEST_APP_PRODUCT_NAME
// We do this so that the app integration doesn't doesn't share the same appDataDir as the dev application
function generateTestAppPackageJson () {
let packageJson = require(path.join(__dirname, '../package.json'))
let packageJson = require(path.join(__dirname, '..', '..', 'package.json'))
packageJson.productName = config.TEST_APP_PRODUCT_NAME
packageJson.main = '../app/main'
packageJson.main = '../../app/main'
const testPackageJsonPath = path.join(__dirname, 'package.json')
fs.writeFileSync(testPackageJsonPath, JSON.stringify(packageJson, null, ' '), 'utf-8')

View File

@@ -0,0 +1,20 @@
const ConfigUtil = require('js/utils/config-util.js');
const SetupSpellChecker = require('js/spellchecker')
describe('test spell checker', function () {
// enable spellchecker settings
ConfigUtil.setConfigItem('enableSpellchecker', true);
ConfigUtil.setConfigItem('spellcheckerLanguage', 'en');
SetupSpellChecker.init() // re-initialize after setting update
const spellCheckHandler = SetupSpellChecker.SpellCheckHandler
it('mark misspelled word', function () {
expect(spellCheckHandler.isMisspelled('helpe')).toBe(true)
})
it('verify properly spelled word', function () {
expect(spellCheckHandler.isMisspelled('help')).toBe(false)
})
})