From 3a89ebafc8eac9150054559ce59d75a56edb328b Mon Sep 17 00:00:00 2001 From: andrico Date: Wed, 13 Nov 2019 09:13:12 +0000 Subject: [PATCH] add test for info icon --- src/components/__tests__/SkillTree.test.tsx | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/components/__tests__/SkillTree.test.tsx b/src/components/__tests__/SkillTree.test.tsx index 232dd71..11bcea1 100644 --- a/src/components/__tests__/SkillTree.test.tsx +++ b/src/components/__tests__/SkillTree.test.tsx @@ -75,6 +75,10 @@ const defaultStoreContents = { }; function renderComponent(props: Props) { + const modalRoot = document.createElement('div'); + modalRoot.setAttribute('id', 'modal-root'); + document.body.appendChild(modalRoot); + let selectedSkillCount: SkillCount; let resetSkills: VoidFunction; @@ -413,6 +417,27 @@ describe('SkillTree', () => { }); }); + describe('Description', () => { + it('should not display info icon if no description is passed through', () => { + const { queryByText } = renderComponent(defaultProps); + + expect(queryByText('ⓘ')).toBeNull(); + }); + + it('should display on hover', () => { + const props = { + ...defaultProps, + description: 'this is the description boys', + }; + + const { getByText } = renderComponent(props); + + const infoIcon = getByText('ⓘ'); + + expect(infoIcon).toBeTruthy(); + }); + }); + describe('resizing', () => { function fireResize(width: number) { // @ts-ignore