-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Enforce casting requested frame names to strings #1124
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,14 @@ describe('Test animate API', function() { | |
|
||
mockCopy = Lib.extendDeep({}, mock); | ||
|
||
// ------------------------------------------------------------ | ||
// NB: TRANSITION IS FAKED | ||
// | ||
// This means that you should not expect `.animate` to actually | ||
// modify the plot in any way in the tests below. For tests | ||
// involvingnon-faked transitions, see the bottom of this file. | ||
// ------------------------------------------------------------ | ||
|
||
spyOn(Plots, 'transition').and.callFake(function() { | ||
// Transition's fake behavior is just to delay by the duration | ||
// and resolve: | ||
|
@@ -579,3 +587,48 @@ describe('Test animate API', function() { | |
}); | ||
}); | ||
}); | ||
|
||
describe('Test animate API', function() { | ||
'use strict'; | ||
|
||
var gd, mockCopy; | ||
|
||
beforeEach(function(done) { | ||
gd = createGraphDiv(); | ||
mockCopy = Lib.extendDeep({}, mock); | ||
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why use the two-argument signature here? 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. historical reasons! |
||
return Plotly.addFrames(gd, mockCopy.frames); | ||
}).then(done); | ||
}); | ||
|
||
afterEach(function() { | ||
Plotly.purge(gd); | ||
destroyGraphDiv(); | ||
}); | ||
|
||
it('does not fail if strings are not used', function(done) { | ||
Plotly.addFrames(gd, [{name: 8, data: [{x: [8, 7, 6]}]}]).then(function() { | ||
// Verify it was added as a string name: | ||
expect(gd._transitionData._frameHash['8']).not.toBeUndefined(); | ||
|
||
// Transition using a number: | ||
return Plotly.animate(gd, [8], {transition: {duration: 0}, frame: {duration: 0}}); | ||
}).then(function() { | ||
// Confirm the result: | ||
expect(gd.data[0].x).toEqual([8, 7, 6]); | ||
}).catch(fail).then(done); | ||
}); | ||
|
||
it('ignores null and undefined frames', function(done) { | ||
var cnt = 0; | ||
gd.on('plotly_animatingframe', function() {cnt++;}); | ||
|
||
Plotly.animate(gd, ['frame0', null, undefined], {transition: {duration: 0}, frame: {duration: 0}}).then(function() { | ||
// Check only one animating was fired: | ||
expect(cnt).toEqual(1); | ||
|
||
// Check unused frames did not affect the current frame: | ||
expect(gd._fullLayout._currentFrame).toEqual('frame0'); | ||
}).catch(fail).then(done); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could go elsewhere so that no failsafe is needed, but it's a trivially inexpensive one-liner, so I think it's a good idea.