This repository has been archived by the owner on Jan 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
87 lines (71 loc) · 1.75 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import Vue from 'vue';
import test from 'ava';
import { has, startCase } from 'lodash';
import propsToLocal from './src';
// const nextTick = () => new Promise((resolve) => {
// Vue.nextTick(() => {
// resolve();
// });
// });
test('defines props correctly', (t) => {
const mixin = propsToLocal({
booleanTest: {
type: Boolean,
default: true,
},
});
t.deepEqual(mixin.props, {
booleanTest: {
type: Boolean,
default: true,
},
});
});
test('excludes "deep" attribute from props', (t) => {
const mixin = propsToLocal({
deepTest: {
type: Boolean,
deep: true,
},
});
t.deepEqual(mixin.props, {
deepTest: {
type: Boolean,
},
});
});
test('excludes "format" attribute from props', (t) => {
const mixin = propsToLocal({
deepTest: {
type: Boolean,
format: value => value,
},
});
t.deepEqual(mixin.props, {
deepTest: {
type: Boolean,
},
});
});
test('defines local object correctly', (t) => {
const component = new Vue(propsToLocal({}, {
localName: 'myLocalData',
}));
t.true(has(component.$data, ['myLocalData']), 'Specified local data does not exist.');
});
test('uses "local" name for local object by default', (t) => {
const component = new Vue(propsToLocal({}));
t.true(has(component.$data, ['local']), 'Local data does not exist.');
});
test('formats local data during initialization', (t) => {
const component = new Vue(propsToLocal({
testValue: {
default: 'my value',
format: value => startCase(value),
},
}));
t.is(component.$data.local.testValue, 'My Value');
});
test.todo('updates local data on prop change');
test.todo('formats local data on prop change');
test.todo('watches props deeply');