Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Use jasmine-core 3.4.0 by etpinard · Pull Request #3969 · plotly/plotly.js · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,16 +132,15 @@
"gzip-size": "^5.1.1",
"image-size": "^0.7.4",
"into-stream": "^4.0.0",
"jasmine-core": "^2.99.1",
"jasmine-core": "^3.4.0",
"jsdom": "^11.12.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fail-fast-reporter": "^1.0.5",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-spec-tags": "^1.0.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-spec-tags": "^1.1.0",
"karma-spec-reporter": "0.0.32",
"karma-verbose-reporter": "0.0.6",
"karma-viewport": "^1.0.4",
Expand Down
7 changes: 3 additions & 4 deletions test/jasmine/assets/custom_assertions.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

var d3 = require('d3');
var negateIf = require('./negate_if');

exports.assertDims = function(dims) {
var traces = d3.selectAll('.trace');
Expand DownExpand Up@@ -122,8 +123,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
assertLabelContent(nameSel, expectation.name, ptMsg + ' (name)');

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' should be rotated');
}
} else if(ptCnt > 1) {
Expand DownExpand Up@@ -162,8 +162,7 @@ exports.assertHoverLabelContent = function(expectation, msg) {
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
negateIf(expectation.isRotated, expect(g.attr('transform').match(reRotate)))
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}
});
Expand Down
14 changes: 0 additions & 14 deletions test/jasmine/assets/custom_matchers.js
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
/*
* custom_matchers - to be included in karma.conf.js, so it can
* add these matchers to jasmine globally and all suites have access.
*
* Also adds `.negateIf` which is not a matcher but a conditional `.not`:
*
* expect(x).negateIf(condition).toBe(0);
*
* is equivalent to:
*
* if(condition) expect(x).toBe(0);
* else expect(x).not.toBe(0);
*/

