github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/ui/dashboard/src/components/dashboards/check/common/index.test.js (about) 1 import { findDimension } from "./index"; 2 3 test("findDimension with undefined dimensions and key returns undefined", () => { 4 expect(findDimension(undefined, undefined)).toBe(undefined); 5 }); 6 7 test("findDimension with undefined dimensions returns undefined", () => { 8 expect(findDimension(undefined, "some_dimension")).toBe(undefined); 9 }); 10 11 test("findDimension with undefined key returns undefined", () => { 12 expect(findDimension([], undefined)).toBe(undefined); 13 }); 14 15 test("findDimension with missing key returns undefined", () => { 16 expect( 17 findDimension([{ key: "region", value: "us-east-1" }], "account_id") 18 ).toBe(undefined); 19 }); 20 21 test("findDimension with present key returns dimension", () => { 22 const dimensions = [ 23 { key: "account_id", value: "123456789012" }, 24 { key: "region", value: "us-east-1" }, 25 ]; 26 expect(findDimension(dimensions, "region")).toBe(dimensions[1]); 27 });