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
// the action | |
[actionTypes.ACTION_SET_FAV_ELEM] (context, elemId) { | |
context.commit(mutationTypes.MUTATION_SET_FAV_ELEM, elemId) | |
} | |
// the test | |
it('should invoke mutation to set the favourite element', done => { | |
const elemId = 'AAAAAA' | |
testAction(actions[actionTypes.ACTION_SET_FAV_ELEM], elemId, {}, [ | |
{ type: mutationTypes.MUTATION_SET_FAV_ELEM, payload: elemId } |
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
// the mutation | |
[mutationTypes.MUTATION_SET_FAV_ELEM] (state, elemId) { | |
state.favElem = elemId | |
} | |
// the test | |
it('should set state.favElem', () => { | |
const state = { | |
favElem: '' | |
} |
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
// the getter | |
getElemsByCategory: state => (category) => { | |
return state.elems.filter((el, index, arr) => el.category === category) | |
} | |
// the test | |
it('should return the elements that have Cat1 as category', done => { | |
const expected = [ | |
{ | |
'id': '1', |
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
// the action | |
[actionTypes.ACTION_SET_FAV_ELEM] (context) { | |
return APIAdapter.services.fetchFavElem() | |
.then((response) => { | |
context.commit(mutationTypes.MUTATION_SET_FAV_ELEM, response) | |
resolve(true) | |
}).catch((error) => { | |
context.commit(mutationTypes.MUTATION_SET_FAV_ELEM, undefined) | |
reject(error) | |
}) |
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
<template> | |
<div></div> | |
</template> | |
<script> | |
export default { | |
// == Lifecycle | |
mounted () { | |
window.addEventListener('scroll', this.handleScroll) | |
}, |
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
describe('Basic component', () => { | |
describe('Lifecycle', () => { | |
it('Mounted', done => { | |
const handleScrollStub = sinon.stub(BasicComponent.methods, 'handleScroll') | |
const addEventStub = sinon.stub(window, 'addEventListener') | |
const wrapper = mount(BasicComponent) | |
expect(addEventStub).to.be.calledWith('scroll', wrapper.vm.handleScroll) |
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
<template> | |
<div></div> | |
</template> | |
<script type="text/javascript"> | |
export default { | |
... | |
data () { | |
return { | |
currentObjects: [], |
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
<template> | |
<div></div> | |
</template> | |
<script type="text/javascript"> | |
import { GET_OBJECTS } from 'services/constants/action-types' | |
export default { | |
... | |
data () { |
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
<template> | |
<div></div> | |
</template> | |
<script type="text/javascript"> | |
export default { | |
props: { | |
propId: { | |
type: Number, | |
required: true |
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
describe('Watcher component', () => { | |
let props | |
beforeEach(() => { | |
props = { | |
propId: 1 | |
} | |
}) | |
describe('Watcher', () => { |
OlderNewer