diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/portalMixin.js b/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/portalMixin.js deleted file mode 100644 index 8668707c5..000000000 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/portalMixin.js +++ /dev/null @@ -1,24 +0,0 @@ -import { mapGetters } from 'vuex'; -import { frontendURL } from 'dashboard/helper/URLHelper'; -import allLocales from 'shared/constants/locales.js'; -export default { - computed: { - ...mapGetters({ accountId: 'getCurrentAccountId' }), - portalSlug() { - return this.$route.params.portalSlug; - }, - locale() { - return this.$route.params.locale; - }, - }, - methods: { - articleUrl(id) { - return frontendURL( - `accounts/${this.accountId}/portals/${this.portalSlug}/${this.locale}/articles/${id}` - ); - }, - localeName(code) { - return allLocales[code]; - }, - }, -}; diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/specs/portalMixin.spec.js b/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/specs/portalMixin.spec.js deleted file mode 100644 index e43f4ce9b..000000000 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/mixins/specs/portalMixin.spec.js +++ /dev/null @@ -1,76 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; -import portalMixin from '../portalMixin'; -import Vuex from 'vuex'; -import VueRouter from 'vue-router'; -const localVue = createLocalVue(); -localVue.use(Vuex); -localVue.use(VueRouter); -import ListAllArticles from '../../pages/portals/ListAllPortals.vue'; - -const router = new VueRouter({ - routes: [ - { - path: ':portalSlug/:locale/articles', - name: 'list_all_locale_articles', - component: ListAllArticles, - }, - ], -}); - -describe('portalMixin', () => { - let getters; - let store; - let wrapper; - - beforeEach(() => { - getters = { - getCurrentAccountId: () => 1, - }; - const Component = { - render() {}, - title: 'TestComponent', - mixins: [portalMixin], - router, - }; - store = new Vuex.Store({ getters }); - wrapper = shallowMount(Component, { store, localVue }); - }); - - it('return account id', () => { - expect(wrapper.vm.accountId).toBe(1); - }); - - it('returns article url', () => { - router.push({ - name: 'list_all_locale_articles', - params: { portalSlug: 'fur-rent', locale: 'en' }, - }); - expect(wrapper.vm.articleUrl(1)).toBe( - '/app/accounts/1/portals/fur-rent/en/articles/1' - ); - }); - - it('returns portal locale', () => { - router.push({ - name: 'list_all_locale_articles', - params: { portalSlug: 'fur-rent', locale: 'es' }, - }); - expect(wrapper.vm.portalSlug).toBe('fur-rent'); - }); - - it('returns portal slug', () => { - router.push({ - name: 'list_all_locale_articles', - params: { portalSlug: 'campaign', locale: 'es' }, - }); - expect(wrapper.vm.portalSlug).toBe('campaign'); - }); - - it('returns locale name', () => { - router.push({ - name: 'list_all_locale_articles', - params: { portalSlug: 'fur-rent', locale: 'es' }, - }); - expect(wrapper.vm.localeName('es')).toBe('Spanish'); - }); -});