Skip to content

Commit

Permalink
test: check the default message if no annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
bathienle committed Aug 29, 2024
1 parent f68cd88 commit 20d852c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/units/components/annotations/similar-annotation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('SimilarAnnotation.vue', () => {
jest.clearAllMocks();
});

it('should render correctly', () => {
it('should render the component correctly', () => {
expect(wrapper.findComponent(VueDraggableResizable).exists()).toBe(true);
expect(wrapper.find('.similar-annotations-playground').exists()).toBe(true);
expect(wrapper.find('h1').text()).toBe('similar-annotations');
Expand All @@ -129,6 +129,24 @@ describe('SimilarAnnotation.vue', () => {
const distances = wrapper.findAll('.annotation-data div');
expect(distances.at(0).text()).toBe('80.00%');
expect(distances.at(1).text()).toBe('70.00%');

const paragraphs = wrapper.findAll('p');
expect(paragraphs.length).toBe(0);
});

it('should render the default message if no annotations', async () => {
wrapper.setData({
annotations: []
});

await wrapper.vm.$nextTick();

expect(wrapper.find('p').text()).toBe('no-similar-annotations-found');
expect(wrapper.findAllComponents(AnnotationPreview).length).toBe(0);
expect(wrapper.findAll('.annotation-data div').length).toBe(0);

expect(wrapper.vm.annotations).toEqual([]);
expect(wrapper.vm.loading).toEqual(false);
});

it('should fetch annotations on created hook and updates state', async () => {
Expand Down

0 comments on commit 20d852c

Please sign in to comment.