diff --git a/packages/portal/src/components/content/ContentSection.vue b/packages/portal/src/components/content/ContentSection.vue index e0c7079662..64d68d025f 100644 --- a/packages/portal/src/components/content/ContentSection.vue +++ b/packages/portal/src/components/content/ContentSection.vue @@ -68,7 +68,7 @@ diff --git a/packages/portal/src/mixins/contentful.js b/packages/portal/src/mixins/contentful.js deleted file mode 100644 index f060e1252b..0000000000 --- a/packages/portal/src/mixins/contentful.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - methods: { - contentfulEntryHasContentType(entry, contentType) { - return entry && (entry['__typename'] === contentType); - } - } -}; diff --git a/packages/portal/src/utils/contentful/entryHasContentType.js b/packages/portal/src/utils/contentful/entryHasContentType.js new file mode 100644 index 0000000000..60fb2c7011 --- /dev/null +++ b/packages/portal/src/utils/contentful/entryHasContentType.js @@ -0,0 +1,3 @@ +export default (entry, contentType) => { + return entry && (entry['__typename'] === contentType); +}; diff --git a/packages/portal/tests/unit/mixins/contentful.spec.js b/packages/portal/tests/unit/mixins/contentful.spec.js deleted file mode 100644 index 85fb81a677..0000000000 --- a/packages/portal/tests/unit/mixins/contentful.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; - -import mixin from '@/mixins/contentful'; - -const component = { - template: '
', - mixins: [mixin] -}; - -const factory = ({ mocks = {} } = {}) => shallowMount(component, { - localVue: createLocalVue(), - mocks: { - ...mocks - } -}); - -describe('mixins/contentful', () => { - describe('methods', () => { - describe('contentfulEntryHasContentType', () => { - it('is true when `__typename` property matches', () => { - const wrapper = factory(); - - const contentfulEntryHasContentType = wrapper.vm.contentfulEntryHasContentType( - { '__typename': 'blogPosting' }, 'blogPosting' - ); - - expect(contentfulEntryHasContentType).toBe(true); - }); - - it('is false when `__typename` property does not match', () => { - const wrapper = factory(); - - const contentfulEntryHasContentType = wrapper.vm.contentfulEntryHasContentType( - { '__typename': 'landingPage' }, 'blogPosting' - ); - - expect(contentfulEntryHasContentType).toBe(false); - }); - }); - }); -}); diff --git a/packages/portal/tests/unit/utils/contentful/entryHasContentType.spec.js b/packages/portal/tests/unit/utils/contentful/entryHasContentType.spec.js new file mode 100644 index 0000000000..9bba8697a8 --- /dev/null +++ b/packages/portal/tests/unit/utils/contentful/entryHasContentType.spec.js @@ -0,0 +1,21 @@ +import contentfulEntryHasContentType from '@/utils/contentful/entryHasContentType.js'; + +describe('utils/contentful/entryHasContentType', () => { + describe('contentfulEntryHasContentType', () => { + it('is true when `__typename` property matches', () => { + const hasType = contentfulEntryHasContentType( + { '__typename': 'blogPosting' }, 'blogPosting' + ); + + expect(hasType).toBe(true); + }); + + it('is false when `__typename` property does not match', () => { + const hasType = contentfulEntryHasContentType( + { '__typename': 'landingPage' }, 'blogPosting' + ); + + expect(hasType).toBe(false); + }); + }); +});