Sha256: 18b74384f6cf287284a48de076f8053ad89c6ef4e7455c9a2820465d637640f2

Contents?: true

Size: 1.97 KB

Versions: 20

Compression:

Stored size: 1.97 KB

Contents

import Vuex from 'vuex'
import { vi } from 'vitest'
import { createLocalVue } from '@vue/test-utils'
import defaultState from '@/store/default-state'
import buildActions from '@/store/actions'
import buildGetters from '@/store/getters'
import buildMutations from '@/store/mutations'
import MockedServices from '@/spec/__mocks__/services'
import { page, normalizedPage, pageSections } from '@/spec/__mocks__/page'
import {
  simpleContentSection,
  normalizedSimpleContentSection,
} from '@/spec/__mocks__/section'
import { site } from '@/spec/__mocks__/site'
import { theme } from '@/spec/__mocks__/theme'

const localVue = createLocalVue()
localVue.use(Vuex)

describe('Section Actions', () => {
  let mockedServices = null
  let store = null

  beforeEach(() => {
    mockedServices = { ...MockedServices }
    store = new Vuex.Store({
      state: {
        ...defaultState,
        theme: { ...theme },
        site,
      },
      actions: buildActions(mockedServices),
      getters: buildGetters(mockedServices),
      mutations: buildMutations(mockedServices),
    })
  })

  describe('#addSection', () => {
    it('marks the new section as touched', async () => {
      mockedServices.section.build = vi.fn(() => simpleContentSection)
      mockedServices.page.normalize = vi.fn(() => normalizedPage)
      mockedServices.page.denormalize = vi.fn(() => page)
      mockedServices.section.normalize = vi.fn(
        () => normalizedSimpleContentSection,
      )
      store.commit('SET_PAGE', page)
      await store.dispatch('addSection', {
        sectionDefinition: theme.sections[0],
        insertAt: 'bottom',
      })
      expect(store.state.touchedSections).toStrictEqual(['NEW-CONTENT-1'])
    })
  })

  describe('#updateSectionContent', () => {
    it('marks the modified section as touched', async () => {
      store.commit('SET_SECTION', pageSections[0])
      await store.dispatch('updateSectionContent', {})
      expect(store.state.touchedSections).toStrictEqual(['GrYZW-VP'])
    })
  })
})

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.7.2 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.7.1 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.7.0 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.6.1 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.6.0 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.5.1 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.4.0 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.3.0 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.2.2 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.2.1 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.2.0 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.7 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.6 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.5 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.4 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.3 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.2 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.1 app/frontend/editor/store/actions/__tests__/section.spec.js
maglevcms-1.1.0 app/frontend/editor/store/actions/__tests__/section.spec.js