2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-11 19:02:24 +03:00

fix: implement simply array polyfills (fixes #328)

This commit is contained in:
pimlie
2019-03-11 17:19:55 +01:00
committed by Alexander Lichter
parent 02c7beb6de
commit d38f81e0a9
9 changed files with 133 additions and 45 deletions
+1 -26
View File
@@ -1,32 +1,7 @@
/**
* @jest-environment node
*/
import setOptions from '../../src/shared/options'
import { setOptions } from '../../src/shared/options'
import { defaultOptions } from '../../src/shared/constants'
import { ensureIsArray } from '../../src/utils/ensure'
import { hasGlobalWindowFn } from '../../src/utils/window'
describe('shared', () => {
test('ensureIsArray ensures var is array', () => {
let a = { p: 1 }
expect(ensureIsArray(a)).toEqual([])
a = 1
expect(ensureIsArray(a)).toEqual([])
a = [1]
expect(ensureIsArray(a)).toBe(a)
})
test('ensureIsArray ensures obj prop is array', () => {
const a = { p: 1 }
expect(ensureIsArray(a, 'p')).toEqual({ p: [] })
})
test('no error when window is not defined', () => {
expect(hasGlobalWindowFn()).toBe(false)
})
test('can use setOptions', () => {
const keyName = 'MY KEY'
let options = { keyName }