-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(geojs): use Vue's provide/inject API in the geojs layer mixin
This provides more flexibility in using the components compared to accessing the `$parent` component directly. This is particularly relevant because newer versions of `@vue/test-utils` broke how we were injecting the parent components in unit testing. Note: This also updates `@vue/test-utils`, but not to the latest version because there is a bug since `beta-18` causing props not to be updated. This may (or may not) be related to the following issue: vuejs/vue-test-utils#738
- Loading branch information
Showing
12 changed files
with
3,060 additions
and
3,035 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import geo from 'geojs'; | ||
import { mount } from '@vue/test-utils'; | ||
|
||
class ProvideGeojs { | ||
start() { | ||
this.element = document.createElement('div'); | ||
this.element.style.width = '300px'; | ||
this.element.style.height = '200px'; | ||
document.body.appendChild(this.element); | ||
this.geojsMap = geo.map({ node: this.element }); | ||
} | ||
|
||
stop() { | ||
this.geojsMap.exit(); | ||
this.element.remove(); | ||
this.element = null; | ||
} | ||
|
||
mountOptions() { | ||
return { | ||
provide: { | ||
$geojs: geo, | ||
$geojsMap: this.geojsMap, | ||
}, | ||
}; | ||
} | ||
|
||
mountLayer(component, options = {}) { | ||
return mount(component, Object.assign( | ||
this.mountOptions(), | ||
options, | ||
)); | ||
} | ||
} | ||
|
||
export default ProvideGeojs; |
This file contains 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -323,9 +323,9 @@ | |
source-map "^0.5.6" | ||
vue-template-es2015-compiler "^1.6.0" | ||
|
||
"@vue/test-utils@^1.0.0-beta.16": | ||
version "1.0.0-beta.16" | ||
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.16.tgz#dcf7a30304391422e382b5f97db6eb9508112906" | ||
"@vue/[email protected].17": | ||
version "1.0.0-beta.17" | ||
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.17.tgz#cdf4213d6f0aded2416465fd4829c162a48b876d" | ||
dependencies: | ||
lodash "^4.17.4" | ||
|
||
|