Skip to content

Commit

Permalink
Datashare Core has now its own plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Mar 20, 2020
1 parent ba4ff45 commit cabeb03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class Core extends Behaviors {
this.useCommons()
this.useRouter()
this.useWait()
this.useCore()
return this
}
useI18n () {
Expand Down Expand Up @@ -84,6 +85,14 @@ export default class Core extends Behaviors {
this.use(VueWait)
this.wait = new VueWait({ useVuex: true })
}
useCore () {
const core = this
this.use(class VueCore {
static install (Vue) {
Vue.prototype.$core = core
}
})
}
async configure () {
// Get the config object
const config = await this.api.getConfig()
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/specs/core/Core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ describe('Core', () => {
core.configure()
await expect(core.ready).resolves.toBe(core)
})

it('should install the internal `VueCore` plugin', async () => {
// Create and configure the core
const core = Core.init(localVue).useAll()
const vm = core.mount('#core')
expect(vm.$core).toBeInstanceOf(Core)
})
})

0 comments on commit cabeb03

Please sign in to comment.