- Notifications
You must be signed in to change notification settings - Fork3
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
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
coderdiazaaaeb88
Configuration for .babelrc on testing
coderdiaze463eaa
Initial testing
coderdiazfc3db43
Added tests
coderdiaz13672a7
Added select for items by page
coderdiazcffe109
Added prop to set page sizes on tiny paginate
coderdiazc54d7da
Minor fixes to docs
coderdiaz60ddcf2
Moved file to __tests__
coderdiaz357222d
Added coverage to .gitignore
coderdiazd047f7c
Added classes to buttons prev and next; added validation for not avai…
coderdiaz44ec472
Added available languages array
coderdiaze215c37
Added more important tests
coderdiazfc97c18
0.2.0
coderdiaz38193ff
Fixed release on docs
coderdiazFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
9 changes: 8 additions & 1 deletion.babelrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,7 @@ | ||
node_modules/ | ||
dist/ | ||
public/ | ||
coverage/ | ||
npm-debug.log | ||
yarn-error.log | ||
108 changes: 108 additions & 0 deletions__tests__/TinyPagination.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff 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() | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.