8000 Update props.spec.js · bootstrap-vue/bootstrap-vue@97e5c20 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Commit 97e5c20
Browse files
committed
Update props.spec.js
1 parent 735537d commit 97e5c20

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/utils/props.spec.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mount } from '@vue/test-utils'
22
import { setConfig } from './config-set'
3-
import { copyProps, makePropsConfigurable } from './props'
3+
import { copyProps, makeProp, makePropsConfigurable } from './props'
44

55
describe('utils/props', () => {
66
it('copyProps() works with array props', async () => {
@@ -31,6 +31,49 @@ describe('utils/props', () => {
3131
expect(copyProps(props).c).toEqual(props.c)
3232
})
3333

34+
it('makeProp() works', async () => {
35+
expect(makeProp()).toEqual({})
36+
expect(makeProp(undefined)).toEqual({})
37+
expect(makeProp(null)).toEqual({})
38+
expect(makeProp('')).toEqual({})
39+
40+
expect(makeProp(Array)).toEqual({ type: Array })
41+
expect(makeProp(Boolean)).toEqual({ type: Boolean })
42+
expect(makeProp(Function)).toEqual({ type: Function })
43+
expect(makeProp(Number)).toEqual({ type: Number })
44+
expect(makeProp(Object)).toEqual({ type: Object })
45+
expect(makeProp(String)).toEqual({ type: String })
46+
47+
expect(makeProp(Array, null)).toEqual({ type: Array, default: null })
48+
expect(makeProp(Boolean, false)).toEqual({ type: Boolean, default: false })
49+
expect(makeProp(Function, null)).toEqual({ type: Function, default: null })
50+
expect(makeProp(Number, 0)).toEqual({ type: Number, default: 0 })
51+
expect(makeProp(Object, null)).toEqual({ type: Object, default: null })
52+
expect(makeProp(String, '')).toEqual({ type: String, default: '' })
53+
54+
expect(typeof makeProp(Array, []).default).toEqual('function')
55+
expect(makeProp(Array, []).default()).toEqual([])
56+
57+
const fn = () => {}
58+
expect(typeof makeProp(Function, fn).default).toEqual('function')
59+
expect(makeProp(Function, fn).default).toEqual(fn)
60+
61+
expect(typeof makeProp(Object, {}).default).toEqual('function')
62+
expect(makeProp(Object, {}).default()).toEqual({})
63+
64+
expect(makeProp(Array, true)).toEqual({ type: Array, required: true })
65+
expect(makeProp(Boolean, true)).toEqual({ type: Boolean, default: true })
66+
expect(makeProp(Function, true)).toEqual({ type: Function, required: true })
67+
expect(makeProp(Number, true)).toEqual({ type: Number, required: true })
68+
expect(makeProp(Object, true)).toEqual({ type: Object, required: true })
69+
expect(makeProp(String, true)).toEqual({ type: String, required: true })
70+
71+
const validator = value => !!value
72+
expect(makeProp(String, '', undefined)).toEqual({ type: String, default: '' })
73+
expect(makeProp(String, '', validator)).toEqual({ type: String, default: '', validator })
74+
expect(makeProp(String, undefined, validator)).toEqual({ type: String, validator })
75+
})
76+
3477
it('makePropsConfigurable() works', async () => {
3578
const NAME = 'Component'
3679
const props = {

0 commit comments

Comments
 (0)
0