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

composerFooterLayout.test.ts

52 lines1.7 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX,
5 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX,
6 shouldUseCompactComposerPrimaryActions,
7 shouldUseCompactComposerFooter,
8} from "./composerFooterLayout";
9​
10describe("shouldUseCompactComposerFooter", () => {
11 it("stays expanded without a measured width", () => {
12 expect(shouldUseCompactComposerFooter(null)).toBe(false);
13 });
14​
15 it("switches to compact mode below the breakpoint", () => {
16 expect(shouldUseCompactComposerFooter(COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX - 1)).toBe(true);
17 });
18​
19 it("stays expanded at and above the breakpoint", () => {
20 expect(shouldUseCompactComposerFooter(COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX)).toBe(false);
21 expect(shouldUseCompactComposerFooter(COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX + 48)).toBe(false);
22 });
23​
24 it("uses a higher breakpoint for wide action states", () => {
25 expect(
26 shouldUseCompactComposerFooter(COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX - 1, {
27 hasWideActions: true,
28 }),
29 ).toBe(true);
30 expect(
31 shouldUseCompactComposerFooter(COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX, {
32 hasWideActions: true,
33 }),
34 ).toBe(false);
35 });
36});
37​
38describe("shouldUseCompactComposerPrimaryActions", () => {
39 it("matches the wide footer breakpoint", () => {
40 expect(
41 shouldUseCompactComposerPrimaryActions(
42 COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX - 1,
43 { hasWideActions: true },
44 ),
45 ).toBe(true);
46 expect(
47 shouldUseCompactComposerPrimaryActions(COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX, {
48 hasWideActions: true,
49 }),
50 ).toBe(false);
51 });
52});