1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-06-23 15:10:30 -04:00
parent 4c039da15e
commit 8013c87ad6

View File

@ -8,19 +8,19 @@ import { observableCrate } from "./impl";
describe("observable-crate", () => { describe("observable-crate", () => {
it("can be constructed with initial value", () => { it("can be constructed with initial value", () => {
expect(() => observableCrate(0).build()).not.toThrow(); expect(() => observableCrate(0)).not.toThrow();
}); });
it("has a definite type if the initial value is provided", () => { it("has a definite type if the initial value is provided", () => {
expect (() => { expect (() => {
const res: ObservableCrate<number> = observableCrate(0).build(); const res: ObservableCrate<number> = observableCrate(0);
void res; void res;
}).not.toThrow(); }).not.toThrow();
}); });
it("accepts a map of transitionHandlers", () => { it("accepts an array of transitionHandlers", () => {
expect(() => observableCrate(0).withHandlers(new Map())).not.toThrow(); expect(() => observableCrate(0, [])).not.toThrow();
}); });
describe("with a crate over an enum, and some transition handlers", () => { describe("with a crate over an enum, and some transition handlers", () => {
@ -37,23 +37,53 @@ describe("observable-crate", () => {
beforeEach(() => { beforeEach(() => {
correctHandler = jest.fn(); correctHandler = jest.fn();
incorrectHandler = jest.fn(); incorrectHandler = jest.fn();
crate = observableCrate(Test.Start).withHandlers(new Map([ crate = observableCrate(Test.Start, [
[Test.Start, new Map([ {
[Test.Start, incorrectHandler], from: Test.Start,
[Test.T1, correctHandler], to: Test.Start,
[Test.End, incorrectHandler], onTransition: incorrectHandler,
])], },
[Test.T1, new Map([ {
[Test.Start, incorrectHandler], from: Test.Start,
[Test.T1, incorrectHandler], to: Test.T1,
[Test.End, incorrectHandler], onTransition: correctHandler,
])], },
[Test.End, new Map([ {
[Test.Start, incorrectHandler], from: Test.Start,
[Test.T1, incorrectHandler], to: Test.End,
[Test.End, incorrectHandler], onTransition: incorrectHandler,
])], },
])); {
from: Test.T1,
to: Test.Start,
onTransition: incorrectHandler,
},
{
from: Test.T1,
to: Test.T1,
onTransition: incorrectHandler,
},
{
from: Test.T1,
to: Test.End,
onTransition: incorrectHandler,
},
{
from: Test.End,
to: Test.Start,
onTransition: incorrectHandler,
},
{
from: Test.End,
to: Test.T1,
onTransition: incorrectHandler,
},
{
from: Test.End,
to: Test.End,
onTransition: incorrectHandler,
},
]);
}); });
it("initial value is available", () => { it("initial value is available", () => {