From 5c1242b999a539ade8951676d55b0799aa0d5aea Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 19 Dec 2019 13:07:07 +0530 Subject: [PATCH] reduce CounterIcon tests to only test logic --- .../generic/CounterIcon/CounterIcon.spec.js | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/webapp/components/_new/generic/CounterIcon/CounterIcon.spec.js b/webapp/components/_new/generic/CounterIcon/CounterIcon.spec.js index 01d753c9d..49be22bde 100644 --- a/webapp/components/_new/generic/CounterIcon/CounterIcon.spec.js +++ b/webapp/components/_new/generic/CounterIcon/CounterIcon.spec.js @@ -5,33 +5,41 @@ import BaseIcon from '../BaseIcon/BaseIcon' const localVue = global.localVue describe('CounterIcon.vue', () => { - let propsData, wrapper, tag + let propsData, wrapper, count const Wrapper = () => { return mount(CounterIcon, { propsData, localVue }) } - describe('given a valid icon name and count', () => { + describe('given a valid icon name and count below 100', () => { beforeEach(() => { - propsData = { icon: 'comments', count: 1 } + propsData = { icon: 'comments', count: 42 } wrapper = Wrapper() - tag = wrapper.find('.ds-tag') + count = wrapper.find('.count') }) - it('renders BaseIcon', () => { + it('renders the icon', () => { expect(wrapper.find(BaseIcon).exists()).toBe(true) }) it('renders the count', () => { - expect(tag.text()).toEqual('1') + expect(count.text()).toEqual('42') + }) + }) + + describe('given a valid icon name and count above 100', () => { + beforeEach(() => { + propsData = { icon: 'comments', count: 750 } + wrapper = Wrapper() + count = wrapper.find('.count') }) - it('uses a round tag', () => { - expect(tag.classes()).toContain('ds-tag-round') + it('renders the icon', () => { + expect(wrapper.find(BaseIcon).exists()).toBe(true) }) - it('uses a primary button', () => { - expect(tag.classes()).toContain('ds-tag-primary') + it('renders the capped count with a plus', () => { + expect(count.text()).toEqual('99+') }) }) })