github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/redux/uiDataSelectors.spec.ts (about) 1 // Copyright 2020 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import { assert } from "chai"; 12 import { dismissReleaseNotesSignupForm } from "./uiDataSelectors"; 13 import { UIData, UIDataStatus } from "src/redux/uiData"; 14 15 describe("uiDataSelectors", () => { 16 describe("dismissReleaseNotesSignupForm selector", () => { 17 const selector = dismissReleaseNotesSignupForm.resultFunc; 18 19 it("returns `false` if uiData status is VALID and has no data", () => { 20 const uiData: UIData = { 21 status: UIDataStatus.VALID, 22 error: null, 23 data: undefined, 24 }; 25 assert.isFalse(selector(uiData)); 26 }); 27 28 it("returns `true` if uiData status is VALID and data = true", () => { 29 const uiData: UIData = { 30 status: UIDataStatus.VALID, 31 error: null, 32 data: true, 33 }; 34 assert.isTrue(selector(uiData)); 35 }); 36 37 it("returns `true` if uiData status is UNINITIALIZED", () => { 38 const uiData: UIData = { 39 status: UIDataStatus.UNINITIALIZED, 40 error: null, 41 data: undefined, 42 }; 43 assert.isTrue(selector(uiData)); 44 }); 45 46 it("returns `true` if uiData state is undefined", () => { 47 assert.isTrue(selector(undefined)); 48 }); 49 }); 50 });