Skip to content

Commit 54efc2b

Browse files
Adding tests
1 parent 4014db6 commit 54efc2b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/unit/util/helper.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { camelize } from "@/util/helper";
2+
3+
4+
describe("camelize", () => {
5+
test.each([
6+
["MyProp", "MyProp"],
7+
["MyProp", "MyProp"],
8+
["kebab-case", "kebabCase"],
9+
["multi-hyphen-string", "multiHyphenString"],
10+
["drag-class", "dragClass"]
11+
])(
12+
"transfoem %s into %s",
13+
(value, expected) =>{
14+
const actual = camelize(value);
15+
expect(actual).toEqual(expected);
16+
}
17+
)
18+
});

tests/unit/vuedraggable.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Sortable from "sortablejs";
33
jest.genMockFromModule('sortablejs');
44
jest.mock('sortablejs');
55
const SortableFake = {
6+
destroy: jest.fn()
67
};
78
Sortable.mockImplementation(() => SortableFake);
89
import draggable from "@/vuedraggable";
@@ -26,6 +27,7 @@ function getEvent(name) {
2627
describe("draggable.vue when initialized with list", () => {
2728
beforeEach(() => {
2829
Sortable.mockClear();
30+
SortableFake.destroy.mockClear();
2931
items = ["a", "b", "c"];
3032
wrapper = shallowMount(draggable, {
3133
attachToDocument: true,
@@ -384,6 +386,16 @@ describe("draggable.vue when initialized with list", () => {
384386
})
385387
})
386388
});
389+
390+
it("does calls Sortable destroy when mounted",()=>{
391+
expect(SortableFake.destroy.mock.calls.length).toBe(0);
392+
});
393+
394+
it("calls Sortable destroy when destroyed",()=>{
395+
wrapper.destroy();
396+
expect(SortableFake.destroy).toHaveBeenCalled();
397+
expect(SortableFake.destroy.mock.calls.length).toBe(1);
398+
});
387399
});
388400

389401
describe("draggable.vue when initialized with value", () => {

0 commit comments

Comments
 (0)