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

test(goals): added CardGoalTest

parent 9a3bab36
No related branches found
No related tags found
3 merge requests!66Final merge,!30Feat/10 finalize goals,!4Pipeline fix
Pipeline #279614 passed
import { describe, expect, it } from 'vitest'
import { mount } from '@vue/test-utils'
import CardGoal from '../CardGoal.vue'
import type { Goal } from '../../types/goal'
describe('CardGoal', () => {
let incompleteWrapper: any
let completeWrapper: any
const incompleteGoal: Goal = {
id: 1,
title: 'Test title',
saved: 100,
target: 1000,
description: 'Test description',
due: '2022-01-01T00:00:00Z',
createdOn: '2021-01-01T00:00:00Z',
completion: 10
}
const completeGoal: Goal = {
id: 1,
title: 'Test title',
saved: 100,
target: 1000,
description: 'Test description',
due: '2022-01-01T00:00:00Z',
createdOn: '2021-01-01T00:00:00Z',
completion: 10,
completedOn: '2022-01-01T00:00:00Z'
}
const mountIncompletedWrapper = async () => {
incompleteWrapper = mount(CardGoal, {
propsData: {
goalInstance: incompleteGoal
}
})
await incompleteWrapper.vm.$nextTick()
}
const mountCompleteWrapper = async () => {
completeWrapper = mount(CardGoal, {
propsData: {
goalInstance: completeGoal
}
})
await completeWrapper.vm.$nextTick()
}
it('renders correctly', () => {
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', () => {
mountIncompletedWrapper()
expect(incompleteWrapper.vm.isCompleted).toBe(false)
})
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