Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Next release#3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coderdiaz merged 14 commits intomasterfromnext
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
3f24f6e
Added dependencies for unit testing with jest
coderdiazFeb 12, 2018
aaaeb88
Configuration for .babelrc on testing
coderdiazFeb 12, 2018
e463eaa
Initial testing
coderdiazFeb 12, 2018
fc3db43
Added tests
coderdiazFeb 15, 2018
13672a7
Added select for items by page
coderdiazFeb 15, 2018
cffe109
Added prop to set page sizes on tiny paginate
coderdiazFeb 17, 2018
c54d7da
Minor fixes to docs
coderdiazFeb 17, 2018
60ddcf2
Moved file to __tests__
coderdiazFeb 19, 2018
357222d
Added coverage to .gitignore
coderdiazFeb 19, 2018
d047f7c
Added classes to buttons prev and next; added validation for not avai…
coderdiazFeb 19, 2018
44ec472
Added available languages array
coderdiazFeb 19, 2018
e215c37
Added more important tests
coderdiazFeb 19, 2018
fc97c18
0.2.0
coderdiazFeb 19, 2018
38193ff
Fixed release on docs
coderdiazFeb 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion.babelrc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,5 +2,12 @@
"presets": [
["env", { "modules": false }],
"stage-3"
]
],
"env": {
"test": {
"presets": [
["env", { "targets": { "node": 8 }}]
]
}
}
}
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
node_modules/
dist/
public/
coverage/
npm-debug.log
yarn-error.log

Expand Down
108 changes: 108 additions & 0 deletions__tests__/TinyPagination.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
import {mount} from 'vue-test-utils'
import TinyPagination from '../src/components/TinyPagination.vue'
import { create } from 'domain';

// Helper function to create a component
const createComponent = propsData => mount(TinyPagination, {propsData})

describe('TinyPagination.vue', () => {
let cmp
it('has a created hook', () => {
expect(typeof TinyPagination.created).toBe('function')
})

describe('Properties', () => {
it('when the component is created without page prop, Page 1 is the page by default', () => {
cmp = createComponent({total: 300})
expect(cmp.vm.page).toBe(1)
})

it('when the page property is set, the currentPage is equals', () => {
cmp = createComponent({total: 300, page: 2})
expect(cmp.vm.currentPage).toBe(2)
})

it('when the component is created, English is the language by default', () => {
cmp = createComponent({total: 300})
expect(cmp.vm.lang).toBe('en')
expect(cmp.vm.translation.title).toBe('Page')
})

it('when the lang prop is set to spanish, the component is translated', () => {
cmp = createComponent({total: 300, lang: 'es'})
expect(cmp.vm.lang).toBe('es')
expect(cmp.vm.translation.title).toBe('Página')
})

it('when the lang prop is set to not available language, English is the language by default', () => {
cmp = createComponent({total: 300, lang: 'fr'})
expect(cmp.vm.translation.title).toBe('Page')
})
})

describe('Watchers', () => {

it('currentPage watcher is called with the new value', () => {
let spy = jest.fn()
cmp = createComponent({total: 100})
cmp.vm.$watch('currentPage', spy)

cmp.setData({currentPage: 3})
cmp.update()

expect(spy).toBeCalled()
})

it('currentLimit watcher is called with the new value', () => {
let spy = jest.fn()
cmp = createComponent({total: 200})
cmp.vm.$watch('currentLimit', spy)

cmp.setData({currentLimit: 20})
cmp.update()

expect(spy).toBeCalled()
})

it('when the currentPage watcher is called, the tiny:change-page event is emitted', () => {
let stub = jest.fn()
cmp = createComponent({total: 100})
cmp.vm.$on('tiny:change-page', stub)

cmp.setData({currentPage: 3})
expect(stub).toBeCalledWith({page: 3})
})

it('when the currentLimit watcher is called, the tiny:change-limit event is emitted', () => {
let stub = jest.fn()
cmp = createComponent({total: 100})
cmp.vm.$on('tiny:change-limit', stub)

cmp.setData({currentLimit: 20})
expect(stub).toBeCalledWith({limit: 20})
})
})

describe('Events', () => {
beforeEach(() => {
cmp = createComponent({total: 20})
})

it('calls nextPage when click on next button', () => {
cmp.vm.nextPage = jest.fn()
cmp.update()

const el = cmp.find('.btn-next-page').trigger('click')
expect(cmp.vm.nextPage).toBeCalled()
})

it('call lastPage when click on prev button', () => {
cmp.vm.lastPage = jest.fn()
cmp.update()

const el = cmp.find('.btn-prev-page').trigger('click')
expect(cmp.vm.lastPage).toBeCalled()
})
})

})
Loading

[8]ページ先頭

©2009-2025 Movatter.jp