Feature/test suite (#169)
* Adding first run of the test environment * small tweaks * Fixing tests suite to ohif-viewer * Improving documentation and fixing versions * Removing commented lines
This commit is contained in:
parent
43a7e8151a
commit
bf68707ff2
40
OHIFViewer/bin/testPackages.sh
Normal file
40
OHIFViewer/bin/testPackages.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
##################################################
|
||||
# Runs the packages tests
|
||||
##################################################
|
||||
|
||||
# check execution arguments
|
||||
while [ "$1" != "" ]; do
|
||||
PARAM=`echo $1 | awk -F= '{print $1}'`
|
||||
case $PARAM in
|
||||
-c | --coverage)
|
||||
export RUN_COVERAGE=1
|
||||
;;
|
||||
-v | --verbose)
|
||||
export COVERAGE_VERBOSE=1
|
||||
;;
|
||||
-s | --spacejam)
|
||||
export RUN_SPACEJAM=1
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$RUN_COVERAGE" == 1 ];
|
||||
then
|
||||
# Setting coverage variables
|
||||
app_folder=$(pwd)
|
||||
app_folder+="/packages/ascend-adaptive-reporting/"
|
||||
export COVERAGE_APP_FOLDER=$app_folder
|
||||
export COVERAGE=1
|
||||
echo 'Running meteor-coverage'
|
||||
fi
|
||||
|
||||
if [ "$RUN_SPACEJAM" == 1 ];
|
||||
then
|
||||
spacejam-mocha ./packages/ascend-adaptive-reporting/
|
||||
else
|
||||
meteor test-packages --driver-package='practicalmeteor:mocha' ./packages/ascend-adaptive-reporting/
|
||||
fi
|
||||
46
Packages/ohif-viewerbase/.coverage.json
Normal file
46
Packages/ohif-viewerbase/.coverage.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"include": [
|
||||
"server/*.js",
|
||||
"client/*.js",
|
||||
"both/*.js"
|
||||
],
|
||||
"exclude": {
|
||||
"general": [],
|
||||
"server": [
|
||||
"**/node_modules/**/*.json",
|
||||
"**/.?*/**",
|
||||
"**/packages/!(local-test_?*.js)",
|
||||
"**/+([^:]):+([^:])/**",
|
||||
"**/@(test|tests|spec|specs)/**",
|
||||
"**/?(*.)test?(s).?*",
|
||||
"**/?(*.)spec?(s).?*",
|
||||
"**/?(*.)app-test?(s).?*",
|
||||
"**/?(*.)app-spec?(s).?*"
|
||||
],
|
||||
"client": [
|
||||
"**/client/stylesheets/**",
|
||||
"**/.npm/package/node_modules/**",
|
||||
"**/web.browser/packages/**",
|
||||
"**/.?*/**",
|
||||
"**/packages/!(local-test_?*.js)",
|
||||
"**/+([^:]):+([^:])/**",
|
||||
"**/@(test|tests|spec|specs)/**",
|
||||
"**/?(*.)test?(s).?*",
|
||||
"**/?(*.)spec?(s).?*",
|
||||
"**/?(*.)app-test?(s).?*",
|
||||
"**/?(*.)app-spec?(s).?*"
|
||||
]
|
||||
},
|
||||
"remapFormat": [
|
||||
"html",
|
||||
"cobertura",
|
||||
"clover",
|
||||
"json",
|
||||
"json-summary",
|
||||
"lcovonly",
|
||||
"teamcity",
|
||||
"text",
|
||||
"text-summary"
|
||||
],
|
||||
"output": "./.coverage"
|
||||
}
|
||||
@ -212,3 +212,51 @@ Package.onUse(function(api) {
|
||||
api.mainModule('main.js', 'client');
|
||||
|
||||
});
|
||||
|
||||
Package.onTest(function(api) {
|
||||
const both = ['client', 'server'];
|
||||
|
||||
api.versionsFrom('1.4');
|
||||
|
||||
/*
|
||||
* Really important dependencies to the project
|
||||
*/
|
||||
api.use(['ecmascript',
|
||||
'standard-app-packages',
|
||||
'http',
|
||||
'jquery',
|
||||
'mongo',
|
||||
'momentjs:moment',
|
||||
'validatejs',
|
||||
'u2622:persistent-session'
|
||||
], both);
|
||||
|
||||
// OHIF dependencies
|
||||
api.use([
|
||||
'lookback:logger',
|
||||
'aldeed:simple-schema@1.5.3',
|
||||
'ohif:design',
|
||||
'ohif:core',
|
||||
'ohif:hotkeys',
|
||||
'ohif:log'
|
||||
], both);
|
||||
|
||||
/*
|
||||
* Our custom packages
|
||||
*/
|
||||
api.use('ohif:viewerbase', both);
|
||||
|
||||
/*
|
||||
* Tests framework components
|
||||
*/
|
||||
api.use('cultofcoders:mocha');
|
||||
api.use('practicalmeteor:sinon');
|
||||
api.use('practicalmeteor:chai');
|
||||
api.use('lmieulet:meteor-coverage@1.1.4');
|
||||
api.use('xolvio:template-isolator');
|
||||
|
||||
/*
|
||||
* Adding all our tests files
|
||||
*/
|
||||
api.addFiles('./tests/client/components/viewer/gridLayout/gridLayout.tests.js', 'client');
|
||||
});
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import '../../../../../client/components/viewer/gridLayout/gridLayout.html';
|
||||
import '../../../../../client/components/viewer/gridLayout/gridLayout.js';
|
||||
import { Session } from 'meteor/session';
|
||||
import { sinon } from 'meteor/practicalmeteor:sinon';
|
||||
chai.should();
|
||||
|
||||
describe('GridLayout', function() {
|
||||
describe('Helpers', function() {
|
||||
before(function() {
|
||||
Template.instance = function() {
|
||||
return {
|
||||
data: {
|
||||
rows: 2,
|
||||
columns: 2,
|
||||
viewportData: []
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should get the height percentage of each viewport', function() {
|
||||
const percentage = Template.gridLayout.__helpers[' height']();
|
||||
|
||||
percentage.should.be.eq(50);
|
||||
});
|
||||
|
||||
it('should get the width percentage of each viewport', function() {
|
||||
const percentage = Template.gridLayout.__helpers[' height']();
|
||||
|
||||
percentage.should.be.eq(50);
|
||||
});
|
||||
})
|
||||
|
||||
after(function() {
|
||||
Meteor.sendCoverage(function() { });
|
||||
});
|
||||
|
||||
// describe('Testing getClass() Helper', function () {
|
||||
// it('should return priorDropdown', function () {
|
||||
// Session.set('isPrior', true);
|
||||
// Template.priorDropdown.__helpers.get('getClass')()
|
||||
// .should.equal('priorDropdown');
|
||||
// });
|
||||
|
||||
// it('should return empty string', function () {
|
||||
// Session.set('isPrior', false);
|
||||
// Template.priorDropdown.__helpers.get('getClass')()
|
||||
// .should.equal('');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Testing dropdown change event', function () {
|
||||
|
||||
// let openPriorStudyWindowStub;
|
||||
// let test;
|
||||
|
||||
// before(function () {
|
||||
|
||||
// Template.instance = function () { return { openPriorStudyWindow: sinon.spy() } };
|
||||
|
||||
// $.fn.select2 = function () {
|
||||
// return [{
|
||||
// selectedIndex: 0,
|
||||
// options: [{
|
||||
// text: 'Attrial Septum'
|
||||
// }]
|
||||
// }]
|
||||
// };
|
||||
// });
|
||||
|
||||
// it('should return priorDropdown', function () {
|
||||
// Template.priorDropdown.fireEvent('change #studySelect');
|
||||
// // TODO: spy is not working
|
||||
// });
|
||||
// });
|
||||
});
|
||||
@ -0,0 +1,21 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { chai } from 'meteor/practicalmeteor:chai';
|
||||
import ReportService from 'meteor/lmieulet:meteor-coverage'
|
||||
|
||||
chai.should();
|
||||
|
||||
describe('Exporting coverage report', function() {
|
||||
it('Generating coverage report', function() { });
|
||||
|
||||
after(function() {
|
||||
const reportService = new ReportService.ReportService();
|
||||
const mockRes = { end: () => { }, writeHead: () => { } };
|
||||
|
||||
// The possible reports
|
||||
// Check https://github.com/serut/meteor-coverage
|
||||
reportService.generateReport(mockRes, 'text-summary', {});
|
||||
reportService.generateReport(mockRes, 'html', {});
|
||||
reportService.generateReport(mockRes, 'json-summary', {});
|
||||
reportService.generateReport(mockRes, 'lcovonly', {});
|
||||
});
|
||||
});
|
||||
50
test/README.md
Normal file
50
test/README.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Tests suite
|
||||
|
||||
## Tools
|
||||
+ mocha as test runner.
|
||||
+ ~~meteor package: practicalmeteor:mocha
|
||||
https://github.com/practicalmeteor/meteor-mocha~~
|
||||
+ meteor package: cultofcoders:mocha
|
||||
https://github.com/cult-of-coders/meteor-mocha
|
||||
+ Using cultofcoders because of this issue: https://github.com/practicalmeteor/meteor-mocha/issues/100
|
||||
|
||||
+ chai as assertion library meteor package:
|
||||
+ practicalmeteor:chai https://github.com/practicalmeteor/meteor-chai
|
||||
|
||||
+ sinon as stubs, spies & mocking lib
|
||||
+ practicalmeteor:meteor-sinon
|
||||
|
||||
+ meteor-coverage as tests coverage report (istanbul.js based)
|
||||
+ https://atmospherejs.com/lmieulet/meteor-coverage
|
||||
|
||||
+ xolvio:template-isolator
|
||||
+ Used for mock events on client side, like 'button click'.
|
||||
|
||||
+ spacejam:
|
||||
+ Use it when you want run tests in a CI server. It has no browser dependency.
|
||||
+ https://www.npmjs.com/package/spacejam
|
||||
|
||||
## Useful links
|
||||
1. https://guide.meteor.com/testing.html
|
||||
2. https://guide.meteor.com/writing-atmosphere-packages.html#testing
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ cd Viewers
|
||||
$ ./test/testPackages.sh [-c] -s
|
||||
# -c for coverage | -s for spacejam
|
||||
```
|
||||
|
||||
You can add more packages to be tested changing the line 7 in `testPackages.sh`:
|
||||
```
|
||||
TEST_PACKAGES=./Packages/ohif-viewerbase ./Packages/ohif-core ./Packages/ohif-etc
|
||||
```
|
||||
|
||||
it does not work using path patterns like `./Packages/*` or `./Packages/`
|
||||
|
||||
Just open `http://localhost:3000` in your browser. The page going to be refreshed everytime you change the code.
|
||||
|
||||
Note: if you want to use spacejam, just install it before running.
|
||||
|
||||
|
||||
43
test/testPackages.sh
Executable file
43
test/testPackages.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
##################################################
|
||||
# Runs the packages tests
|
||||
##################################################
|
||||
|
||||
TEST_PACKAGES=./Packages/ohif-viewerbase
|
||||
export METEOR_PACKAGE_DIRS="./Packages"
|
||||
|
||||
# check execution arguments
|
||||
while [ "$1" != "" ]; do
|
||||
PARAM=`echo $1 | awk -F= '{print $1}'`
|
||||
case $PARAM in
|
||||
-c | --coverage)
|
||||
export RUN_COVERAGE=1
|
||||
;;
|
||||
-v | --verbose)
|
||||
export COVERAGE_VERBOSE=1
|
||||
;;
|
||||
-s | --spacejam)
|
||||
export RUN_SPACEJAM=1
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$RUN_COVERAGE" == 1 ];
|
||||
then
|
||||
# Setting coverage variables
|
||||
app_folder=$(pwd)
|
||||
app_folder+=TEST_PACKAGES
|
||||
export COVERAGE_APP_FOLDER=$app_folder
|
||||
export COVERAGE=1
|
||||
echo 'Running meteor-coverage'
|
||||
fi
|
||||
|
||||
if [ "$RUN_SPACEJAM" == 1 ];
|
||||
then
|
||||
spacejam-mocha $TEST_PACKAGES
|
||||
else
|
||||
meteor test-packages --driver-package='cultofcoders:mocha' $TEST_PACKAGES
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user