From e9d251919522f9fb94b1818d90fc198211c72902 Mon Sep 17 00:00:00 2001 From: Abigail Alexander Date: Wed, 21 Aug 2024 13:30:33 +0100 Subject: [PATCH] Update snapshot tests --- .../Symbol/__snapshots__/symbol.test.tsx.snap | 23 +++-------- src/ui/widgets/Symbol/symbol.test.tsx | 40 +++++++++++++++---- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/ui/widgets/Symbol/__snapshots__/symbol.test.tsx.snap b/src/ui/widgets/Symbol/__snapshots__/symbol.test.tsx.snap index 8cc1e26..d2a6524 100644 --- a/src/ui/widgets/Symbol/__snapshots__/symbol.test.tsx.snap +++ b/src/ui/widgets/Symbol/__snapshots__/symbol.test.tsx.snap @@ -1,52 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` from .bob file use arrayIndex to find index if value is an array 1`] = ` +exports[` from .bob file matches snapshot (using fallback symbol) 1`] = `
`; -exports[` from .bob file use fallbackSymbol if index out of range or no symbol provided 1`] = ` +exports[` from .bob file matches snapshot (with index) 1`] = `
`; -exports[` from .bob file use initialIndex if no props value provided 1`] = ` +exports[` from .bob file matches snapshot (without index) 1`] = `
-
- - - 2 - - -
`; diff --git a/src/ui/widgets/Symbol/symbol.test.tsx b/src/ui/widgets/Symbol/symbol.test.tsx index faa2297..5351427 100644 --- a/src/ui/widgets/Symbol/symbol.test.tsx +++ b/src/ui/widgets/Symbol/symbol.test.tsx @@ -74,28 +74,54 @@ describe(" from .bob file", (): void => { symbols: ["img 1.gif", "img 2.png", "img 3.svg"], value: undefined }; + + render(); + + expect(screen.getByText("2")).toBeInTheDocument(); + }); + + test("use arrayIndex to find index if value is an array", (): void => { + const symbolProps = { + arrayIndex: 0, + showIndex: true, + symbols: ["img 1.gif", "img 2.png", "img 3.svg"], + value: arrayValue + }; + render(); + + expect(screen.getByText("2")).toBeInTheDocument(); + }); + + test("matches snapshot (without index)", (): void => { + const symbolProps = { + symbols: ["img 1.gif"], + value: new DType({ stringValue: "0" }) + }; + const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); - test("use fallbackSymbol if index out of range or no symbol provided", (): void => { + + test("matches snapshot (with index)", (): void => { const symbolProps = { - symbols: ["img 1.gif"], - value: new DType({ doubleValue: 1 }) + symbols: ["img 1.gif", "img 2.png", "img 3.svg"], + value: new DType({ stringValue: "2" }) }; + const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); - test("use arrayIndex to find index if value is an array", (): void => { + + test("matches snapshot (using fallback symbol)", (): void => { const symbolProps = { - arrayIndex: 0, - symbols: ["img 1.gif", "img 2.png", "img 3.svg"], - value: arrayValue + symbols: ["img 1.gif"], + value: new DType({ doubleValue: 1 }) }; const { asFragment } = render(