2
0
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:
Declan de Wet
2016-11-02 10:25:43 +02:00
parent d033b8ed12
commit 4f4f65a11b
6 changed files with 32 additions and 22 deletions
+21 -17
View File
@@ -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')))
})