Skip to content

Commit 3bccdb1

Browse files
committed
use async pattern after plot in axes test
1 parent c12b3e8 commit 3bccdb1

File tree

1 file changed

+72
-36
lines changed

1 file changed

+72
-36
lines changed

test/jasmine/tests/axes_test.js

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,146 +1915,174 @@ describe('Test axes', function() {
19151915
afterEach(destroyGraphDiv);
19161916

19171917
describe('setting, or not setting categoryorder if it is not explicitly declared', function() {
1918-
it('should set categoryorder to default if categoryorder and categoryarray are not supplied', function() {
1918+
it('should set categoryorder to default if categoryorder and categoryarray are not supplied', function(done) {
19191919
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {xaxis: {type: 'category'}})
19201920
.then(function() {
19211921
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
19221922
expect(gd._fullLayout.xaxis.categorarray).toBe(undefined);
1923-
});
1923+
})
1924+
.catch(failTest)
1925+
.then(done);
19241926
});
19251927

1926-
it('should set categoryorder to default even if type is not set to category explicitly', function() {
1928+
it('should set categoryorder to default even if type is not set to category explicitly', function(done) {
19271929
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}])
19281930
.then(function() {
19291931
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
19301932
expect(gd._fullLayout.xaxis.categorarray).toBe(undefined);
1931-
});
1933+
})
1934+
.catch(failTest)
1935+
.then(done);
19321936
});
19331937

1934-
it('should NOT set categoryorder to default if type is not category', function() {
1938+
it('should NOT set categoryorder to default if type is not category', function(done) {
19351939
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}])
19361940
.then(function() {
19371941
expect(gd._fullLayout.yaxis.categoryorder).toBe(undefined);
19381942
expect(gd._fullLayout.xaxis.categorarray).toBe(undefined);
1939-
});
1943+
})
1944+
.catch(failTest)
1945+
.then(done);
19401946
});
19411947

1942-
it('should set categoryorder to default if type is overridden to be category', function() {
1948+
it('should set categoryorder to default if type is overridden to be category', function(done) {
19431949
Plotly.plot(gd, [{x: [1, 2, 3, 4, 5], y: [15, 11, 12, 13, 14]}], {yaxis: {type: 'category'}})
19441950
.then(function() {
19451951
expect(gd._fullLayout.xaxis.categoryorder).toBe(undefined);
19461952
expect(gd._fullLayout.yaxis.categorarray).toBe(undefined);
19471953
expect(gd._fullLayout.yaxis.categoryorder).toBe('trace');
19481954
expect(gd._fullLayout.yaxis.categorarray).toBe(undefined);
1949-
});
1955+
})
1956+
.catch(failTest)
1957+
.then(done);
19501958
});
19511959
});
19521960

19531961
describe('setting categoryorder to "array"', function() {
1954-
it('should leave categoryorder on "array" if it is supplied', function() {
1962+
it('should leave categoryorder on "array" if it is supplied', function(done) {
19551963
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
19561964
xaxis: {type: 'category', categoryorder: 'array', categoryarray: ['b', 'a', 'd', 'e', 'c']}
19571965
})
19581966
.then(function() {
19591967
expect(gd._fullLayout.xaxis.categoryorder).toBe('array');
19601968
expect(gd._fullLayout.xaxis.categoryarray).toEqual(['b', 'a', 'd', 'e', 'c']);
1961-
});
1969+
})
1970+
.catch(failTest)
1971+
.then(done);
19621972
});
19631973

1964-
it('should switch categoryorder on "array" if it is not supplied but categoryarray is supplied', function() {
1974+
it('should switch categoryorder on "array" if it is not supplied but categoryarray is supplied', function(done) {
19651975
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
19661976
xaxis: {type: 'category', categoryarray: ['b', 'a', 'd', 'e', 'c']}
19671977
})
19681978
.then(function() {
19691979
expect(gd._fullLayout.xaxis.categoryorder).toBe('array');
19701980
expect(gd._fullLayout.xaxis.categoryarray).toEqual(['b', 'a', 'd', 'e', 'c']);
1971-
});
1981+
})
1982+
.catch(failTest)
1983+
.then(done);
19721984
});
19731985

