From c55c3b6fbdfb080c3f08b450dcd0ac8a3c004790 Mon Sep 17 00:00:00 2001 From: Alf Eaton <eaton.alf@gmail.com> Date: Thu, 7 Sep 2017 11:00:50 +0100 Subject: [PATCH] Update tests --- package.json | 2 +- test/AppBar.test.js | 2 +- test/Radio.test.js | 6 ++-- test/__snapshots__/AppBar.test.js.snap | 35 ++++++++++++++++-- test/__snapshots__/Menu.test.js.snap | 7 ++-- test/__snapshots__/Radio.test.js.snap | 14 ++++++-- test/__snapshots__/RadioGroup.test.js.snap | 42 ++++++++++++++++++---- test/__snapshots__/YesOrNo.test.js.snap | 28 ++++++++++++--- 8 files changed, 115 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 3217668c0..1f28697d3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "jest": { "moduleNameMapper": { - "\\.css$": "<rootDir>/test/setup/styleMock.js" + "\\.s?css$": "<rootDir>/test/setup/styleMock.js" }, "transform": { "\\.js$": "<rootDir>/test/config/transform.js" diff --git a/test/AppBar.test.js b/test/AppBar.test.js index b0cc4289d..cefb04773 100644 --- a/test/AppBar.test.js +++ b/test/AppBar.test.js @@ -80,7 +80,7 @@ describe('AppBar', () => { expect(rightArea.children()).toHaveLength(2) const userName = rightArea.childAt(0) - expect(userName.text()).toBe(props.userName) + expect(userName.text()).toBe("<Icon />some name") }) test('Should display the login link if no username is given', () => { diff --git a/test/Radio.test.js b/test/Radio.test.js index a548f014a..ceae22df2 100644 --- a/test/Radio.test.js +++ b/test/Radio.test.js @@ -30,9 +30,9 @@ describe('Radio', () => { expect(input.is('input')).toBeTruthy() expect(input.children()).toHaveLength(0) - const labelText = wrapper.childAt(1) - expect(labelText.text()).toBe(props.label) - expect(labelText.children()).toHaveLength(0) + const labelSpan = wrapper.childAt(1) + expect(labelSpan.text()).toBe(props.label) + expect(labelSpan.children()).toHaveLength(1) }) test('Input gets the correct props', () => { diff --git a/test/__snapshots__/AppBar.test.js.snap b/test/__snapshots__/AppBar.test.js.snap index 3ea9dd76f..456909a19 100644 --- a/test/__snapshots__/AppBar.test.js.snap +++ b/test/__snapshots__/AppBar.test.js.snap @@ -5,7 +5,7 @@ exports[`AppBar Snapshot 1`] = ` className={undefined} > <a - className={undefined} + className="" onClick={[Function]} style={Object {}} > @@ -15,7 +15,38 @@ exports[`AppBar Snapshot 1`] = ` <span className={undefined} > - some name + <span> + <svg + height={16} + viewBox="0 0 24 24" + width={16} + xmlns="http://www.w3.org/2000/svg" + > + <path + d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" + fill="none" + stroke="black" + strokeLinecap="round" + strokeLinejoin="round" + strokeWidth="2" + /> + <circle + cx="12" + cy="7" + fill="none" + r="4" + stroke="black" + strokeLinecap="round" + strokeLinejoin="round" + strokeWidth="2" + /> + </svg> + </span> + <span + className={undefined} + > + some name + </span> </span> <a className="" diff --git a/test/__snapshots__/Menu.test.js.snap b/test/__snapshots__/Menu.test.js.snap index 1f56dbdc0..0d6d7d321 100644 --- a/test/__snapshots__/Menu.test.js.snap +++ b/test/__snapshots__/Menu.test.js.snap @@ -2,12 +2,15 @@ exports[`Menu Snapshot 1`] = ` <div - className={undefined} + className="" > - <div> + <div + className={undefined} + > <button className={undefined} onClick={[Function]} + type="button" > <span> Foo diff --git a/test/__snapshots__/Radio.test.js.snap b/test/__snapshots__/Radio.test.js.snap index f93d4bcae..22221e98a 100644 --- a/test/__snapshots__/Radio.test.js.snap +++ b/test/__snapshots__/Radio.test.js.snap @@ -2,16 +2,26 @@ exports[`Radio Snapshot 1`] = ` <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={undefined} required={true} type="radio" value="TestValue" /> - TestLabel + <span + className={undefined} + > + TestLabel + </span> </label> `; diff --git a/test/__snapshots__/RadioGroup.test.js.snap b/test/__snapshots__/RadioGroup.test.js.snap index edbf58540..7060ef82c 100644 --- a/test/__snapshots__/RadioGroup.test.js.snap +++ b/test/__snapshots__/RadioGroup.test.js.snap @@ -3,43 +3,73 @@ exports[`Radio Group Snapshot 1`] = ` <div> <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={[Function]} required={true} type="radio" value="yes" /> - Yes + <span + className={undefined} + > + Yes + </span> </label> <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={[Function]} required={true} type="radio" value="no" /> - No + <span + className={undefined} + > + No + </span> </label> <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={[Function]} required={true} type="radio" value="maybe" /> - Maybe + <span + className={undefined} + > + Maybe + </span> </label> </div> `; diff --git a/test/__snapshots__/YesOrNo.test.js.snap b/test/__snapshots__/YesOrNo.test.js.snap index bce7baa1a..11ea90396 100644 --- a/test/__snapshots__/YesOrNo.test.js.snap +++ b/test/__snapshots__/YesOrNo.test.js.snap @@ -3,30 +3,50 @@ exports[`Yes or No Snapshot 1`] = ` <div> <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={[Function]} required={undefined} type="radio" value="yes" /> - Yes + <span + className={undefined} + > + Yes + </span> </label> <label - className={undefined} + className="" + style={ + Object { + "color": undefined, + } + } > <input checked={false} className={undefined} name="TestName" + onChange={[Function]} required={undefined} type="radio" value="no" /> - No + <span + className={undefined} + > + No + </span> </label> </div> `; -- GitLab