'use strict';
Expand DownExpand Up@@ -241,9 +232,4 @@ function arrayToStr(array) {

beforeAll(function() {
jasmine.addMatchers(matchers);

jasmine.Expectation.prototype.negateIf = function(negate) {
if(negate) return this.not;
return this;
};
});
21 changes: 21 additions & 0 deletions test/jasmine/assets/negate_if.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
'use strict';

/**
* Helpers that can negate an expectation given a condition
*
* @param {boolean OR function} condition
* @param {jasmine expect return} expectation
* @returns {jasmine expect return}
*
* Example:
*
* negateIf(myCondition, expect(actual)).toBe(expected);
*
*/
function negateIf(condition, expectation) {
return (typeof condition === 'function' ? condition() : condition) ?
expectation.not :
expectation;
}

module.exports = negateIf;
66 changes: 36 additions & 30 deletions test/jasmine/karma.conf.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,15 @@ var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');

var isCI = !!process.env.CI;
var isCI = Boolean(process.env.CI);

var argv = minimist(process.argv.slice(4), {
string: ['bundleTest', 'width', 'height'],
'boolean': ['info', 'nowatch', 'failFast', 'verbose', 'Chrome', 'Firefox', 'IE11'],
'boolean': [
'info',
'nowatch', 'failFast', 'verbose', 'randomize',
'Chrome', 'Firefox', 'IE11'
],
alias: {
'Chrome': 'chrome',
'Firefox': ['firefox', 'FF'],
Expand All@@ -21,6 +26,7 @@ var argv = minimist(process.argv.slice(4), {
nowatch: isCI,
failFast: false,
verbose: false,
randomize: false,
width: '1035',
height: '617'
}
Expand DownExpand Up@@ -60,6 +66,7 @@ if(argv.info) {
' - `--failFast` (dflt: `false`): exit karma upon first test failure',
' - `--verbose` (dflt: `false`): show test result using verbose reporter',
' - `--showSkipped` (dflt: `false`): show tests that are skipped',
' - `--randomize` (dflt: `false`): randomize test ordering (useful to detect bad test teardown)',
' - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)',
' - `--width`(dflt: 1035): set width of the browser window',
' - `--height` (dflt: 617): set height of the browser window',
Expand DownExpand Up@@ -113,7 +120,6 @@ var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');

var reporters = ((isFullSuite && !argv.tags) || argv.showSkipped) ? ['dots', 'spec'] : ['progress'];
if(argv.failFast) reporters.push('fail-fast');
if(argv.verbose) reporters.push('verbose');

function func(config) {
Expand DownExpand Up@@ -224,27 +230,33 @@ func.defaultConfig = {
debug: true
},

// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
client: {
// Options for `karma-jasmine-spec-tags`
// see https://www.npmjs.com/package/karma-jasmine-spec-tags
//
// A few tests don't behave well on CI
// add @noCI to the spec description to skip a spec on CI
//
// Although not recommended, some tests "depend" on other
// tests to pass (e.g. the Plotly.react tests check that
// all available traces and transforms are tested). Tag these
// with @noCIdep, so that
// - $ npm run test-jasmine -- tags=noCI,noCIdep
// can pass.
//
// Label tests that require a WebGL-context by @gl so that
// they can be skipped using:
// - $ npm run test-jasmine -- --skip-tags=gl
// or run is isolation easily using:
// - $ npm run test-jasmine -- --tags=gl
tagPrefix: '@',
skipTags: isCI ? 'noCI' : null
skipTags: isCI ? 'noCI' : null,

// See https://jasmine.github.io/api/3.4/Configuration.html
jasmine: {
random: argv.randomize,
failFast: argv.failFast
}
},

// use 'karma-spec-reporter' to log info about skipped specs
Expand All@@ -253,14 +265,8 @@ func.defaultConfig = {
suppressFailed: true,
suppressPassed: true,
suppressSkipped: false,
showSpecTiming: false,
// use 'karma-fail-fast-reporter' to fail fast w/o conflicting
// with other karma plugins
failFast: false
},

// e.g. when a test file does not container a given spec tags
failOnEmptyTestSuite: false
showSpecTiming: false
}
};

func.defaultConfig.preprocessors[pathToCustomMatchers] = ['browserify'];
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/bar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');
var color = require('../../../src/components/color');
Expand DownExpand Up@@ -1759,7 +1760,7 @@ describe('A bar plot', function() {
if(!i) return;
var bbox = this.getBoundingClientRect();
['left', 'right', 'top', 'bottom', 'width', 'height'].forEach(function(dim) {
expect(bbox[dim]).negateIf(dims.indexOf(dim) === -1)
negateIf(dims.indexOf(dim) === -1, expect(bbox[dim]))
.toBeWithin(bbox1[dim], 0.1, msg + ' (' + i + '): ' + dim);
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/colorbar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ var subroutines = require('@src/plot_api/subroutines');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
var drag = require('../assets/drag');
Expand DownExpand Up@@ -119,7 +120,7 @@ describe('Test colorbar:', function() {
var cbbg = colorbars.selectAll('.cbbg');
var cbfills = colorbars.selectAll('.cbfill');

expect(cbfills.size()).negateIf(multiFill).toBe(1);
negateIf(multiFill, expect(cbfills.size())).toBe(1);

if(!cbHeight) cbHeight = 400;
var bgHeight = +cbbg.attr('height');
Expand Down
5 changes: 3 additions & 2 deletions test/jasmine/tests/geo_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var getClientPosition = require('../assets/get_client_position');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
Expand DownExpand Up@@ -1571,8 +1572,8 @@ describe('Test geo base layers', function() {
var cd0 = gd.calcdata[0];
var subplot = gd._fullLayout.geo._subplot;

expect(cd0[0].geojson).negateIf(geojson[0]).toBe(null);
expect(cd0[1].geojson).negateIf(geojson[1]).toBe(null);
negateIf(geojson[0], expect(cd0[0].geojson)).toBe(null);
negateIf(geojson[1], expect(cd0[1].geojson)).toBe(null);

expect(Object.keys(subplot.layers).length).toEqual(layers.length, '# of layers');

Expand Down
17 changes: 9 additions & 8 deletions test/jasmine/tests/plot_api_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var checkTicks = require('../assets/custom_assertions').checkTicks;
var supplyAllDefaults = require('../assets/supply_defaults');

Expand DownExpand Up@@ -1110,9 +1111,9 @@ describe('Test plot api', function() {
var zmax1 = 10;

function check(auto, msg) {
expect(gd._fullData[0].zmin).negateIf(auto).toBe(zmin0, msg);
negateIf(auto, expect(gd._fullData[0].zmin)).toBe(zmin0, msg);
expect(gd._fullData[0].zauto).toBe(auto, msg);
expect(gd._fullData[1].zmax).negateIf(auto).toBe(zmax1, msg);
negateIf(auto, expect(gd._fullData[1].zmax)).toBe(zmax1, msg);
expect(gd._fullData[1].zauto).toBe(auto, msg);
}

Expand DownExpand Up@@ -1153,12 +1154,12 @@ describe('Test plot api', function() {

function check(auto, autocolorscale, msg) {
expect(gd._fullData[0].marker.cauto).toBe(auto, msg);
expect(gd._fullData[0].marker.cmin).negateIf(auto).toBe(mcmin0);
negateIf(auto, expect(gd._fullData[0].marker.cmin)).toBe(mcmin0);
expect(gd._fullData[0].marker.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[0].marker.colorscale).toEqual(auto ? autocscale : scales[mcscl0]);

expect(gd._fullData[1].marker.line.cauto).toBe(auto, msg);
expect(gd._fullData[1].marker.line.cmax).negateIf(auto).toBe(mlcmax1);
negateIf(auto, expect(gd._fullData[1].marker.line.cmax)).toBe(mlcmax1);
expect(gd._fullData[1].marker.line.autocolorscale).toBe(autocolorscale, msg);
expect(gd._fullData[1].marker.line.colorscale).toEqual(auto ? autocscale : scales[mlcscl1]);
}
Expand DownExpand Up@@ -1323,8 +1324,8 @@ describe('Test plot api', function() {
function check(auto, msg) {
expect(gd.data[0].autocontour).toBe(auto, msg);
expect(gd.data[1].autocontour).toBe(auto, msg);
expect(gd.data[0].contours.start).negateIf(auto).toBe(start0, msg);
expect(gd.data[1].contours.size).negateIf(auto).toBe(size1, msg);
negateIf(auto, expect(gd.data[0].contours.start)).toBe(start0, msg);
negateIf(auto, expect(gd.data[1].contours.size)).toBe(size1, msg);
}

Plotly.plot(gd, [
Expand DownExpand Up@@ -1411,9 +1412,9 @@ describe('Test plot api', function() {
var dtick1 = 0.8;

function check(auto, msg) {
expect(gd._fullData[0].colorbar.tick0).negateIf(auto).toBe(tick00, msg);
negateIf(auto, expect(gd._fullData[0].colorbar.tick0)).toBe(tick00, msg);
expect(gd._fullData[0].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
expect(gd._fullData[1].colorbar.dtick).negateIf(auto).toBe(dtick1, msg);
negateIf(auto, expect(gd._fullData[1].colorbar.dtick)).toBe(dtick1, msg);
expect(gd._fullData[1].colorbar.tickmode).toBe(auto ? 'auto' : 'linear', msg);
}

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/polar_test.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var negateIf = require('../assets/negate_if');
var mouseEvent = require('../assets/mouse_event');
var click = require('../assets/click');
var doubleClick = require('../assets/double_click');
Expand DownExpand Up@@ -460,7 +461,7 @@ describe('Test relayout on polar subplots:', function() {
expect(txt.text()).toBe(content, 'radial axis title');
}

expect(newBBox).negateIf(didBBoxChanged).toEqual(lastBBox, 'did bbox change');
negateIf(didBBoxChanged, expect(newBBox)).toEqual(lastBBox, 'did bbox change');
lastBBox = newBBox;
}

Expand Down
Loading