1974-
it('should revert categoryorder to "trace" if "array" is supplied but there is no list', function() {
1986+
it('should revert categoryorder to "trace" if "array" is supplied but there is no list', function(done) {
19751987
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
19761988
xaxis: {type: 'category', categoryorder: 'array'}
19771989
})
19781990
.then(function() {
19791991
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
19801992
expect(gd._fullLayout.xaxis.categorarray).toBe(undefined);
1981-
});
1993+
})
1994+
.catch(failTest)
1995+
.then(done);
19821996
});
19831997
});
19841998

19851999
describe('do not set categoryorder to "array" if list exists but empty', function() {
1986-
it('should switch categoryorder to default if list is not supplied', function() {
2000+
it('should switch categoryorder to default if list is not supplied', function(done) {
19872001
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
19882002
xaxis: {type: 'category', categoryorder: 'array', categoryarray: []}
19892003
})
19902004
.then(function() {
19912005
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
19922006
expect(gd._fullLayout.xaxis.categoryarray).toEqual([]);
1993-
});
2007+
})
2008+
.catch(failTest)
2009+
.then(done);
19942010
});
19952011

1996-
it('should not switch categoryorder on "array" if categoryarray is supplied but empty', function() {
2012+
it('should not switch categoryorder on "array" if categoryarray is supplied but empty', function(done) {
19972013
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
19982014
xaxis: {type: 'category', categoryarray: []}
19992015
})
20002016
.then(function() {
20012017
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
20022018
expect(gd._fullLayout.xaxis.categoryarray).toEqual(undefined);
2003-
});
2019+
})
2020+
.catch(failTest)
2021+
.then(done);
20042022
});
20052023
});
20062024

20072025
describe('do NOT set categoryorder to "array" if it has some other proper value', function() {
2008-
it('should use specified categoryorder if it is supplied even if categoryarray exists', function() {
2026+
it('should use specified categoryorder if it is supplied even if categoryarray exists', function(done) {
20092027
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
20102028
xaxis: {type: 'category', categoryorder: 'trace', categoryarray: ['b', 'a', 'd', 'e', 'c']}
20112029
})
20122030
.then(function() {
20132031
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
20142032
expect(gd._fullLayout.xaxis.categoryarray).toBe(undefined);
2015-
});
2033+
})
2034+
.catch(failTest)
2035+
.then(done);
20162036
});
20172037

2018-
it('should use specified categoryorder if it is supplied even if categoryarray exists', function() {
2038+
it('should use specified categoryorder if it is supplied even if categoryarray exists', function(done) {
20192039
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
20202040
xaxis: {type: 'category', categoryorder: 'category ascending', categoryarray: ['b', 'a', 'd', 'e', 'c']}
20212041
})
20222042
.then(function() {
20232043
expect(gd._fullLayout.xaxis.categoryorder).toBe('category ascending');
20242044
expect(gd._fullLayout.xaxis.categoryarray).toBe(undefined);
2025-
});
2045+
})
2046+
.catch(failTest)
2047+
.then(done);
20262048
});
20272049

2028-
it('should use specified categoryorder if it is supplied even if categoryarray exists', function() {
2050+
it('should use specified categoryorder if it is supplied even if categoryarray exists', function(done) {
20292051
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
20302052
xaxis: {type: 'category', categoryorder: 'category descending', categoryarray: ['b', 'a', 'd', 'e', 'c']}
20312053
})
20322054
.then(function() {
20332055
expect(gd._fullLayout.xaxis.categoryorder).toBe('category descending');
20342056
expect(gd._fullLayout.xaxis.categoryarray).toBe(undefined);
2035-
});
2057+
})
2058+
.catch(failTest)
2059+
.then(done);
20362060
});
20372061
});
20382062

20392063
describe('setting categoryorder to the default if the value is unexpected', function() {
2040-
it('should switch categoryorder to "trace" if mode is supplied but invalid', function() {
2064+
it('should switch categoryorder to "trace" if mode is supplied but invalid', function(done) {
20412065
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
20422066
xaxis: {type: 'category', categoryorder: 'invalid value'}
20432067
})
20442068
.then(function() {
20452069
expect(gd._fullLayout.xaxis.categoryorder).toBe('trace');
20462070
expect(gd._fullLayout.xaxis.categoryarray).toBe(undefined);
2047-
});
2071+
})
2072+
.catch(failTest)
2073+
.then(done);
20482074
});
20492075

