Skip to content

Commit

Permalink
Add options for testing getMetaInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Nov 14, 2016
1 parent 8f39c97 commit 488d6d1
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion test/getMetaInfo.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import Vue from 'vue'
import _getMetaInfo from '../src/shared/getMetaInfo'
import {
VUE_META_KEY_NAME,
VUE_META_ATTRIBUTE,
VUE_META_SERVER_RENDERED_ATTRIBUTE,
VUE_META_TAG_LIST_ID_KEY_NAME
} from '../src/shared/constants'

const getMetaInfo = _getMetaInfo()
// set some default options
const defaultOptions = {
keyName: VUE_META_KEY_NAME,
attribute: VUE_META_ATTRIBUTE,
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
}

const getMetaInfo = _getMetaInfo(defaultOptions)

describe('getMetaInfo', () => {
// const container = document.createElement('div')
Expand All @@ -25,4 +39,30 @@ describe('getMetaInfo', () => {
noscript: []
})
})

it('returns metaInfos when used in component', () => {
component = new Vue({
metaInfo: {
title: 'Hello',
meta: [
{ charset: 'utf-8' }
]
}
})
expect(getMetaInfo(component)).to.eql({
title: 'Hello',
titleChunk: 'Hello',
titleTemplate: '%s',
htmlAttrs: {},
bodyAttrs: {},
meta: [
{ charset: 'utf-8' }
],
base: [],
link: [],
style: [],
script: [],
noscript: []
})
})
})

0 comments on commit 488d6d1

Please sign in to comment.