diff --git a/cypress/integration/counter-vuex-spec.js b/cypress/integration/counter-vuex-spec.js index 2657063..7be15d7 100644 --- a/cypress/integration/counter-vuex-spec.js +++ b/cypress/integration/counter-vuex-spec.js @@ -2,11 +2,13 @@ // https://github.com/vuejs/vuex/tree/dev/examples/counter import Counter from '../../components/Counter.vue' import store from '../../components/store' -const mountVue = require('../..') +import Vuex from 'vuex' +import mountVue from '../..' /* eslint-env mocha */ describe('Vuex Counter', () => { - const extensions = { + const extensions = { + plugins: [Vuex], components: { counter: Counter }, @@ -14,7 +16,37 @@ describe('Vuex Counter', () => { const template = '' beforeEach(mountVue({template, store}, {extensions})) + const getCount = () => + Cypress.vue.$store.state.count + + const setCount = value => { + Cypress.vue.$store.state.count = value + } + it('starts with zero', () => { - cy.contains('button', '0') + cy.contains('0 times') + }) + + it('increments the counter on click of "+"', () => { + cy.contains('button', '+').click() + cy.contains('1 times') + }) + + it('decrements the counter on click of "-"', () => { + cy.contains('button', '-').click() + cy.contains('0 times') + }) + + it('increments the counter if count is odd', () => { + setCount(3) + cy.contains('odd') + cy.contains('button', 'Increment if odd').click() + cy.contains('even') + }) + + it('asynchronously increments counter', () => { + let count = getCount() + cy.contains('button', 'Increment async').click() + cy.contains(`${count++} times`) }) })