Skip to content

Commit

Permalink
Merge pull request #718 from Caltech-IPAC/IRSA-2520_jest_framework
Browse files Browse the repository at this point in the history
IRSA-2520: Add JavaScript Testing framework to Firefly
  • Loading branch information
loitly authored Jan 16, 2019
2 parents 858dbac + 5171353 commit 361c9a7
Show file tree
Hide file tree
Showing 17 changed files with 2,005 additions and 179 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

"env": {
"es6": true,
"browser": true
"browser": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 7,
Expand Down
47 changes: 47 additions & 0 deletions __jest__/InitTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as jest from 'jest';

jest.mock('firefly/Firefly.js');
//
// -- we are going to have to do something like this eventually, I think, right now I can't make it work
// jest.mock('firefly/Firefly.js', () => {
// return {
// flux : {
// process : () => {},
// getState : () => ({
// app_data : {},
// allPlots : {},
// fieldGroup: {}
// })
// }
// }
// });


jest.mock('firefly/util/BrowserInfo.js', () => {
return {
getBrowserType: () => '',
isIE: () => false,
isSafari: () => false,
isFirefox: () => false,
isChrome: () => true,
isBrowser: () => false,
isPlatform: () => false,
isVersionAtLeast: () => false,
isVersionBefore: () => false,
getSupportsCSS3: () => false,
getSupportsCORS: () => false,
getPlatformDesc: () => '',
getBrowserString: () => 'chrome',
isTouchInput: () => false,
getVersionString: () => '1.2.3',
getBrowserDesc: () => 'chrome'

};
});


jest.mock('firefly/core/AppDataCntlr.js', () => {
return {
getAppOptions : () => ({})
}
});
1 change: 1 addition & 0 deletions __jest__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
6 changes: 6 additions & 0 deletions __jest__/jest.transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Custom Jest transform implementation that wraps babel-jest and injects our
// babel presets, so we don't have to use .babelrc.

module.exports = require('babel-jest').createTransformer({
presets: ["env", "react", "stage-3"],
});
1 change: 1 addition & 0 deletions __jest__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
4 changes: 2 additions & 2 deletions buildScript/depends.gincl
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,13 @@ ext.NODE = { ...cmd ->
for (String key : project.appConfigProps.keySet()) {
if (key.startsWith('__$')) {
environment (key, project.appConfigProps[key])
println ">> " + key + " = " + project.appConfigProps[key]
// println ">> " + key + " = " + project.appConfigProps[key]
}
}
// load version info as JS global
for (String key : versionInfo.keySet()) {
environment ('__$version.'+key, versionInfo[key])
println ">> " + '__$version.'+key + " = " + versionInfo[key]
// println ">> " + '__$version.'+key + " = " + versionInfo[key]
}
}
return res;
Expand Down
12 changes: 12 additions & 0 deletions buildScript/gwt_webapp.gincl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ task jsTest (dependsOn: [loadConfig]) {
}
}

task jsTestDebug (dependsOn: [loadConfig]) {
doLast {
if (file("package.json").exists()) {
println ">> running JavaScript test in debug mode..."
def res = project.ext.NODE 'yarn', 'run', 'test-debug'
if (res.getExitValue() != 0) {
throw new GradleException("JavaScript test fail.")
}
}
}
}

clean {
description= 'Remove build files from this project'
group = DEV_GROUP
Expand Down
7 changes: 0 additions & 7 deletions buildScript/mocha-init.js

This file was deleted.

7 changes: 0 additions & 7 deletions config/test/mocha-init.js

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"ink-docstrap": "^1.2.1",
"jsdoc": "^3.5.5",
"jsdoc-jsx": "^0.1.0",
"jest": "^23.6.0",
"babel-jest": "^23.6.0",
"mocha": "^3.1.0",
"postcss-loader": "^0.11.1",
"publish-release": "^1.1.0",
Expand Down
Loading

0 comments on commit 361c9a7

Please sign in to comment.