Robert Schäfer a7354a054e Fix test, remove vue-filter relativeDateTime
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.
2019-04-10 18:46:13 +02:00

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')
})
})
})