2050-
it('should switch categoryorder to "array" if mode is supplied but invalid and list is supplied', function() {
2076+
it('should switch categoryorder to "array" if mode is supplied but invalid and list is supplied', function(done) {
20512077
Plotly.plot(gd, [{x: ['c', 'a', 'e', 'b', 'd'], y: [15, 11, 12, 13, 14]}], {
20522078
xaxis: {type: 'category', categoryorder: 'invalid value', categoryarray: ['b', 'a', 'd', 'e', 'c']}
20532079
})
20542080
.then(function() {
20552081
expect(gd._fullLayout.xaxis.categoryorder).toBe('array');
20562082
expect(gd._fullLayout.xaxis.categoryarray).toEqual(['b', 'a', 'd', 'e', 'c']);
2057-
});
2083+
})
2084+
.catch(failTest)
2085+
.then(done);
20582086
});
20592087
});
20602088
});
@@ -2069,13 +2097,15 @@ describe('Test axes', function() {
20692097
afterEach(destroyGraphDiv);
20702098

20712099
describe('a category has the same value of one of the auto range computed extreme', function() {
2072-
it('should compute the right range for X axis', function() {
2100+
it('should compute the right range for X axis', function(done) {
20732101
Plotly.plot(gd, [{x: ['0', '-0.5', '3.5', 'Not Known'], y: [ '1.0', '1.0', '2.0', '1.0'], type: 'bar'}], {
20742102
xaxis: {type: 'category', autorange: true}
20752103
})
20762104
.then(function() {
20772105
expect(gd._fullLayout.xaxis._rl).toEqual([-0.5, 3.5]);
2078-
});
2106+
})
2107+
.catch(failTest)
2108+
.then(done);
20792109
});
20802110
});
20812111
});
@@ -2090,7 +2120,7 @@ describe('Test axes', function() {
20902120

20912121
afterEach(destroyGraphDiv);
20922122

2093-
it('should set defaults on bad inputs', function() {
2123+
it('should set defaults on bad inputs', function(done) {
20942124
var layout = {
20952125
yaxis: {
20962126
ticklen: 'invalid',
@@ -2112,10 +2142,12 @@ describe('Test axes', function() {
21122142
expect(yaxis.showticklabels).toBe(true);
21132143
expect(yaxis.tickfont).toEqual({ family: '"Open Sans", verdana, arial, sans-serif', size: 12, color: '#444' });
21142144
expect(yaxis.tickangle).toBe('auto');
2115-
});
2145+
})
2146+
.catch(failTest)
2147+
.then(done);
21162148
});
21172149

2118-
it('should use valid inputs', function() {
2150+
it('should use valid inputs', function(done) {
21192151
var layout = {
21202152
yaxis: {
21212153
ticklen: 10,
@@ -2137,10 +2169,12 @@ describe('Test axes', function() {
21372169
expect(yaxis.showticklabels).toBe(true);
21382170
expect(yaxis.tickfont).toEqual({ family: 'Garamond', size: 72, color: '#0FF' });
21392171
expect(yaxis.tickangle).toBe(-20);
2140-
});
2172+
})
2173+
.catch(failTest)
2174+
.then(done);
21412175
});
21422176

2143-
it('should conditionally coerce based on showticklabels', function() {
2177+
it('should conditionally coerce based on showticklabels', function(done) {
21442178
var layout = {
21452179
yaxis: {
21462180
showticklabels: false,
@@ -2152,7 +2186,9 @@ describe('Test axes', function() {
21522186
.then(function() {
21532187
var yaxis = gd._fullLayout.yaxis;
21542188
expect(yaxis.tickangle).toBeUndefined();
2155-
});
2189+
})
2190+
.catch(failTest)
2191+
.then(done);
21562192
});
21572193
});
21582194

0 commit comments

Comments
 (0)