mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-11 02:42:25 +03:00
switch to beforemount hook & improve test timing logic
This commit is contained in:
+21
-17
@@ -1,25 +1,29 @@
|
||||
import Vue from 'vue'
|
||||
import Meta from 'vue-meta'
|
||||
|
||||
import { Promise } from 'es6-promise'
|
||||
|
||||
Vue.use(Meta)
|
||||
|
||||
before(() => {
|
||||
new Vue({
|
||||
template: `
|
||||
<div id="app">
|
||||
</div>
|
||||
`,
|
||||
metaInfo: {
|
||||
title: 'Foo'
|
||||
}
|
||||
}).$mount()
|
||||
})
|
||||
|
||||
describe('basic', () => {
|
||||
it('sets the document title', (done) => {
|
||||
setTimeout(() => {
|
||||
expect(document.title).to.equal('Foo')
|
||||
done()
|
||||
}, 100)
|
||||
const container = document.createElement('div')
|
||||
let vm
|
||||
|
||||
function setMetaInfo (metaInfo) {
|
||||
return new Promise((resolve) => {
|
||||
vm = new Vue({ el: container, metaInfo })
|
||||
vm.$on('vue-meta-update', resolve)
|
||||
})
|
||||
}
|
||||
|
||||
afterEach(() => vm.$destroy())
|
||||
|
||||
it('sets a title', () => setMetaInfo({ title: 'Foo' })
|
||||
.then(() => expect(document.title).to.equal('Foo')))
|
||||
|
||||
it('sets a title with a template', () => setMetaInfo({
|
||||
title: 'Foo',
|
||||
titleTemplate: '%s Bar'
|
||||
})
|
||||
.then(() => expect(document.title).to.equal('Foo Bar')))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user