Skip to content

Revert "Make plot_css_test.js asynchronous" #828

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

Closed
wants to merge 1 commit into from
Closed
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
73 changes: 35 additions & 38 deletions test/jasmine/tests/plot_css_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('css injection', function() {

// the most basic of basic plots
function plot(target) {
return Plotly.plot(target, [{
Plotly.plot(target, [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16]
}], {
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('css injection', function() {
}
}

it('inserts styles on initial plot', function(done) {
it('inserts styles on initial plot', function() {
deletePlotCSSRules(document); // clear the rules

// fix scope errors
Expand All @@ -78,44 +78,42 @@ describe('css injection', function() {

// plot
var gd = createGraphDiv();
plot(gd).then(function() {
plot(gd);

// check for styles
allSelectors = plotcss_utils.getAllRuleSelectors(document);
// check for styles
allSelectors = plotcss_utils.getAllRuleSelectors(document);

for(selector in plotcss) {
fullSelector = plotcss_utils.buildFullSelector(selector);
for(selector in plotcss) {
fullSelector = plotcss_utils.buildFullSelector(selector);

expect(allSelectors.indexOf(fullSelector)).not.toEqual(-1);
}
expect(allSelectors.indexOf(fullSelector)).not.toEqual(-1);
}

// clean up
return destroyGraphDiv();
}).then(done);
// clean up
destroyGraphDiv();
});

it('inserts styles in a child window document', function(done) {
it('inserts styles in a child window document', function() {
var gd = createGraphDivInChildWindow();
var childWindow = gd.ownerDocument.defaultView;

// plot
plot(gd).then(function() {
plot(gd);

// check for styles
var allSelectors = plotcss_utils.getAllRuleSelectors(gd.ownerDocument);
// check for styles
var allSelectors = plotcss_utils.getAllRuleSelectors(gd.ownerDocument);

for(var selector in plotcss) {
var fullSelector = plotcss_utils.buildFullSelector(selector);
for(var selector in plotcss) {
var fullSelector = plotcss_utils.buildFullSelector(selector);

expect(allSelectors.indexOf(fullSelector)).not.toEqual(-1);
}
expect(allSelectors.indexOf(fullSelector)).not.toEqual(-1);
}

// clean up
childWindow.close();
}).then(done);
// clean up
childWindow.close();
});

it('does not insert duplicate styles', function(done) {
it('does not insert duplicate styles', function() {
deletePlotCSSRules(document); // clear the rules

// fix scope errors
Expand All @@ -133,23 +131,22 @@ describe('css injection', function() {

// plot
var gd = createGraphDiv();
plot(gd).then(function() {
return plot(gd); // plot again so injectStyles gets called again
}).then(function() {
// check for styles
allSelectors = plotcss_utils.getAllRuleSelectors(document);
plot(gd);
plot(gd); // plot again so injectStyles gets called again

// check for styles
allSelectors = plotcss_utils.getAllRuleSelectors(document);

for(selector in plotcss) {
fullSelector = plotcss_utils.buildFullSelector(selector);
for(selector in plotcss) {
fullSelector = plotcss_utils.buildFullSelector(selector);

var firstIndex = allSelectors.indexOf(fullSelector);
var firstIndex = allSelectors.indexOf(fullSelector);

// there should be no occurences after the initial one
expect(allSelectors.indexOf(fullSelector, firstIndex + 1)).toEqual(-1);
}
// there should be no occurences after the initial one
expect(allSelectors.indexOf(fullSelector, firstIndex + 1)).toEqual(-1);
}

// clean up
return destroyGraphDiv();
}).then(done);
// clean up
destroyGraphDiv();
});
});