Skip to content

Commit 4fde166

Browse files
committed
Merge pull request #425 from plotly/karma-individual-tests
Single suite karma/jasmine tests
2 parents e475be3 + b203a3c commit 4fde166

File tree

5 files changed

+58
-24
lines changed

5 files changed

+58
-24
lines changed

src/components/annotations/attributes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
'use strict';
1010

1111
var ARROWPATHS = require('./arrow_paths');
12-
var Cartesian = require('../../plots/cartesian');
1312
var fontAttrs = require('../../plots/font_attributes');
13+
var cartesianConstants = require('../../plots/cartesian/constants');
1414
var extendFlat = require('../../lib/extend').extendFlat;
1515

1616

@@ -156,7 +156,7 @@ module.exports = {
156156
valType: 'enumerated',
157157
values: [
158158
'paper',
159-
Cartesian.idRegex.x.toString()
159+
cartesianConstants.idRegex.x.toString()
160160
],
161161
role: 'info',
162162
description: [
@@ -199,7 +199,7 @@ module.exports = {
199199
valType: 'enumerated',
200200
values: [
201201
'paper',
202-
Cartesian.idRegex.y.toString()
202+
cartesianConstants.idRegex.y.toString()
203203
],
204204
role: 'info',
205205
description: [

src/plots/cartesian/constants.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111

1212
module.exports = {
13+
14+
idRegex: {
15+
x: /^x([2-9]|[1-9][0-9]+)?$/,
16+
y: /^y([2-9]|[1-9][0-9]+)?$/
17+
},
18+
19+
attrRegex: {
20+
x: /^xaxis([2-9]|[1-9][0-9]+)?$/,
21+
y: /^yaxis([2-9]|[1-9][0-9]+)?$/
22+
},
23+
1324
/**
1425
* standardize all missing data in calcdata to use undefined
1526
* never null or NaN.

src/plots/cartesian/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@
1212
var Lib = require('../../lib');
1313
var Plots = require('../plots');
1414

15+
var constants = require('./constants');
16+
1517
exports.name = 'cartesian';
1618

1719
exports.attr = ['xaxis', 'yaxis'];
1820

1921
exports.idRoot = ['x', 'y'];
2022

21-
exports.attributes = require('./attributes');
23+
exports.idRegex = constants.idRegex;
2224

23-
exports.idRegex = {
24-
x: /^x([2-9]|[1-9][0-9]+)?$/,
25-
y: /^y([2-9]|[1-9][0-9]+)?$/
26-
};
25+
exports.attrRegex = constants.attrRegex;
2726

28-
exports.attrRegex = {
29-
x: /^xaxis([2-9]|[1-9][0-9]+)?$/,
30-
y: /^yaxis([2-9]|[1-9][0-9]+)?$/
31-
};
27+
exports.attributes = require('./attributes');
3228

3329
exports.plot = function(gd) {
3430
var fullLayout = gd._fullLayout,

src/plots/cartesian/layout_attributes.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
'use strict';
1010

11-
var Cartesian = require('./index');
1211
var fontAttrs = require('../font_attributes');
1312
var colorAttrs = require('../../components/color/attributes');
1413
var extendFlat = require('../../lib/extend').extendFlat;
1514
var rangeSliderAttrs = require('../../components/rangeslider/attributes');
1615
var rangeSelectorAttrs = require('../../components/rangeselector/attributes');
1716

17+
var constants = require('./constants');
18+
1819

1920
module.exports = {
2021
color: {
@@ -402,8 +403,8 @@ module.exports = {
402403
valType: 'enumerated',
403404
values: [
404405
'free',
405-
Cartesian.idRegex.x.toString(),
406-
Cartesian.idRegex.y.toString()
406+
constants.idRegex.x.toString(),
407+
constants.idRegex.y.toString()
407408
],
408409
role: 'info',
409410
description: [
@@ -431,8 +432,8 @@ module.exports = {
431432
valType: 'enumerated',
432433
values: [
433434
'free',
434-
Cartesian.idRegex.x.toString(),
435-
Cartesian.idRegex.y.toString()
435+
constants.idRegex.x.toString(),
436+
constants.idRegex.y.toString()
436437
],
437438
role: 'info',
438439
description: [

test/jasmine/karma.conf.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
* will only run the tests in axes_test.js
1313
*
1414
*/
15-
var testFileGlob = process.argv[4] ? process.argv[4] : 'tests/*_test.js';
15+
16+
var arg = process.argv[4];
17+
18+
var testFileGlob = arg ? arg : 'tests/*_test.js';
19+
var isSingleSuiteRun = (arg && arg.indexOf('bundle_tests/') === -1);
20+
21+
var pathToMain = '../../lib/index.js';
22+
var pathToJQuery = 'assets/jquery-1.8.3.min.js';
1623

1724

1825
function func(config) {
@@ -34,10 +41,9 @@ func.defaultConfig = {
3441
frameworks: ['jasmine', 'browserify'],
3542

3643
// list of files / patterns to load in the browser
37-
files: [
38-
'assets/jquery-1.8.3.min.js',
39-
testFileGlob
40-
],
44+
//
45+
// N.B. this field is filled below
46+
files: [],
4147

4248
exclude: [],
4349

@@ -77,7 +83,27 @@ func.defaultConfig = {
7783
}
7884
};
7985

80-
// browserify the test files
81-
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
86+
87+
// Add lib/index.js to single-suite runs,
88+
// to avoid import conflicts due to plotly.js
89+
// circular dependencies.
90+
if(isSingleSuiteRun) {
91+
func.defaultConfig.files = [
92+
pathToJQuery,
93+
pathToMain,
94+
testFileGlob
95+
];
96+
97+
func.defaultConfig.preprocessors[pathToMain] = ['browserify'];
98+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
99+
}
100+
else {
101+
func.defaultConfig.files = [
102+
pathToJQuery,
103+
testFileGlob
104+
];
105+
106+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
107+
}
82108

83109
module.exports = func;

0 commit comments

Comments
 (0)