You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/unit/vuedraggable.spec.js
+61-3Lines changed: 61 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,64 @@ describe("draggable.vue when initialized with list", () => {
56
56
element=wrapper.element;
57
57
});
58
58
59
+
describe("when initialized with incorrect props",()=>{
60
+
const{ error }=console;
61
+
const{ warn }=console;
62
+
63
+
beforeEach(()=>{
64
+
console.error=jest.fn();
65
+
console.warn=jest.fn();
66
+
});
67
+
68
+
afterEach(()=>{
69
+
console.error=error;
70
+
console.warn=warn;
71
+
})
72
+
73
+
it("log an error when list and value are both not null",()=>{
74
+
wrapper=shallowMount(draggable,{
75
+
attachToDocument: true,
76
+
propsData: {
77
+
list: [],
78
+
value: []
79
+
},
80
+
slots: {
81
+
default: ""
82
+
}
83
+
});
84
+
expect(console.error).toBeCalledWith("Value and list props are mutually exclusive! Please set one or another.");
85
+
});
86
+
87
+
it("warns when options is used",()=>{
88
+
wrapper=shallowMount(draggable,{
89
+
attachToDocument: true,
90
+
propsData: {
91
+
options: {
92
+
group: "led zeppelin"
93
+
}
94
+
},
95
+
slots: {
96
+
default: ""
97
+
}
98
+
});
99
+
expect(console.warn).toBeCalledWith("Options props is deprecated, add sortable options directly as vue.draggable item, or use v-bind. See https://github.com/SortableJS/Vue.Draggable/blob/master/documentation/migrate.md#options-props");
100
+
});
101
+
102
+
it("warns when element is used",()=>{
103
+
wrapper=shallowMount(draggable,{
104
+
attachToDocument: true,
105
+
propsData: {
106
+
element: "li"
107
+
},
108
+
slots: {
109
+
default: ""
110
+
}
111
+
});
112
+
expect(console.warn).toBeCalledWith("Element props is deprecated please use tag props instead. See https://github.com/SortableJS/Vue.Draggable/blob/master/documentation/migrate.md#element-props");
113
+
});
114
+
115
+
});
116
+
59
117
it("instantiate without error",()=>{
60
118
expect(wrapper).not.toBeUndefined();
61
119
});
@@ -157,7 +215,7 @@ describe("draggable.vue when initialized with list", () => {
157
215
awaitVue.nextTick();
158
216
constcomputeIndexes=jest.fn();
159
217
wrapper.setMethods({ computeIndexes })
160
-
wrapper.setProps({list: ["c","d","e","f","g"]});
218
+
wrapper.setProps({list: ["c","d","e","f","g"]});
161
219
expect(computeIndexes).toHaveBeenCalled()
162
220
});
163
221
@@ -592,7 +650,7 @@ describe("draggable.vue when initialized with value", () => {
592
650
awaitVue.nextTick();
593
651
constcomputeIndexes=jest.fn();
594
652
wrapper.setMethods({ computeIndexes })
595
-
wrapper.setProps({value: ["c","d","e","f","g"]});
653
+
wrapper.setProps({value: ["c","d","e","f","g"]});
596
654
expect(computeIndexes).toHaveBeenCalled()
597
655
});
598
656
@@ -728,7 +786,7 @@ describe("draggable.vue when initialized with a transition group", () => {
0 commit comments