Skip to content

no more fail for async tests, only failTest #2918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 27 additions & 11 deletions test/jasmine/tests/command_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var Registry = require('@src/registry');
var Plots = Plotly.Plots;
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var fail = require('../assets/fail_test');
var failTest = require('../assets/fail_test');
var Lib = require('@src/lib');

describe('Plots.executeAPICommand', function() {
Expand Down Expand Up @@ -34,7 +34,9 @@ describe('Plots.executeAPICommand', function() {
expect(m.calls.argsFor(0)).toEqual([gd, 'foo', 'bar']);

expect(value).toEqual('resolution');
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

});
Expand All @@ -47,22 +49,24 @@ describe('Plots.executeAPICommand', function() {
});

it('calls the API method and rejects', function(done) {
Plots.executeAPICommand(gd, 'restyle', ['foo', 'bar']).then(fail, function(value) {
Plots.executeAPICommand(gd, 'restyle', ['foo', 'bar']).then(failTest, function(value) {
var m = Registry.apiMethodRegistry.restyle;
expect(m).toHaveBeenCalled();
expect(m.calls.count()).toEqual(1);
expect(m.calls.argsFor(0)).toEqual([gd, 'foo', 'bar']);

expect(value).toEqual('rejection');
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

});

describe('with the skip command', function() {
it('resolves immediately', function(done) {
Plots.executeAPICommand(gd, 'skip')
.catch(fail).then(done);
.catch(failTest).then(done);
});
});
});
Expand Down Expand Up @@ -514,7 +518,9 @@ describe('component bindings', function() {
return Plotly.restyle(gd, 'marker.width', 8);
}).then(function() {
expect(count).toEqual(1);
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

it('logs a warning if unable to create an observer', function() {
Expand All @@ -536,15 +542,19 @@ describe('component bindings', function() {

Plotly.restyle(gd, 'marker.color', 'blue').then(function() {
expect(gd.layout.sliders[0].active).toBe(4);
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

it('does not update the component if the value is not present', function(done) {
expect(gd.layout.sliders[0].active).toBe(0);

Plotly.restyle(gd, 'marker.color', 'black').then(function() {
expect(gd.layout.sliders[0].active).toBe(0);
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

it('udpates bound components when the computed value changes', function(done) {
Expand All @@ -555,7 +565,9 @@ describe('component bindings', function() {
// nonetheless is bound by value to the component.
Plotly.restyle(gd, 'line.color', 'blue').then(function() {
expect(gd.layout.sliders[0].active).toBe(4);
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});
});

Expand Down Expand Up @@ -623,7 +635,9 @@ describe('attaching component bindings', function() {
// Bindings are no longer simple, so check to ensure they have
// been removed
expect(gd._internalEv._events.plotly_animatingframe).toBeUndefined();
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});

it('attaches and updates bindings for updatemenus', function(done) {
Expand Down Expand Up @@ -676,6 +690,8 @@ describe('attaching component bindings', function() {
// Bindings are no longer simple, so check to ensure they have
// been removed
expect(gd._internalEv._events.plotly_animatingframe).toBeUndefined();
}).catch(fail).then(done);
})
.catch(failTest)
.then(done);
});
});
4 changes: 2 additions & 2 deletions test/jasmine/tests/download_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var Plotly = require('@lib/index');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var textchartMock = require('@mocks/text_chart_arrays.json');
var fail = require('../assets/fail_test');
var failTest = require('../assets/fail_test');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW there was only one actual bug caught in this change, download_test has one real Jasmine fail in it which we were overriding with our async version:

fail('undefined saveBlob');

which I guess would still show up as a test failure... it just wouldn't give the right message.


var Lib = require('@src/lib');

Expand Down Expand Up @@ -106,7 +106,7 @@ describe('Plotly.downloadImage', function() {
reader.readAsText(savedBlob);
});
})
.catch(fail)
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);
});
Expand Down
6 changes: 3 additions & 3 deletions test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Drawing = require('@src/components/drawing');
var svgTextUtils = require('@src/lib/svg_text_utils');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var fail = require('../assets/fail_test');
var failTest = require('../assets/fail_test');

describe('Drawing', function() {
'use strict';
Expand Down Expand Up @@ -422,7 +422,7 @@ describe('Drawing', function() {
bottom: 4
});
})
.catch(fail)
.catch(failTest)
.then(done);
});

Expand Down Expand Up @@ -546,7 +546,7 @@ describe('gradients', function() {
// full replot and no resulting markers at all -> no gradients
checkGradientIds([], [], [], []);
})
.catch(fail)
.catch(failTest)
.then(done);
});
});
6 changes: 3 additions & 3 deletions test/jasmine/tests/errorbars_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var Plotly = require('@lib/index');
var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var fail = require('../assets/fail_test');
var failTest = require('../assets/fail_test');


describe('errorbar plotting', function() {
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('errorbar plotting', function() {
.then(function() {
check([-0.6667, 2.6667], [-0.2629, 4.9949], 3, 3);
})
.catch(fail)
.catch(failTest)
.then(done);
});

Expand Down Expand Up @@ -97,7 +97,7 @@ describe('errorbar plotting', function() {
{xs: 10, xh: 18}
]);
})
.catch(fail)
.catch(failTest)
.then(done);
});
});
Loading