Skip to content
Snippets Groups Projects
Commit 702cf870 authored by Tini Tran's avatar Tini Tran
Browse files

build fix

parent 80f55331
No related branches found
No related tags found
1 merge request!59Resolve "test for economy components and create form components"
Pipeline #281035 passed
......@@ -29,8 +29,13 @@ describe('BaseInput', () => {
const newValue = 'New Value'
await input.setValue(newValue)
// Assert emitted event
expect(wrapper.emitted()['update:modelValue']).toBeTruthy()
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe(newValue)
const emittedEvents = wrapper.emitted()
expect(emittedEvents).toBeTruthy()
const updateModelValueEvents = emittedEvents['update:modelValue'] as any[]
expect(updateModelValueEvents).toBeTruthy()
const newValueEmitted = updateModelValueEvents[0][0]
expect(newValueEmitted).toBe(newValue)
})
})
......@@ -25,7 +25,13 @@ describe('BaseTextArea', () => {
const newValue = 'New Value'
await textarea.setValue(newValue)
expect(wrapper.emitted()['update:modelValue']).toBeTruthy()
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe(newValue)
const emittedEvents = wrapper.emitted()
expect(emittedEvents).toBeTruthy()
const updateModelValueEvents = emittedEvents['update:modelValue'] as any[]
expect(updateModelValueEvents).toBeTruthy()
const newValueEmitted = updateModelValueEvents[0][0]
expect(newValueEmitted).toBe(newValue)
})
})
......@@ -4,25 +4,27 @@ import ToggleButton from '@/components/economy/ToggleButton.vue'
describe('ToggleButton', () => {
it('toggles chart visibility when clicked', async () => {
const wrapper = mount(ToggleButton)
const wrapper = mount(ToggleButton) as any
expect(wrapper.vm.chartVisible).toBe(false)
await wrapper.find('input[type="checkbox"]').trigger('change')
expect(wrapper.vm.chartVisible).toBe(true)
})
it('emits toggle-chart event when clicked', async () => {
const wrapper = mount(ToggleButton)
const wrapper = mount(ToggleButton) as any
// Simulate clicking the toggle button
await wrapper.find('input[type="checkbox"]').trigger('change')
expect(wrapper.emitted('toggle-chart')).toBeTruthy()
const emittedEvents = wrapper.emitted()
expect(emittedEvents).toBeTruthy()
const toggleChartEmit = emittedEvents['toggle-chart'] as any[] // Type assertion to any[]
expect(toggleChartEmit).toBeTruthy()
expect(wrapper.vm.chartVisible).toBe(true)
await wrapper.find('input[type="checkbox"]').trigger('change')
expect(wrapper.emitted('toggle-chart')).toBeTruthy()
expect(wrapper.emitted('toggle-chart')[1][0]).toBe(false)
expect(toggleChartEmit[1][0]).toBe(false)
})
})
......@@ -20,16 +20,44 @@ describe('TransactionComponent', () => {
})
// title rendering
expect(wrapper.find('.component-title').text()).toContain(title)
const titleElement = wrapper.find('.component-title')
if (titleElement.exists()) {
expect(titleElement.text()).toContain(title)
} else {
throw new Error('Title element not found');
}
// date rendering
expect(wrapper.findAll('.component-right-field').at(0).text()).toContain(date)
// Find all component-right-field elements
const rightFieldElements = wrapper.findAll('.component-right-field')
// amount rendering
expect(wrapper.findAll('.component-right-field').at(1).text()).toContain(`${amount}kr`)
// Check if elements exist and have expected text content
if (rightFieldElements.length >= 3) {
// date rendering
const dateElement = rightFieldElements.at(0)
if (dateElement) {
expect(dateElement.text()).toContain(date)
} else {
throw new Error('Date element not found');
}
// amount rendering
const amountElement = rightFieldElements.at(1)
if (amountElement) {
expect(amountElement.text()).toContain(`${amount}kr`)
} else {
throw new Error('Amount element not found');
}
// category rendering
expect(wrapper.findAll('.component-right-field').at(2).text()).toContain(category)
// category rendering
const categoryElement = rightFieldElements.at(2)
if (categoryElement) {
expect(categoryElement.text()).toContain(category)
} else {
throw new Error('Category element not found');
}
} else {
throw new Error('Expected elements not found');
}
})
})
......@@ -18,7 +18,7 @@ describe('MilestoneButton', () => {
expect(wrapper.text()).toBe('Save')
// button color
const buttonElement = wrapper.find('.save-button').element
expect(buttonElement.style.backgroundColor).toBe(buttonColor)
const buttonElement = wrapper.find('.save-button').element as HTMLElement
expect(buttonElement.style?.backgroundColor).toBe(buttonColor)
})
})
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