Skip to content

Commit 3fb9bfb

Browse files
committed
Added tests
1 parent 6650833 commit 3fb9bfb

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

Diff for: tests/TinyPagination.spec.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import {mount} from 'vue-test-utils'
2+
import Vue from 'vue'
23
import TinyPagination from '../src/components/TinyPagination.vue'
3-
import { create } from 'domain';
4+
5+
const Constructor = Vue.extend(TinyPagination)
6+
const vm = new Constructor({
7+
propsData: {
8+
total: 100
9+
}
10+
}).$mount()
411

512
// Helper function to create a component
613
const createComponent = propsData => mount(TinyPagination, {propsData})
@@ -11,6 +18,10 @@ describe('TinyPagination.vue', () => {
1118
expect(typeof TinyPagination.created).toBe('function')
1219
})
1320

21+
it('should match the snapshot', () => {
22+
expect(vm.$el).toMatchSnapshot()
23+
})
24+
1425
describe('Properties', () => {
1526
it('when the component is created without page prop, Page 1 is the page by default', () => {
1627
cmp = createComponent({total: 300})
@@ -38,6 +49,17 @@ describe('TinyPagination.vue', () => {
3849
cmp = createComponent({total: 300, lang: 'fr'})
3950
expect(cmp.vm.translation.title).toBe('Page')
4051
})
52+
53+
it('when the show limit is not set, true is by default', () => {
54+
cmp = createComponent({ total: 100 })
55+
expect(cmp.vm.showLimit).toBe(true)
56+
})
57+
58+
it('when the showLimit is set, prop is same', () => {
59+
let showLimit = true
60+
cmp = createComponent({ total: 100, showLimit })
61+
expect(cmp.vm.showLimit).toBe(showLimit)
62+
})
4163
})
4264

4365
describe('Watchers', () => {

Diff for: tests/__snapshots__/TinyPagination.spec.js.snap

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`TinyPagination.vue should match the snapshot 1`] = `
4+
<div
5+
class="vue-tiny-pagination"
6+
>
7+
<ul
8+
class="tiny-pagination"
9+
>
10+
<li
11+
class="page-item disabled c-not-allowed"
12+
>
13+
<a
14+
class="btn-prev-page"
15+
href="#"
16+
>
17+
Previous
18+
</a>
19+
</li>
20+
21+
<li
22+
class="page-item"
23+
>
24+
<span>
25+
Page 1
26+
</span>
27+
</li>
28+
29+
<li
30+
class="page-item c-not-allowed"
31+
>
32+
<a
33+
class="btn-next-page"
34+
href="#"
35+
>
36+
Next
37+
</a>
38+
</li>
39+
40+
<li
41+
class="page-item"
42+
>
43+
<select
44+
class="tiny-form-select"
45+
>
46+
<option
47+
value="10"
48+
>
49+
10/Page
50+
</option>
51+
<option
52+
value="15"
53+
>
54+
15/Page
55+
</option>
56+
<option
57+
value="20"
58+
>
59+
20/Page
60+
</option>
61+
<option
62+
value="50"
63+
>
64+
50/Page
65+
</option>
66+
<option
67+
value="100"
68+
>
69+
100/Page
70+
</option>
71+
</select>
72+
</li>
73+
</ul>
74+
</div>
75+
`;

0 commit comments

Comments
 (0)