Skip to content

Commit fdaaac6

Browse files
Improving tests
1 parent ad14a8a commit fdaaac6

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
name: "FakeFunctional",
3+
functional:true,
4+
props: {
5+
prop1: {
6+
type: String,
7+
default: "string"
8+
}
9+
},
10+
render(createElement, context) {
11+
return createElement('button', 'Click me');
12+
}
13+
}

tests/unit/vuedraggable.spec.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Sortable.mockImplementation(() => SortableFake);
1010
import draggable from "@/vuedraggable";
1111
import Vue from "vue";
1212
import Fake from "./helper/FakeComponent.js"
13+
import FakeFunctional from "./helper/FakeFunctionalComponent.js"
14+
1315

1416
let wrapper;
1517
let vm;
@@ -190,18 +192,28 @@ describe("draggable.vue when initialized with list", () => {
190192
expect(wrapper.html()).toEqual(initialRender);
191193
})
192194

193-
test.each([
195+
describe.each([
194196
"ul",
195197
"span",
196198
"div"
197199
])(
198-
"renders tag %s as root element",
200+
"considering a tag %s",
199201
(tag) => {
200-
wrapper = shallowMount(draggable, {
201-
propsData: { tag }
202+
beforeEach(() => {
203+
wrapper = shallowMount(draggable, {
204+
propsData: { tag }
205+
});
202206
});
203-
const expectedRegex = new RegExp(`^<${tag}>.*<\/${tag}>$`);
204-
expect(wrapper.html()).toMatch(expectedRegex);
207+
208+
it("renders tag as root element", () => {
209+
const expectedRegex = new RegExp(`^<${tag}>.*<\/${tag}>$`);
210+
expect(wrapper.html()).toMatch(expectedRegex);
211+
})
212+
213+
it("set noneFunctionalComponentMode to false ", () => {
214+
const { noneFunctionalComponentMode } = vm;
215+
expect(noneFunctionalComponentMode).toBe(false);
216+
})
205217
}
206218
)
207219

0 commit comments

Comments
 (0)