@@ -0,0 +1,2719 @@
+/* global jest */%0A%0Aimport Vue from 'vue'%0Aimport Vuex from 'vuex'%0Aimport %7B shallow %7D from 'vue-test-utils'%0Aimport ContentTypeEdit from '@/components/ContentTypeEdit'%0A%0AVue.use(Vuex)%0A%0Adescribe('ContentTypeEdit', () =%3E %7B%0A  let wrapper%0A  let store%0A  let actions%0A  let getters%0A  let $route%0A%0A  beforeEach(() =%3E %7B%0A    $route = %7B%0A      path: '/',%0A      hash: '',%0A      params: %7B%0A        contentTypeId: 'success'%0A      %7D,%0A      query: %7B %7D%0A    %7D%0A%0A    actions = %7B%0A      saveContentType: jest.fn()%0A    %7D%0A%0A    getters = %7B%0A      getContentTypes: () =%3E %7B%0A        return %7B%0A          success: %7B%0A            controls: %5B%0A              %7Bname: '1'%7D%0A            %5D%0A          %7D,%0A          failure: %7B%0A            controls: %5B%0A              %7B name: '1' %7D,%0A              %7B name: '1' %7D%0A            %5D%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A%0A    store = new Vuex.Store(%7B%0A      getters,%0A      actions%0A    %7D)%0A  %7D)%0A%0A  test('is a Vue component', () =%3E %7B%0A    wrapper = shallow(ContentTypeEdit, %7B%0A      store,%0A      mocks: %7B%0A        $route%0A      %7D%0A    %7D)%0A%0A    expect(wrapper.isVueInstance()).toBeTruthy()%0A  %7D)%0A%0A  describe('should have an onSave method that', () =%3E %7B%0A    it('should call $store.dispatch if all names are unique', () =%3E %7B%0A      wrapper = shallow(ContentTypeEdit, %7B%0A        store,%0A        mocks: %7B%0A          $route%0A        %7D,%0A        attachToDocument: true%0A      %7D)%0A%0A      const ref = jest.fn()%0A      wrapper.setData(%7B%0A        firebase: %7B database: () =%3E (%7B ref %7D) %7D%0A      %7D)%0A      wrapper.vm.onSave()%0A      expect(ref).toHaveBeenCalledWith('contentType/success')%0A    %7D)%0A%0A    it('should error out if there are names that are not unique', () =%3E %7B%0A      $route.params.contentTypeId = 'failure'%0A%0A      wrapper = shallow(ContentTypeEdit, %7B%0A        store,%0A        mocks: %7B%0A          $route%0A        %7D,%0A        attachToDocument: true%0A      %7D)%0A%0A      const commit = jest.fn()%0A      wrapper.vm.$store.commit = commit%0A%0A      wrapper.setData(%7B%0A        firebase: %7B database: () =%3E (%7B ref: jest.fn() %7D) %7D%0A      %7D)%0A%0A      wrapper.vm.onSave()%0A%0A      expect(commit).toHaveBeenCalledWith('setError', 'Each control needs to have a unique name')%0A    %7D)%0A  %7D)%0A%0A  describe('should have an addControl method that', () =%3E %7B%0A    it('should add a control to controlsToAdd', () =%3E %7B%0A      $route.params.contentTypeId = 'success'%0A%0A      wrapper = shallow(ContentTypeEdit, %7B%0A        store,%0A        mocks: %7B%0A          $route%0A        %7D,%0A        attachToDocument: true%0A      %7D)%0A%0A      const event = %7B path: %5B %7B%7D, %7B dataset: %7B%0A        default: '',%0A        type: 'text'%0A      %7D%7D%5D%7D%0A%0A      wrapper.vm.addControl(event)%0A      expect(wrapper.vm.controlsToAdd%5B1%5D).toEqual(%7B%0A        name: 'Unnamed',%0A        type: 'text',%0A        defaultValue: '',%0A        id: 1%0A      %7D)%0A    %7D)%0A  %7D)%0A%7D)%0A

add tests for addContentType and onSave