github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/ccl/src/views/clusterviz/components/instructionsBox/instructionsBox.spec.ts (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Licensed as a CockroachDB Enterprise file under the Cockroach Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt 8 import { assert } from "chai"; 9 10 import { showInstructionsBox } from "src/views/clusterviz/components/instructionsBox"; 11 import { LocalityTier } from "src/redux/localities"; 12 13 describe("InstructionsBox component", () => { 14 15 describe("showInstructionsBox", () => { 16 17 interface TestCase { 18 showMap: boolean; 19 tiers: LocalityTier[]; 20 expected: boolean; 21 desc: string; 22 } 23 24 const cases: TestCase[] = [ 25 { 26 desc: "showing map, at top level", 27 showMap: true, 28 tiers: [], 29 expected: false, 30 }, 31 { 32 desc: "showing map, down a level", 33 showMap: true, 34 tiers: [{ key: "foo", value: "bar" }], 35 expected: false, 36 }, 37 { 38 desc: "not showing map, at top level", 39 showMap: false, 40 tiers: [], 41 expected: true, 42 }, 43 { 44 desc: "not showing map, down a level", 45 showMap: false, 46 tiers: [{ key: "foo", value: "bar" }], 47 expected: false, 48 }, 49 ]; 50 51 cases.forEach((testCase) => { 52 it(`returns ${testCase.expected} for case "${testCase.desc}"`, () => { 53 assert.equal(showInstructionsBox(testCase.showMap, testCase.tiers), testCase.expected); 54 }); 55 }); 56 57 }); 58 59 });