mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
cc @Tirokk @ulfgebhardt @appinteractive This is a perfect example why I insist on writing tests. While debugging @Tirokk and I discovered several design flaws and plugins that depend on each other. The solution to all of this is not to use vue-filters plugin at all! Vue-filters depends on Vuex, i18n, vuex-i18n, nuxt-modules and so on. This is just bad, bad, bad code. Start writing tests. Now. We should start to refactor vue-filters and use components instead.
53 lines
925 B
JavaScript
53 lines
925 B
JavaScript
import { shallowMount, createLocalVue } from '@vue/test-utils'
|
|
import RelativeDateTime from './index.vue'
|
|
|
|
const localVue = createLocalVue()
|
|
|
|
describe('RelativeDateTime', () => {
|
|
let wrapper
|
|
let mocks
|
|
let locale
|
|
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$i18n: {
|
|
locale: () => locale
|
|
}
|
|
}
|
|
})
|
|
|
|
let Wrapper = () => {
|
|
return shallowMount(RelativeDateTime, {
|
|
mocks,
|
|
localVue,
|
|
propsData: {
|
|
dateTime: new Date()
|
|
}
|
|
})
|
|
}
|
|
|
|
it('renders', () => {
|
|
expect(Wrapper().is('span')).toBe(true)
|
|
})
|
|
|
|
describe("locale == 'en'", () => {
|
|
beforeEach(() => {
|
|
locale = 'en'
|
|
})
|
|
|
|
it('translates', () => {
|
|
expect(Wrapper().text()).toContain('today at')
|
|
})
|
|
})
|
|
|
|
describe("locale == 'de'", () => {
|
|
beforeEach(() => {
|
|
locale = 'de'
|
|
})
|
|
|
|
it('translates', () => {
|
|
expect(Wrapper().text()).toContain('heute um')
|
|
})
|
|
})
|
|
})
|