Skip to content
Snippets Groups Projects
Commit edf4345c authored by Trygve Jørgensen's avatar Trygve Jørgensen
Browse files

fix: removed test error

parent c94286e1
No related branches found
No related tags found
3 merge requests!66Final merge,!28Added challenge tests,!4Pipeline fix
Pipeline #279303 passed
import { beforeEach, describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vitest'
import { mount } from '@vue/test-utils'
import CardChallenge from '../CardChallenge.vue'
import type { Challenge } from '../../types/challenge'
describe('CardChallenge', () => {
let wrapper: any
let incompleteWrapper: any
let completeWrapper: any
const incompleteChallenge: Challenge = {
id: 1,
......@@ -33,33 +34,38 @@ describe('CardChallenge', () => {
completedOn: '2022-01-01T00:00:00Z'
}
beforeEach(async () => {
wrapper = mount(CardChallenge, {
const mountIncompletedWrapper = async () => {
incompleteWrapper = mount(CardChallenge, {
propsData: {
challengeInstance: incompleteChallenge
}
})
await wrapper.vm.$nextTick()
})
await incompleteWrapper.vm.$nextTick()
}
const mountCompleteWrapper = async () => {
completeWrapper = mount(CardChallenge, {
propsData: {
challengeInstance: completeChallenge
}
})
await completeWrapper.vm.$nextTick()
}
it('renders correctly', () => {
expect(wrapper.text()).toContain('Test title')
expect(wrapper.text()).toContain('100kr / 1000kr')
expect(wrapper.text()).toContain('2022-01-01 00:00')
mountIncompletedWrapper()
expect(incompleteWrapper.text()).toContain('Test title')
expect(incompleteWrapper.text()).toContain('100kr / 1000kr')
expect(incompleteWrapper.text()).toContain('2022-01-01 00:00')
})
it('sets isCompleted to false', () => {
expect(wrapper.vm.isCompleted).toBe(false)
mountIncompletedWrapper()
expect(incompleteWrapper.vm.isCompleted).toBe(false)
})
it('sets isCompleted to true', async () => {
let completedWrapper = mount(CardChallenge, {
propsData: {
challengeInstance: completeChallenge
}
})
await completedWrapper.vm.$nextTick()
expect(completedWrapper.vm.isCompleted).toBe(true)
it('sets isCompleted to true', () => {
mountCompleteWrapper()
expect(completeWrapper.vm.isCompleted).toBe(true)
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment