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

composerFooterLayout.test.ts

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