File tree Expand file tree Collapse file tree 4 files changed +112
-4
lines changed Expand file tree Collapse file tree 4 files changed +112
-4
lines changed Original file line number Diff line number Diff line change 1+ var path = require ( 'path' ) ;
2+ var exec = require ( 'child_process' ) . exec ;
3+
4+ var glob = require ( 'glob' ) ;
5+ var constants = require ( './util/constants' ) ;
6+ var pathToBundleTests = path . join ( constants . pathToJasmineTests , '..' , 'bundle_tests' ) ;
7+
8+
9+ glob ( pathToBundleTests + '/*.js' , function ( err , files ) {
10+ files . forEach ( function ( file ) {
11+ var baseName = path . basename ( file ) ;
12+ var cmd = 'npm run citest-jasmine -- bundle_tests/' + baseName ;
13+
14+ exec ( cmd , function ( err , stdout ) {
15+ console . log ( stdout ) ;
16+
17+ if ( err ) throw err ;
18+ } ) ;
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 1+ var d3 = require ( 'd3' ) ;
2+
3+ var Plotly = require ( '@lib/core' ) ;
4+ var PlotlyBar = require ( '@lib/bar' ) ;
5+
6+ var createGraphDiv = require ( '../assets/create_graph_div' ) ;
7+ var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
8+
9+
10+ describe ( 'Bundle with bar' , function ( ) {
11+ 'use strict' ;
12+
13+ Plotly . register ( PlotlyBar ) ;
14+
15+ var mock = require ( '@mocks/bar_line.json' ) ;
16+
17+ beforeEach ( function ( done ) {
18+ Plotly . plot ( createGraphDiv ( ) , mock . data , mock . layout ) . then ( done ) ;
19+ } ) ;
20+
21+ afterEach ( destroyGraphDiv ) ;
22+
23+ it ( 'should graph scatter traces' , function ( ) {
24+ var nodes = d3 . selectAll ( 'g.trace.scatter' ) ;
25+
26+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
27+ } ) ;
28+
29+ it ( 'should graph bar traces' , function ( ) {
30+ var nodes = d3 . selectAll ( 'g.trace.bars' ) ;
31+
32+ expect ( nodes . size ( ) ) . toEqual ( 1 ) ;
33+ } ) ;
34+ } ) ;
Original file line number Diff line number Diff line change 1+ var d3 = require ( 'd3' ) ;
2+
3+ var Plotly = require ( '@lib/core' ) ;
4+
5+ var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6+ var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
7+
8+
9+ describe ( 'Bundle with core only' , function ( ) {
10+ 'use strict' ;
11+
12+ var mock = require ( '@mocks/bar_line.json' ) ;
13+
14+ beforeEach ( function ( done ) {
15+ spyOn ( console , 'warn' ) ;
16+
17+ Plotly . plot ( createGraphDiv ( ) , mock . data , mock . layout ) . then ( done ) ;
18+ } ) ;
19+
20+ afterEach ( destroyGraphDiv ) ;
21+
22+ it ( 'should graph scatter traces' , function ( ) {
23+ var nodes = d3 . selectAll ( 'g.trace.scatter' ) ;
24+
25+ expect ( nodes . size ( ) ) . toEqual ( mock . data . length ) ;
26+ } ) ;
27+
28+ it ( 'should not graph bar traces' , function ( ) {
29+ var nodes = d3 . selectAll ( 'g.trace.bars' ) ;
30+
31+ expect ( nodes . size ( ) ) . toEqual ( 0 ) ;
32+ } ) ;
33+
34+ it ( 'should warn users about unregistered bar trace type' , function ( ) {
35+ expect ( console . warn ) . toHaveBeenCalled ( ) ;
36+ } ) ;
37+ } ) ;
Original file line number Diff line number Diff line change 1+ /*eslint-env node*/
2+
13// Karma configuration
24
5+ /*
6+ * Test file globs can be passed with an argument.
7+ *
8+ * Example:
9+ *
10+ * $ npm run test-jasmine -- tests/axes_test.js
11+ *
12+ * will only run the tests in axes_test.js
13+ *
14+ */
15+ var testFileGlob = process . argv [ 4 ] ? process . argv [ 4 ] : 'tests/*_test.js' ;
16+
17+
318function func ( config ) {
419
520 // level of logging
@@ -21,7 +36,7 @@ func.defaultConfig = {
2136 // list of files / patterns to load in the browser
2237 files : [
2338 'assets/jquery-1.8.3.min.js' ,
24- 'tests/*_test.js'
39+ testFileGlob
2540 ] ,
2641
2742 // list of files to exclude
@@ -30,9 +45,9 @@ func.defaultConfig = {
3045
3146 // preprocess matching files before serving them to the browser
3247 // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
33- preprocessors : {
34- 'tests/*_test.js' : [ 'browserify' ]
35- } ,
48+ //
49+ // N.B. this field is filled below
50+ preprocessors : { } ,
3651
3752 // test results reporter to use
3853 // possible values: 'dots', 'progress'
@@ -64,5 +79,7 @@ func.defaultConfig = {
6479 }
6580} ;
6681
82+ // browserify the test files
83+ func . defaultConfig . preprocessors [ testFileGlob ] = [ 'browserify' ] ;
6784
6885module . exports = func ;
You can’t perform that action at this time.
0 commit comments