-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(core): Add View.clone() method #9588
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 all commits
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 |
|---|---|---|
|
|
@@ -19,6 +19,29 @@ test('View#imports', t => { | |
| t.end(); | ||
| }); | ||
|
|
||
| test('View#clone', t => { | ||
| const view = new MapView({ | ||
| id: 'test-view', | ||
| latitude: 0, | ||
| longitude: 0, | ||
| zoom: 1 | ||
| }); | ||
| const identicalClone = view.clone({}); | ||
| t.ok(identicalClone instanceof MapView, 'identical clone is an instance of MapView'); | ||
| t.ok(identicalClone !== view, 'identical clone is a new instance'); | ||
| t.ok(identicalClone.equals(view), 'identical clone.equals() is true'); | ||
|
|
||
| const clone = view.clone({ | ||
| id: 'cloned-view', | ||
| zoom: 5 | ||
| }); | ||
| t.is(clone.id, 'cloned-view', 'modified clone id is overridden'); | ||
| t.is(clone.props.zoom, 5, 'modified clone prop zoom is overridden'); | ||
| t.is(clone.props.latitude, view.props.latitude, 'other props are preserved'); | ||
| t.is(clone.props.longitude, view.props.longitude, 'other props are preserved'); | ||
|
Collaborator
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. Can we also test that cloning a view should produce an identical view with matching matrices?
Collaborator
Author
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.
I considered it, but seemed to require a bit more work than I would like, I feel that adding the equal test should be pretty solid. |
||
| t.end(); | ||
| }); | ||
|
|
||
| test('View#equals', t => { | ||
| const mapView1 = new MapView({ | ||
| id: 'default-view', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.