Skip to content

Commit 1ccf35c

Browse files
committed
Moved test to frame_api_test.js
1 parent b1e538d commit 1ccf35c

File tree

2 files changed

+38
-46
lines changed

2 files changed

+38
-46
lines changed

test/jasmine/tests/animate_test.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -682,38 +682,6 @@ describe('Animate API details', function() {
682682
}).catch(fail).then(done);
683683
});
684684

685-
it('emits warning if strings are not used and this creates ambiguity', function(done) {
686-
spyOn(Lib, 'warn');
687-
688-
// Test with both multiframe additions and repeated `addFrames` calls - both should count toward the warn limit
689-
Plotly.addFrames(gd, [
690-
{name: 8, data: [{x: [8, 7, 6]}]},
691-
{name: 8888, data: [{x: [8, 7, 6]}]},
692-
{name: 8, data: [{x: [8, 7, 6]}]},
693-
{name: '8', data: [{x: [8, 7, 6]}]}
694-
])
695-
.then(function() {
696-
// so far, two warnings
697-
expect(Lib.warn.calls.count()).toEqual(2);
698-
return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);
699-
})
700-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
701-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
702-
.then(function() {
703-
// so far, 5 + 1 warnings
704-
expect(Lib.warn.calls.count()).toEqual(5 + 1);
705-
return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);
706-
})
707-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
708-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
709-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
710-
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
711-
.then(function() {
712-
// Five (`var numericNameWarningCountLimit = 5`) warnings and one warning saying that there won't be more warnings
713-
expect(Lib.warn.calls.count()).toEqual(5 + 1);
714-
}).catch(fail).then(done);
715-
});
716-
717685
it('ignores null and undefined frames', function(done) {
718686
var cnt = 0;
719687
gd.on('plotly_animatingframe', function() {cnt++;});

test/jasmine/tests/frame_api_test.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,44 @@ describe('Test frame api', function() {
3737
});
3838

3939
describe('#addFrames', function() {
40+
41+
it('issues a warning if a number-named frame would overwrite a frame', function(done) {
42+
var warnings = [];
43+
spyOn(Lib, 'warn').and.callFake(function(msg) {
44+
warnings.push(msg);
45+
});
46+
47+
// Test with both multiframe additions and repeated `addFrames` calls - both should count toward the warn limit
48+
Plotly.addFrames(gd, [
49+
{name: 8, data: [{x: [8, 7, 6]}]},
50+
{name: 8888, data: [{x: [8, 7, 6]}]},
51+
{name: 8, data: [{x: [8, 7, 6]}]},
52+
{name: '8', data: [{x: [8, 7, 6]}]}
53+
])
54+
.then(function() {
55+
// so far, two warnings
56+
expect(Lib.warn.calls.count()).toEqual(2);
57+
expect(warnings[0]).toMatch(/^addFrames.*overwriting/);
58+
return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);
59+
})
60+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
61+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
62+
.then(function() {
63+
// so far, 5 + 1 warnings
64+
expect(Lib.warn.calls.count()).toEqual(5 + 1);
65+
expect(warnings[5]).toMatch(/^addFrames.*suppressed/);
66+
return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);
67+
})
68+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
69+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
70+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
71+
.then(function() {return Plotly.addFrames(gd, [{name: 8, data: [{x: [3, 2, 1]}]}]);})
72+
.then(function() {
73+
// Five (`var numericNameWarningCountLimit = 5`) warnings and one warning saying that there won't be more warnings
74+
expect(Lib.warn.calls.count()).toEqual(5 + 1);
75+
}).catch(fail).then(done);
76+
});
77+
4078
it('treats an undefined list as a noop', function(done) {
4179
Plotly.addFrames(gd, undefined).then(function() {
4280
expect(Object.keys(h)).toEqual([]);
@@ -102,20 +140,6 @@ describe('Test frame api', function() {
102140
}).catch(fail).then(done);
103141
});
104142

105-
it('issues a warning if a number-named frame would overwrite a frame', function(done) {
106-
var warnings = [];
107-
spyOn(Lib, 'warn').and.callFake(function(msg) {
108-
warnings.push(msg);
109-
});
110-
111-
Plotly.addFrames(gd, [{name: 2}]).then(function() {
112-
return Plotly.addFrames(gd, [{name: 2, layout: {foo: 'bar'}}]);
113-
}).then(function() {
114-
expect(warnings.length).toEqual(1);
115-
expect(warnings[0]).toMatch(/overwriting/);
116-
}).catch(fail).then(done);
117-
});
118-
119143
it('avoids name collisions', function(done) {
120144
Plotly.addFrames(gd, [{name: 'frame 0'}, {name: 'frame 2'}]).then(function() {
121145
expect(f).toEqual([{name: 'frame 0'}, {name: 'frame 2'}]);

0 commit comments

Comments
 (0)