From 488d6d1dcad93f278d041160022c70915f16e65c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Nov 2016 20:52:42 +0100 Subject: [PATCH] Add options for testing getMetaInfo --- test/getMetaInfo.spec.js | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/test/getMetaInfo.spec.js b/test/getMetaInfo.spec.js index 9bd7e0eb..e2402fd7 100644 --- a/test/getMetaInfo.spec.js +++ b/test/getMetaInfo.spec.js @@ -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') @@ -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: [] + }) + }) })