Created
November 8, 2019 15:29
-
-
Save harrybeckwith/dc19c23716bf8651f1bf5d3f566a735b to your computer and use it in GitHub Desktop.
Revisions
-
harrybeckwith created this gist
Nov 8, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ import Vuex from "vuex"; import { createLocalVue, shallowMount } from "@vue/test-utils"; import chai, { expect } from "chai"; import sinon from "sinon"; import sinonChai from "sinon-chai"; import Modal from "@/ui/Modal"; import BaseButton from "@/ui/BaseButton"; chai.use(sinonChai); const localVue = createLocalVue(); localVue.use(Vuex); localVue.component("BaseButton", BaseButton); describe("Modal", () => { let store; const getters = { isModalOpen: () => true, activeModalName: () => "baz" }; const actions = { TOGGLE_MODAL: () => true }; let component; const mockMethod = sinon.spy(); beforeEach(() => { store = new Vuex.Store({ getters, actions }); component = shallowMount(Modal, { store, localVue, }); }); describe("can close when", () => { it("clicking 'x'", () => { component.setMethods({ TOGGLE_MODAL: mockMethod }); component.find(".modal-close-btn").trigger("click"); expect(mockMethod).to.have.been.called.calledWith({ isOpen: false, name: null }); }); }); });