From 20d852cef33deec11c5a0aa39d1136094608f77a Mon Sep 17 00:00:00 2001 From: Ba Thien Le Date: Thu, 29 Aug 2024 13:43:49 +0200 Subject: [PATCH] test: check the default message if no annotations --- .../annotations/similar-annotation.test.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/units/components/annotations/similar-annotation.test.js b/tests/units/components/annotations/similar-annotation.test.js index c49887ce..606efcd7 100644 --- a/tests/units/components/annotations/similar-annotation.test.js +++ b/tests/units/components/annotations/similar-annotation.test.js @@ -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'); @@ -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 () => {