-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make frame with nulls clear items & array containers #1118
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
Changes from 1 commit
69bffe1
4c49755
d21d782
138ac35
d0953a0
174b640
36859f1
66f8bb7
8ed1957
9de2f77
5de6ff0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,4 +427,71 @@ describe('Test Plots', function() { | |
expect(gd._transitioning).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('extendObjectWithContainers', function() { | ||
|
||
function assert(dest, src, expected) { | ||
Plots.extendObjectWithContainers(dest, src, ['container']); | ||
expect(dest).toEqual(expected); | ||
} | ||
|
||
it('extend each container items', function() { | ||
var dest = { | ||
container: [ | ||
{ text: '1', x: 1, y: 1 }, | ||
{ text: '2', x: 2, y: 2 } | ||
] | ||
}; | ||
|
||
var src = { | ||
container: [ | ||
{ text: '1-new' }, | ||
{ text: '2-new' } | ||
] | ||
}; | ||
|
||
var expected = { | ||
container: [ | ||
{ text: '1-new', x: 1, y: 1 }, | ||
{ text: '2-new', x: 2, y: 2 } | ||
] | ||
}; | ||
|
||
assert(dest, src, expected); | ||
}); | ||
|
||
it('clears container items when applying null src items', function() { | ||
var dest = { | ||
container: [ | ||
{ text: '1', x: 1, y: 1 }, | ||
{ text: '2', x: 2, y: 2 } | ||
] | ||
}; | ||
|
||
var src = { | ||
container: [null, null] | ||
}; | ||
|
||
var expected = { | ||
container: [null, null] | ||
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. N.B. I changed the behavior here as discussed in #1118 (comment) - see 36859f1 In brief, frames with array containers set to null extend the state with |
||
}; | ||
|
||
assert(dest, src, expected); | ||
}); | ||
|
||
it('clears container applying null src', function() { | ||
var dest = { | ||
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. Looks good. Ditto on behavior of undefined? |
||
container: [ | ||
{ text: '1', x: 1, y: 1 }, | ||
{ text: '2', x: 2, y: 2 } | ||
] | ||
}; | ||
|
||
var src = { container: null }; | ||
|
||
var expected = { container: null }; | ||
|
||
assert(dest, src, expected); | ||
}); | ||
}); | ||
}); |
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 also looks like what I'd expect. Am I correct in understanding that
[undefined, undefined]
would skip applying any changes?