Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PreviewAutomationOwner.test.ts

31 lines1.0 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { observeAutomationOwnerConnectedGeneration } from "./PreviewAutomationOwner";
4​
5describe("observeAutomationOwnerConnectedGeneration", () => {
6 it("reports ownership when the initial transport generation connects", () => {
7 const initial = observeAutomationOwnerConnectedGeneration(null, 1);
8 expect(initial).toEqual({
9 nextGeneration: 1,
10 shouldReport: true,
11 });
12​
13 const disconnected = observeAutomationOwnerConnectedGeneration(initial.nextGeneration, null);
14 expect(disconnected).toEqual({
15 nextGeneration: 1,
16 shouldReport: false,
17 });
18​
19 expect(observeAutomationOwnerConnectedGeneration(disconnected.nextGeneration, 2)).toEqual({
20 nextGeneration: 2,
21 shouldReport: true,
22 });
23 });
24​
25 it("does not re-report for repeated connected state from the same generation", () => {
26 expect(observeAutomationOwnerConnectedGeneration(3, 3)).toEqual({
27 nextGeneration: 3,
28 shouldReport: false,
29 });
30 });
31});