/* global describe, it */
import { expect } from 'chai'
import Vue from 'vue'
import Vuex from 'vuex'
import sinon from 'sinon'
import Home from 'renderer/components/Home.vue'

Vue.use(Vuex)

function getMockStore () {
  return {
    actions: { loadProtocol: sinon.spy() },
    state: {}
  }
}

const mockStore = getMockStore()

function getRenderedVm (Component, store) {
  const Ctor = Vue.extend(Component)
  const vm = new Ctor({store: new Vuex.Store(store)}).$mount()
  return vm
}

describe('Home.vue', (done) => {
  it('has 6 btn-homes', () => {
    let home = getRenderedVm(Home, mockStore)
    expect(home.$el.querySelectorAll('.btn-home').length).to.equal(6)
  })
})

@@ -242,20 +242,12 @@
 : %7B 
-loadProtocol
+home
 : si
@@ -261,23 +261,8 @@
 () %7D
-,%0A    state: %7B%7D
 %0A  %7D
@@ -297,16 +297,60 @@
 kStore()
+%0Aconst home = getRenderedVm(Home, mockStore)
 %0A%0Afuncti
@@ -555,16 +555,23 @@
 btn-home
+ classe
 s', () =
@@ -582,54 +582,8 @@
     
-let home = getRenderedVm(Home, mockStore)%0A    
 expe
@@ -630,16 +630,483 @@
 ).length
+).to.equal(6)%0A  %7D)%0A%0A  it('has each button send a home dispatch with the correct axis', () =%3E %7B%0A    let buttons = %5B%5D.slice.call(home.$el.querySelectorAll('.btn-home'))%0A    expect(mockStore.actions.home.called).to.be.false%0A    buttons.map((button, i) =%3E %7B%0A      button.click()%0A      let homeArgs = mockStore.actions.home.getCall(i).args.slice(-2)%5B0%5D%0A      expect(homeArgs.axis).to.equal(button.innerHTML.toLowerCase())%0A    %7D)%0A    expect(mockStore.actions.home.callCount
 ).to.equ

test button clicks calling actions