@1doc/1ds-react 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1540 -0
- package/dist/components/AILabel/AILabel.js +1 -1
- package/dist/components/Accordion/Accordion.css +13 -0
- package/dist/components/Accordion/Accordion.d.ts +9 -2
- package/dist/components/Accordion/Accordion.js +1 -0
- package/dist/components/AppSubheader/AppSubheader.css +10 -1
- package/dist/components/AttachmentCard/AttachmentCard.css +26 -8
- package/dist/components/AttachmentCard/AttachmentCard.d.ts +22 -2
- package/dist/components/AttachmentCard/AttachmentCard.js +47 -3
- package/dist/components/Avatar/Avatar.css +7 -2
- package/dist/components/Avatar/AvatarGroup.d.ts +17 -0
- package/dist/components/Avatar/AvatarGroup.js +22 -8
- package/dist/components/Badge/Badge.css +67 -2
- package/dist/components/Badge/Badge.d.ts +23 -4
- package/dist/components/Badge/Badge.js +4 -0
- package/dist/components/Box/Box.css +83 -0
- package/dist/components/Box/Box.d.ts +82 -2
- package/dist/components/Box/Box.js +42 -2
- package/dist/components/Button/Button.css +29 -0
- package/dist/components/Button/Button.d.ts +4 -4
- package/dist/components/Button/Button.js +4 -1
- package/dist/components/Calendar/Calendar.css +245 -0
- package/dist/components/Calendar/Calendar.d.ts +126 -0
- package/dist/components/Calendar/Calendar.js +320 -0
- package/dist/components/Chips/Chips.css +38 -0
- package/dist/components/Chips/Chips.d.ts +5 -2
- package/dist/components/Chips/Chips.js +2 -1
- package/dist/components/Coachmark/Coachmark.css +128 -0
- package/dist/components/Coachmark/Coachmark.d.ts +87 -0
- package/dist/components/Coachmark/Coachmark.js +362 -0
- package/dist/components/CodeBlock/CodeBlock.css +96 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +47 -0
- package/dist/components/CodeBlock/CodeBlock.js +103 -0
- package/dist/components/ColorPicker/ColorPicker.css +140 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +73 -0
- package/dist/components/ColorPicker/ColorPicker.js +219 -0
- package/dist/components/Combobox/Combobox.css +8 -0
- package/dist/components/DataTable/DataTable.css +254 -0
- package/dist/components/DataTable/DataTable.d.ts +81 -5
- package/dist/components/DataTable/DataTable.js +335 -19
- package/dist/components/DatePicker/DatePicker.css +8 -0
- package/dist/components/DatePicker/DatePicker.js +10 -1
- package/dist/components/DescriptionList/DescriptionList.css +127 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +62 -0
- package/dist/components/DescriptionList/DescriptionList.js +52 -0
- package/dist/components/EmptyState/EmptyState.d.ts +4 -2
- package/dist/components/EmptyState/EmptyState.js +2 -2
- package/dist/components/FileInput/FileInput.css +16 -0
- package/dist/components/FileInput/FileInput.d.ts +4 -2
- package/dist/components/FileInput/FileInput.js +8 -2
- package/dist/components/Grid/Grid.js +5 -5
- package/dist/components/IconPicker/IconPicker.css +107 -0
- package/dist/components/IconPicker/IconPicker.d.ts +74 -0
- package/dist/components/IconPicker/IconPicker.js +194 -0
- package/dist/components/Input/Input.css +59 -0
- package/dist/components/Input/Input.d.ts +17 -1
- package/dist/components/Input/Input.js +67 -5
- package/dist/components/Kanban/Kanban.css +4 -0
- package/dist/components/Kbd/Kbd.css +66 -0
- package/dist/components/Kbd/Kbd.d.ts +32 -0
- package/dist/components/Kbd/Kbd.js +40 -0
- package/dist/components/List/List.css +136 -0
- package/dist/components/List/List.d.ts +82 -0
- package/dist/components/List/List.js +53 -0
- package/dist/components/List/ListItem.d.ts +97 -0
- package/dist/components/List/ListItem.js +82 -0
- package/dist/components/Modal/Modal.css +80 -0
- package/dist/components/Modal/Modal.d.ts +33 -6
- package/dist/components/Modal/Modal.js +101 -6
- package/dist/components/MultiSelect/MultiSelect.css +8 -0
- package/dist/components/MultiSelect/MultiSelect.js +10 -1
- package/dist/components/OrgChart/OrgChart.css +149 -0
- package/dist/components/OrgChart/OrgChart.d.ts +83 -0
- package/dist/components/OrgChart/OrgChart.js +297 -0
- package/dist/components/OtpInput/OtpInput.css +93 -0
- package/dist/components/OtpInput/OtpInput.d.ts +60 -0
- package/dist/components/OtpInput/OtpInput.js +215 -0
- package/dist/components/PhoneInput/PhoneInput.css +8 -0
- package/dist/components/Popover/Popover.d.ts +7 -0
- package/dist/components/Popover/Popover.js +11 -1
- package/dist/components/RichTextEditor/RichTextEditor.css +250 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +97 -0
- package/dist/components/RichTextEditor/RichTextEditor.js +951 -0
- package/dist/components/SegmentedControl/SegmentedControl.css +24 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +10 -2
- package/dist/components/Select/Select.css +164 -0
- package/dist/components/Select/Select.d.ts +34 -0
- package/dist/components/Select/Select.js +258 -28
- package/dist/components/Stack/Stack.css +49 -0
- package/dist/components/Stack/Stack.d.ts +65 -7
- package/dist/components/Stack/Stack.js +30 -2
- package/dist/components/StatCard/StatCard.css +138 -0
- package/dist/components/StatCard/StatCard.d.ts +26 -0
- package/dist/components/StatCard/StatCard.js +13 -1
- package/dist/components/Tabs/Tab.d.ts +15 -0
- package/dist/components/Tabs/Tab.js +30 -1
- package/dist/components/Tabs/Tabs.css +132 -0
- package/dist/components/Tabs/Tabs.d.ts +7 -0
- package/dist/components/Tabs/Tabs.js +13 -2
- package/dist/components/Tag/Tag.css +85 -2
- package/dist/components/Tag/Tag.d.ts +13 -6
- package/dist/components/Tag/Tag.js +1 -0
- package/dist/components/Text/Text.js +2 -2
- package/dist/components/Textarea/Textarea.css +8 -0
- package/dist/components/TimePicker/TimePicker.css +8 -0
- package/dist/components/Toast/Toast.css +32 -0
- package/dist/components/Toast/Toast.d.ts +18 -0
- package/dist/components/Toast/Toast.js +14 -1
- package/dist/components/Toast/ToastStack.js +8 -1
- package/dist/components/Tooltip/Tooltip.css +25 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.js +18 -3
- package/dist/index.d.ts +25 -0
- package/dist/index.js +14 -0
- package/dist/teste/AILabel.test.d.ts +1 -0
- package/dist/teste/AILabel.test.js +33 -0
- package/dist/teste/AccordionConteudoLivre.test.d.ts +1 -0
- package/dist/teste/AccordionConteudoLivre.test.js +29 -0
- package/dist/teste/AccordionTituloNeutro.test.d.ts +1 -0
- package/dist/teste/AccordionTituloNeutro.test.js +23 -0
- package/dist/teste/AppSubheaderRegiao.test.d.ts +1 -0
- package/dist/teste/AppSubheaderRegiao.test.js +13 -0
- package/dist/teste/AtributosRepassados.test.d.ts +1 -0
- package/dist/teste/AtributosRepassados.test.js +52 -0
- package/dist/teste/AttachmentCardIA.test.d.ts +1 -0
- package/dist/teste/AttachmentCardIA.test.js +89 -0
- package/dist/teste/AttachmentCardLista.test.d.ts +1 -0
- package/dist/teste/AttachmentCardLista.test.js +49 -0
- package/dist/teste/AttachmentCardSm.test.d.ts +1 -0
- package/dist/teste/AttachmentCardSm.test.js +26 -0
- package/dist/teste/AvatarGroupOverlap.test.d.ts +1 -0
- package/dist/teste/AvatarGroupOverlap.test.js +56 -0
- package/dist/teste/BadgeNeutroColado.test.d.ts +1 -0
- package/dist/teste/BadgeNeutroColado.test.js +11 -0
- package/dist/teste/BadgeTag.test.d.ts +1 -0
- package/dist/teste/BadgeTag.test.js +55 -0
- package/dist/teste/BoxItemFlex.test.d.ts +1 -0
- package/dist/teste/BoxItemFlex.test.js +54 -0
- package/dist/teste/BoxLayout.test.d.ts +1 -0
- package/dist/teste/BoxLayout.test.js +35 -0
- package/dist/teste/Button.test.d.ts +1 -0
- package/dist/teste/Button.test.js +27 -0
- package/dist/teste/Calendar.test.d.ts +1 -0
- package/dist/teste/Calendar.test.js +221 -0
- package/dist/teste/CalendarCabecalho.test.d.ts +1 -0
- package/dist/teste/CalendarCabecalho.test.js +11 -0
- package/dist/teste/ChipsXs.test.d.ts +1 -0
- package/dist/teste/ChipsXs.test.js +31 -0
- package/dist/teste/Coachmark.test.d.ts +1 -0
- package/dist/teste/Coachmark.test.js +149 -0
- package/dist/teste/CoachmarkSemVeu.test.d.ts +1 -0
- package/dist/teste/CoachmarkSemVeu.test.js +85 -0
- package/dist/teste/ColorPicker.test.d.ts +1 -0
- package/dist/teste/ColorPicker.test.js +132 -0
- package/dist/teste/ColorPickerXs.test.d.ts +1 -0
- package/dist/teste/ColorPickerXs.test.js +21 -0
- package/dist/teste/DataTableArvoreEVariantes.test.d.ts +1 -0
- package/dist/teste/DataTableArvoreEVariantes.test.js +190 -0
- package/dist/teste/DataTableCelulaLivre.test.d.ts +1 -0
- package/dist/teste/DataTableCelulaLivre.test.js +76 -0
- package/dist/teste/DataTableDocumento.test.d.ts +1 -0
- package/dist/teste/DataTableDocumento.test.js +92 -0
- package/dist/teste/DatePicker.test.js +23 -0
- package/dist/teste/DescriptionListCompacta.test.d.ts +1 -0
- package/dist/teste/DescriptionListCompacta.test.js +22 -0
- package/dist/teste/EmptyStateTituloRico.test.d.ts +1 -0
- package/dist/teste/EmptyStateTituloRico.test.js +23 -0
- package/dist/teste/FileInputTrigger.test.d.ts +1 -0
- package/dist/teste/FileInputTrigger.test.js +53 -0
- package/dist/teste/IconPicker.test.d.ts +1 -0
- package/dist/teste/IconPicker.test.js +130 -0
- package/dist/teste/InputAgrupado.test.d.ts +1 -0
- package/dist/teste/InputAgrupado.test.js +24 -0
- package/dist/teste/InputMascaraEAfins.test.d.ts +1 -0
- package/dist/teste/InputMascaraEAfins.test.js +99 -0
- package/dist/teste/KbdCodeBlock.test.d.ts +1 -0
- package/dist/teste/KbdCodeBlock.test.js +95 -0
- package/dist/teste/List.test.d.ts +1 -0
- package/dist/teste/List.test.js +153 -0
- package/dist/teste/ListItemTooltipStandalone.test.d.ts +1 -0
- package/dist/teste/ListItemTooltipStandalone.test.js +39 -0
- package/dist/teste/ModalVariantes.test.d.ts +1 -0
- package/dist/teste/ModalVariantes.test.js +151 -0
- package/dist/teste/NomeAcessivelSsr.test.d.ts +1 -0
- package/dist/teste/NomeAcessivelSsr.test.js +88 -0
- package/dist/teste/OrgChart.test.d.ts +1 -0
- package/dist/teste/OrgChart.test.js +162 -0
- package/dist/teste/OtpInput.test.d.ts +1 -0
- package/dist/teste/OtpInput.test.js +143 -0
- package/dist/teste/PopoverMaxHeight.test.d.ts +1 -0
- package/dist/teste/PopoverMaxHeight.test.js +38 -0
- package/dist/teste/RichTextEditor.test.d.ts +1 -0
- package/dist/teste/RichTextEditor.test.js +287 -0
- package/dist/teste/RichTextEditorAlinhaImagemTabela.test.d.ts +1 -0
- package/dist/teste/RichTextEditorAlinhaImagemTabela.test.js +212 -0
- package/dist/teste/RichTextEditorEstiloDeTexto.test.d.ts +1 -0
- package/dist/teste/RichTextEditorEstiloDeTexto.test.js +120 -0
- package/dist/teste/SegmentedControlContador.test.d.ts +1 -0
- package/dist/teste/SegmentedControlContador.test.js +39 -0
- package/dist/teste/SelectAbertoControladoEFlutuante.test.d.ts +1 -0
- package/dist/teste/SelectAbertoControladoEFlutuante.test.js +145 -0
- package/dist/teste/SelectFiltroCorETamanho.test.d.ts +1 -0
- package/dist/teste/SelectFiltroCorETamanho.test.js +77 -0
- package/dist/teste/SelectPlacementFiltro.test.d.ts +1 -0
- package/dist/teste/SelectPlacementFiltro.test.js +88 -0
- package/dist/teste/Stack.test.d.ts +1 -0
- package/dist/teste/Stack.test.js +57 -0
- package/dist/teste/StatCardRotuloTopo.test.d.ts +1 -0
- package/dist/teste/StatCardRotuloTopo.test.js +34 -0
- package/dist/teste/StatCardSecundariaETom.test.d.ts +1 -0
- package/dist/teste/StatCardSecundariaETom.test.js +45 -0
- package/dist/teste/TabsContadorFechavel.test.d.ts +1 -0
- package/dist/teste/TabsContadorFechavel.test.js +79 -0
- package/dist/teste/ToastAcaoEDetalhes.test.d.ts +1 -0
- package/dist/teste/ToastAcaoEDetalhes.test.js +94 -0
- package/dist/teste/TooltipDark.test.d.ts +1 -0
- package/dist/teste/TooltipDark.test.js +31 -0
- package/dist/utils/calendario.d.ts +28 -0
- package/dist/utils/calendario.js +73 -0
- package/dist/utils/html-seguro.d.ts +45 -0
- package/dist/utils/html-seguro.js +208 -0
- package/dist/utils/paleta-de-cores.d.ts +26 -0
- package/dist/utils/paleta-de-cores.js +10 -0
- package/dist/utils/texto.d.ts +5 -0
- package/dist/utils/texto.js +5 -0
- package/dist/utils/toast.d.ts +10 -1
- package/dist/utils/toast.js +2 -1
- package/package.json +3 -3
- package/src/index.ts +26 -0
- package/src/teste/AILabel.test.tsx +41 -0
- package/src/teste/AccordionConteudoLivre.test.tsx +39 -0
- package/src/teste/AccordionTituloNeutro.test.tsx +25 -0
- package/src/teste/AppSubheaderRegiao.test.tsx +17 -0
- package/src/teste/AtributosRepassados.test.tsx +73 -0
- package/src/teste/AttachmentCardIA.test.tsx +126 -0
- package/src/teste/AttachmentCardLista.test.tsx +53 -0
- package/src/teste/AttachmentCardSm.test.tsx +29 -0
- package/src/teste/AvatarGroupOverlap.test.tsx +74 -0
- package/src/teste/BadgeNeutroColado.test.tsx +15 -0
- package/src/teste/BadgeTag.test.tsx +85 -0
- package/src/teste/BoxItemFlex.test.tsx +81 -0
- package/src/teste/BoxLayout.test.tsx +50 -0
- package/src/teste/Button.test.tsx +39 -0
- package/src/teste/Calendar.test.tsx +282 -0
- package/src/teste/CalendarCabecalho.test.tsx +11 -0
- package/src/teste/ChipsXs.test.tsx +41 -0
- package/src/teste/Coachmark.test.tsx +198 -0
- package/src/teste/CoachmarkSemVeu.test.tsx +101 -0
- package/src/teste/ColorPicker.test.tsx +153 -0
- package/src/teste/ColorPickerXs.test.tsx +22 -0
- package/src/teste/DataTableArvoreEVariantes.test.tsx +240 -0
- package/src/teste/DataTableCelulaLivre.test.tsx +103 -0
- package/src/teste/DataTableDocumento.test.tsx +102 -0
- package/src/teste/DatePicker.test.tsx +38 -0
- package/src/teste/DescriptionListCompacta.test.tsx +24 -0
- package/src/teste/EmptyStateTituloRico.test.tsx +34 -0
- package/src/teste/FileInputTrigger.test.tsx +89 -0
- package/src/teste/IconPicker.test.tsx +145 -0
- package/src/teste/InputAgrupado.test.tsx +26 -0
- package/src/teste/InputMascaraEAfins.test.tsx +124 -0
- package/src/teste/KbdCodeBlock.test.tsx +106 -0
- package/src/teste/List.test.tsx +269 -0
- package/src/teste/ListItemTooltipStandalone.test.tsx +64 -0
- package/src/teste/ModalVariantes.test.tsx +173 -0
- package/src/teste/NomeAcessivelSsr.test.tsx +110 -0
- package/src/teste/OrgChart.test.tsx +183 -0
- package/src/teste/OtpInput.test.tsx +163 -0
- package/src/teste/PopoverMaxHeight.test.tsx +47 -0
- package/src/teste/RichTextEditor.test.tsx +329 -0
- package/src/teste/RichTextEditorAlinhaImagemTabela.test.tsx +238 -0
- package/src/teste/RichTextEditorEstiloDeTexto.test.tsx +137 -0
- package/src/teste/SegmentedControlContador.test.tsx +43 -0
- package/src/teste/SelectAbertoControladoEFlutuante.test.tsx +180 -0
- package/src/teste/SelectFiltroCorETamanho.test.tsx +90 -0
- package/src/teste/SelectPlacementFiltro.test.tsx +110 -0
- package/src/teste/Stack.test.tsx +80 -0
- package/src/teste/StatCardRotuloTopo.test.tsx +44 -0
- package/src/teste/StatCardSecundariaETom.test.tsx +51 -0
- package/src/teste/TabsContadorFechavel.test.tsx +144 -0
- package/src/teste/ToastAcaoEDetalhes.test.tsx +109 -0
- package/src/teste/TooltipDark.test.tsx +51 -0
- package/src/utils/calendario.ts +78 -0
- package/src/utils/html-seguro.ts +197 -0
- package/src/utils/paleta-de-cores.ts +34 -0
- package/src/utils/texto.ts +5 -0
- package/src/utils/toast.ts +12 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import Text from "../components/Text/Text";
|
|
5
|
+
import Grid from "../components/Grid/Grid";
|
|
6
|
+
import Logo from "../components/Logo/Logo";
|
|
7
|
+
import Button from "../components/Button/Button";
|
|
8
|
+
import DataTable from "../components/DataTable/DataTable";
|
|
9
|
+
/**
|
|
10
|
+
* Paridade com o Vue: no Vue gerado, Text, Grid e Logo descartavam
|
|
11
|
+
* `title`, `style` e `aria-*`, o Button escrevia `autofocus="false"` e o
|
|
12
|
+
* DataTable a classe `--selected.value`. O React nunca teve o defeito; o teste
|
|
13
|
+
* garante que a correção do Vue não o introduza aqui (mesma fonte Mitosis).
|
|
14
|
+
*/
|
|
15
|
+
describe("atributos repassados ao elemento raiz", () => {
|
|
16
|
+
it("Text repassa title, style e aria-*", () => {
|
|
17
|
+
const { container } = render(_jsx(Text, { title: "Dica", style: { marginTop: 4 }, "aria-live": "polite", "data-x": "1", children: "Ol\u00E1" }));
|
|
18
|
+
const el = container.firstElementChild;
|
|
19
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
20
|
+
expect(el.style.marginTop).toBe("4px");
|
|
21
|
+
expect(el.getAttribute("aria-live")).toBe("polite");
|
|
22
|
+
expect(el.getAttribute("data-x")).toBe("1");
|
|
23
|
+
});
|
|
24
|
+
it("Grid repassa title, style e aria-*", () => {
|
|
25
|
+
const { container } = render(_jsx(Grid, { container: true, spacing: "xxxs", title: "Dica", style: { marginTop: 4 }, "aria-label": "\u00C1rea", children: "x" }));
|
|
26
|
+
const el = container.firstElementChild;
|
|
27
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
28
|
+
expect(el.style.marginTop).toBe("4px");
|
|
29
|
+
expect(el.getAttribute("aria-label")).toBe("Área");
|
|
30
|
+
});
|
|
31
|
+
it("Logo repassa title, style e aria-*", () => {
|
|
32
|
+
const { container } = render(_jsx(Logo, { title: "Dica", style: { width: 80 }, "aria-hidden": "true" }));
|
|
33
|
+
const el = container.firstElementChild;
|
|
34
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
35
|
+
expect(el.style.width).toBe("80px");
|
|
36
|
+
expect(el.getAttribute("aria-hidden")).toBe("true");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe("Button · autoFocus", () => {
|
|
40
|
+
it("não escreve autofocus quando falso ou ausente", () => {
|
|
41
|
+
const { container } = render(_jsx(Button, { children: "Salvar" }));
|
|
42
|
+
expect(container.querySelector("[autofocus]")).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe("DataTable · linha selecionada", () => {
|
|
46
|
+
it("a classe --selected vai limpa, só na linha selecionada", () => {
|
|
47
|
+
const { container } = render(_jsx(DataTable, { columns: [{ key: "nome", label: "Nome" }], data: [{ nome: "Cris Lima" }, { nome: "Ana Paula" }], selectable: true, selectedRows: [0] }));
|
|
48
|
+
const marcadas = container.querySelectorAll(".umds-datatable__row--selected");
|
|
49
|
+
expect(marcadas).toHaveLength(1);
|
|
50
|
+
expect(container.innerHTML).not.toContain(".value");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import AttachmentCard from "../components/AttachmentCard/AttachmentCard";
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
if (!globalThis.ResizeObserver) {
|
|
8
|
+
globalThis.ResizeObserver = class {
|
|
9
|
+
observe() { }
|
|
10
|
+
unobserve() { }
|
|
11
|
+
disconnect() { }
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function cartaoDeIA(extra = {}) {
|
|
16
|
+
const aoAplicar = vi.fn();
|
|
17
|
+
const ui = (_jsx(AttachmentCard, { fileName: "protocolo.pdf", documentType: "Protocolo", status: "ai", statusLabel: "Recursos IA", onOpen: () => { }, panel: _jsxs("div", { children: [_jsx("p", { children: "A IA sugere um assunto." }), _jsx("button", { type: "button", onClick: aoAplicar, children: "Aplicar sugest\u00E3o" })] }), ...extra }));
|
|
18
|
+
return { aoAplicar, ...render(ui) };
|
|
19
|
+
}
|
|
20
|
+
describe("AttachmentCard · status ai", () => {
|
|
21
|
+
it("escreve a classe do selo de IA e usa a varinha por padrão", () => {
|
|
22
|
+
const { container } = render(_jsx(AttachmentCard, { fileName: "x.pdf", status: "ai", statusLabel: "Recursos IA" }));
|
|
23
|
+
const selo = container.querySelector(".umds-attachment-card__status");
|
|
24
|
+
expect(selo).toHaveClass("umds-attachment-card__status--ai");
|
|
25
|
+
expect(selo.querySelector("svg")).not.toBeNull();
|
|
26
|
+
});
|
|
27
|
+
it("só o selo de IA ganha ícone por padrão", () => {
|
|
28
|
+
const { container } = render(_jsx(AttachmentCard, { fileName: "x.pdf", status: "positive", statusLabel: "Ok" }));
|
|
29
|
+
expect(container.querySelector(".umds-attachment-card__status svg")).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("AttachmentCard · slot panel", () => {
|
|
33
|
+
it("o painel livre substitui o resultado da conferência, e o selo vira botão sem statusDetails", async () => {
|
|
34
|
+
const usuario = userEvent.setup();
|
|
35
|
+
cartaoDeIA();
|
|
36
|
+
const selo = screen.getByRole("button", { name: /^Recursos IA/ });
|
|
37
|
+
expect(selo).toHaveAttribute("aria-haspopup", "dialog");
|
|
38
|
+
await usuario.click(selo);
|
|
39
|
+
const painel = await screen.findByRole("dialog");
|
|
40
|
+
expect(painel).toHaveTextContent("A IA sugere um assunto.");
|
|
41
|
+
expect(screen.getByRole("button", { name: "Aplicar sugestão" })).toBeInTheDocument();
|
|
42
|
+
// sem título interno: o painel é nomeado pelo selo
|
|
43
|
+
expect(painel).not.toHaveAttribute("aria-labelledby");
|
|
44
|
+
expect(painel).toHaveAccessibleName(/Recursos IA/);
|
|
45
|
+
});
|
|
46
|
+
it("sem panel nem statusDetails o selo não é botão", () => {
|
|
47
|
+
render(_jsx(AttachmentCard, { fileName: "x.pdf", status: "ai", statusLabel: "Recursos IA" }));
|
|
48
|
+
expect(screen.queryByRole("button")).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
it("panelWidth escreve a largura do painel; sem ela não há style", async () => {
|
|
51
|
+
const usuario = userEvent.setup();
|
|
52
|
+
cartaoDeIA({ panelWidth: 280 });
|
|
53
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
54
|
+
expect((await screen.findByRole("dialog")).style.width).toBe("280px");
|
|
55
|
+
});
|
|
56
|
+
it("sem panelWidth o painel não leva style", async () => {
|
|
57
|
+
const usuario = userEvent.setup();
|
|
58
|
+
cartaoDeIA();
|
|
59
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
60
|
+
expect((await screen.findByRole("dialog")).getAttribute("style")).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
describe("AttachmentCard · closePanelOnAction", () => {
|
|
64
|
+
it("acionar um botão do painel fecha, devolve o foco ao selo e a ação chega ao app", async () => {
|
|
65
|
+
const usuario = userEvent.setup();
|
|
66
|
+
const { aoAplicar } = cartaoDeIA({ closePanelOnAction: true });
|
|
67
|
+
const selo = screen.getByRole("button", { name: /^Recursos IA/ });
|
|
68
|
+
await usuario.click(selo);
|
|
69
|
+
await usuario.click(await screen.findByRole("button", { name: "Aplicar sugestão" }));
|
|
70
|
+
expect(aoAplicar).toHaveBeenCalledTimes(1);
|
|
71
|
+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
|
|
72
|
+
expect(selo).toHaveFocus();
|
|
73
|
+
});
|
|
74
|
+
it("sem a prop o painel continua aberto depois da ação", async () => {
|
|
75
|
+
const usuario = userEvent.setup();
|
|
76
|
+
const { aoAplicar } = cartaoDeIA();
|
|
77
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
78
|
+
await usuario.click(await screen.findByRole("button", { name: "Aplicar sugestão" }));
|
|
79
|
+
expect(aoAplicar).toHaveBeenCalledTimes(1);
|
|
80
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
it("o botão de copiar um campo não fecha o painel", async () => {
|
|
83
|
+
const usuario = userEvent.setup();
|
|
84
|
+
render(_jsx(AttachmentCard, { fileName: "cpf.pdf", status: "positive", statusLabel: "Pr\u00E9-aprovado", closePanelOnAction: true, statusDetails: { fields: [{ label: "CPF", value: "384.221.760-05", copyable: true }] } }));
|
|
85
|
+
await usuario.click(screen.getByRole("button", { name: /^Pré-aprovado/ }));
|
|
86
|
+
await usuario.click(await screen.findByRole("button", { name: "Copiar CPF" }));
|
|
87
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import AttachmentCard from "../components/AttachmentCard/AttachmentCard";
|
|
6
|
+
const DETALHES = {
|
|
7
|
+
description: "Documento legível.",
|
|
8
|
+
fields: [
|
|
9
|
+
{ label: "Nome completo", value: "Marcos Vinícius Tavares", copyable: true },
|
|
10
|
+
{ label: "CPF", value: "123.456.789-09" },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
async function abrirPainel() {
|
|
14
|
+
const usuario = userEvent.setup();
|
|
15
|
+
render(_jsx(AttachmentCard, { fileName: "cnh.pdf", documentType: "CNH", status: "positive", statusLabel: "Pr\u00E9-aprovado", statusDetails: DETALHES }));
|
|
16
|
+
await usuario.click(screen.getByRole("button", { name: /Pré-aprovado/ }));
|
|
17
|
+
return usuario;
|
|
18
|
+
}
|
|
19
|
+
describe("AttachmentCard · o <dl> do painel é válido (axe definition-list)", () => {
|
|
20
|
+
it("o dl só tem div filhos, e cada div só tem dt e dd, nessa ordem", async () => {
|
|
21
|
+
await abrirPainel();
|
|
22
|
+
const dl = document.querySelector(".umds-attachment-card__campos");
|
|
23
|
+
expect(dl.tagName).toBe("DL");
|
|
24
|
+
const grupos = [...dl.children];
|
|
25
|
+
expect(grupos).toHaveLength(2);
|
|
26
|
+
for (const grupo of grupos) {
|
|
27
|
+
expect(grupo.tagName).toBe("DIV");
|
|
28
|
+
expect([...grupo.children].map((f) => f.tagName)).toEqual(["DT", "DD"]);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
it("o botão de copiar mora dentro do dd, ao lado do valor, e continua com nome", async () => {
|
|
32
|
+
await abrirPainel();
|
|
33
|
+
const dd = document.querySelector(".umds-attachment-card__campo-valor");
|
|
34
|
+
expect(dd.tagName).toBe("DD");
|
|
35
|
+
expect(dd.querySelector(".umds-attachment-card__campo-valor-texto")).toHaveTextContent("Marcos Vinícius Tavares");
|
|
36
|
+
const botao = dd.querySelector("button");
|
|
37
|
+
expect(botao).toHaveAttribute("aria-label", "Copiar Nome completo");
|
|
38
|
+
// nenhum botão solto direto num div do dl
|
|
39
|
+
for (const grupo of document.querySelectorAll(".umds-attachment-card__campo")) {
|
|
40
|
+
expect(grupo.querySelector(":scope > button")).toBeNull();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
it("o campo sem copyable não tem botão e o valor segue no dd", async () => {
|
|
44
|
+
await abrirPainel();
|
|
45
|
+
const campos = document.querySelectorAll(".umds-attachment-card__campo");
|
|
46
|
+
expect(campos[1].querySelector("button")).toBeNull();
|
|
47
|
+
expect(campos[1].querySelector("dd")).toHaveTextContent("123.456.789-09");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import AttachmentCard from "../components/AttachmentCard/AttachmentCard";
|
|
5
|
+
const tamanho = (el) => el.style.width;
|
|
6
|
+
describe("AttachmentCard · size", () => {
|
|
7
|
+
it("md (padrão): ícone do preview de 48px e o do rodapé no sm do Icon", () => {
|
|
8
|
+
const { container } = render(_jsx(AttachmentCard, { fileName: "Protocolo 104-2026.pdf" }));
|
|
9
|
+
expect(container.firstElementChild).not.toHaveClass("umds-attachment-card--sm");
|
|
10
|
+
expect(tamanho(container.querySelector(".umds-attachment-card__preview .umds-icon"))).toBe("48px");
|
|
11
|
+
const rodape = container.querySelector(".umds-attachment-card__rodape-icone .umds-icon");
|
|
12
|
+
expect(rodape).toHaveClass("umds-icon--sm");
|
|
13
|
+
expect(rodape.style.width).toBe("");
|
|
14
|
+
});
|
|
15
|
+
it("sm: ícone do preview de 40px e o do rodapé de 12px", () => {
|
|
16
|
+
const { container } = render(_jsx(AttachmentCard, { fileName: "Protocolo 104-2026.pdf", size: "sm" }));
|
|
17
|
+
expect(container.firstElementChild).toHaveClass("umds-attachment-card--sm");
|
|
18
|
+
expect(tamanho(container.querySelector(".umds-attachment-card__preview .umds-icon"))).toBe("40px");
|
|
19
|
+
expect(tamanho(container.querySelector(".umds-attachment-card__rodape-icone .umds-icon"))).toBe("12px");
|
|
20
|
+
});
|
|
21
|
+
it("o ícone central escolhido continua valendo no sm", () => {
|
|
22
|
+
const { container } = render(_jsx(AttachmentCard, { fileName: "a.pdf", size: "sm", documentType: "CNH", status: "positive", statusLabel: "Pr\u00E9-aprovado" }));
|
|
23
|
+
expect(container.querySelector(".umds-attachment-card__tipo-texto")).toHaveTextContent("CNH");
|
|
24
|
+
expect(container.querySelector(".umds-attachment-card__status-texto")).toHaveTextContent("Pré-aprovado");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import AvatarGroup from "../components/Avatar/AvatarGroup";
|
|
5
|
+
const PESSOAS = [
|
|
6
|
+
{ name: "Ana Souza" },
|
|
7
|
+
{ name: "Bruno Lima" },
|
|
8
|
+
{ name: "Carla Dias" },
|
|
9
|
+
{ name: "Diego Ferraz" },
|
|
10
|
+
{ name: "Eduarda Neves" },
|
|
11
|
+
];
|
|
12
|
+
const grupo = (c) => c.firstElementChild;
|
|
13
|
+
describe("AvatarGroup · overflowCount", () => {
|
|
14
|
+
it("sem a prop, o +N é o que passou de max (como antes)", () => {
|
|
15
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS, max: 3 }));
|
|
16
|
+
expect(screen.getByText("+2")).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
it("overflowCount vira o +N sem itens-fantasma", () => {
|
|
19
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS.slice(0, 3), max: 3, overflowCount: 12 }));
|
|
20
|
+
expect(screen.getByText("+12")).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
it("soma com o que passou de max dentro de avatars", () => {
|
|
23
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS, max: 3, overflowCount: 10 }));
|
|
24
|
+
expect(screen.getByText("+12")).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
it("o rótulo traduzido recebe o total escondido", () => {
|
|
27
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS.slice(0, 2), max: 2, overflowCount: 7, overflowTitle: (n) => n + " others", overflowAriaLabel: (n) => n + " more avatars" }));
|
|
28
|
+
expect(screen.getByTitle("7 others")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
it("sem excedente nenhum, não há +N", () => {
|
|
31
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS.slice(0, 2), max: 4 }));
|
|
32
|
+
expect(screen.queryByText(/^\+/)).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
it("overflowCount 0 não cria +0", () => {
|
|
35
|
+
render(_jsx(AvatarGroup, { avatars: PESSOAS.slice(0, 2), max: 4, overflowCount: 0 }));
|
|
36
|
+
expect(screen.queryByText(/^\+/)).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe("AvatarGroup · overlap e ring", () => {
|
|
40
|
+
it("escrevem as variáveis do grupo em px", () => {
|
|
41
|
+
const { container } = render(_jsx(AvatarGroup, { avatars: PESSOAS, overlap: 6, ring: 1 }));
|
|
42
|
+
const el = grupo(container);
|
|
43
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-overlap")).toBe("6px");
|
|
44
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-ring")).toBe("1px");
|
|
45
|
+
});
|
|
46
|
+
it("só overlap não mexe no anel", () => {
|
|
47
|
+
const { container } = render(_jsx(AvatarGroup, { avatars: PESSOAS, overlap: 4 }));
|
|
48
|
+
const el = grupo(container);
|
|
49
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-overlap")).toBe("4px");
|
|
50
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-ring")).toBe("");
|
|
51
|
+
});
|
|
52
|
+
it("sem as props, nenhum style: valem os padrões do CSS", () => {
|
|
53
|
+
const { container } = render(_jsx(AvatarGroup, { avatars: PESSOAS }));
|
|
54
|
+
expect(grupo(container).getAttribute("style")).toBeNull();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import Badge from "../components/Badge/Badge";
|
|
5
|
+
/** A cascata de CSS de arquivo não existe no jsdom: a regra é conferida na fonte pelo teste do Vue; aqui, as classes no DOM. */
|
|
6
|
+
describe("Badge attached neutral", () => {
|
|
7
|
+
it("o neutro colado e sólido leva as três classes que a regra de CSS escolhe", () => {
|
|
8
|
+
const { container } = render(_jsx(Badge, { attached: true, variant: "neutral", appearance: "solid", children: "Tarefa manual" }));
|
|
9
|
+
expect(container.firstElementChild).toHaveClass("umds-badge--attached", "umds-badge--neutral", "umds-badge--solid");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import Badge from "../components/Badge/Badge";
|
|
5
|
+
import Tag from "../components/Tag/Tag";
|
|
6
|
+
const raiz = (c) => c.firstElementChild;
|
|
7
|
+
describe("Badge compacto, novidade e colado", () => {
|
|
8
|
+
it("size 2xs escreve a classe; sem size continua md", () => {
|
|
9
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Badge, { size: "2xs", children: "A" }), _jsx(Badge, { children: "B" })] }));
|
|
10
|
+
expect(container.children[0]).toHaveClass("umds-badge--2xs");
|
|
11
|
+
expect(container.children[1]).toHaveClass("umds-badge--md");
|
|
12
|
+
});
|
|
13
|
+
it("variant new escreve a classe da variante", () => {
|
|
14
|
+
const { container } = render(_jsx(Badge, { variant: "new", children: "Novidade" }));
|
|
15
|
+
expect(raiz(container)).toHaveClass("umds-badge--new");
|
|
16
|
+
});
|
|
17
|
+
it("attached escreve o modificador; sem ele não há", () => {
|
|
18
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Badge, { attached: true, children: "A" }), _jsx(Badge, { children: "B" })] }));
|
|
19
|
+
expect(container.children[0]).toHaveClass("umds-badge--attached");
|
|
20
|
+
expect(container.children[1]).not.toHaveClass("umds-badge--attached");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe("Tag compacta, soft, pílula e novidade", () => {
|
|
24
|
+
it("size xs escreve a classe e sm continua", () => {
|
|
25
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Tag, { label: "a", size: "xs" }), _jsx(Tag, { label: "b", size: "sm" })] }));
|
|
26
|
+
expect(container.children[0]).toHaveClass("umds-tag--xs");
|
|
27
|
+
expect(container.children[1]).toHaveClass("umds-tag--sm");
|
|
28
|
+
});
|
|
29
|
+
it("appearance soft e pill escrevem as classes", () => {
|
|
30
|
+
const { container } = render(_jsx(Tag, { label: "SOBR", appearance: "soft", variant: "primary", pill: true }));
|
|
31
|
+
expect(raiz(container)).toHaveClass("umds-tag--soft", "umds-tag--primary", "umds-tag--pill");
|
|
32
|
+
});
|
|
33
|
+
it("sem pill não há a classe; padrão segue outlined", () => {
|
|
34
|
+
const { container } = render(_jsx(Tag, { label: "x" }));
|
|
35
|
+
expect(raiz(container)).toHaveClass("umds-tag--outlined");
|
|
36
|
+
expect(raiz(container)).not.toHaveClass("umds-tag--pill");
|
|
37
|
+
});
|
|
38
|
+
it("variant new escreve a classe", () => {
|
|
39
|
+
const { container } = render(_jsx(Tag, { label: "Dado simulado", variant: "new", appearance: "soft" }));
|
|
40
|
+
expect(raiz(container)).toHaveClass("umds-tag--new", "umds-tag--soft");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe("Badge attachedSide", () => {
|
|
44
|
+
it("right escreve o modificador do canto direito; left e o padrão não", () => {
|
|
45
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Badge, { attached: true, attachedSide: "right", children: "A" }), _jsx(Badge, { attached: true, attachedSide: "left", children: "B" }), _jsx(Badge, { attached: true, children: "C" })] }));
|
|
46
|
+
expect(container.children[0]).toHaveClass("umds-badge--attached", "umds-badge--attached-right");
|
|
47
|
+
expect(container.children[1]).not.toHaveClass("umds-badge--attached-right");
|
|
48
|
+
expect(container.children[2]).not.toHaveClass("umds-badge--attached-right");
|
|
49
|
+
});
|
|
50
|
+
it("attachedSide sem attached não faz nada", () => {
|
|
51
|
+
const { container } = render(_jsx(Badge, { attachedSide: "right", children: "A" }));
|
|
52
|
+
expect(raiz(container)).not.toHaveClass("umds-badge--attached-right");
|
|
53
|
+
expect(raiz(container)).not.toHaveClass("umds-badge--attached");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import Box from "../components/Box/Box";
|
|
5
|
+
describe("Box como item flex e com `as`", () => {
|
|
6
|
+
it("sem `as` continua um div", () => {
|
|
7
|
+
const { container } = render(_jsx(Box, { padding: "md", children: "x" }));
|
|
8
|
+
expect(container.firstElementChild?.tagName).toBe("DIV");
|
|
9
|
+
});
|
|
10
|
+
for (const tag of ["div", "span", "ul", "ol", "li", "section", "nav", "header", "footer", "form"]) {
|
|
11
|
+
it(`as="${tag}" renderiza <${tag}> e só ele`, () => {
|
|
12
|
+
const { container } = render(_jsx(Box, { as: tag, children: "x" }));
|
|
13
|
+
expect(container.firstElementChild?.tagName).toBe(tag.toUpperCase());
|
|
14
|
+
expect(container.children).toHaveLength(1);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
it("ul e ol mantêm a semântica de lista (role=list)", () => {
|
|
18
|
+
render(_jsxs(_Fragment, { children: [_jsx(Box, { as: "ul", "aria-label": "Itens", children: _jsx(Box, { as: "li", children: "a" }) }), _jsx(Box, { as: "ol", "aria-label": "Passos", children: _jsx(Box, { as: "li", children: "b" }) })] }));
|
|
19
|
+
expect(screen.getByRole("list", { name: "Itens" }).tagName).toBe("UL");
|
|
20
|
+
expect(screen.getByRole("list", { name: "Passos" }).tagName).toBe("OL");
|
|
21
|
+
});
|
|
22
|
+
it("nav com aria-label vira região de navegação nomeada", () => {
|
|
23
|
+
render(_jsx(Box, { as: "nav", "aria-label": "Atalhos", children: "x" }));
|
|
24
|
+
expect(screen.getByRole("navigation", { name: "Atalhos" })).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
it("as=form chama onSubmit", () => {
|
|
27
|
+
const aoEnviar = vi.fn((e) => e.preventDefault());
|
|
28
|
+
const { container } = render(_jsx(Box, { as: "form", onSubmit: aoEnviar, children: _jsx("button", { type: "submit", children: "Enviar" }) }));
|
|
29
|
+
fireEvent.submit(container.querySelector("form"));
|
|
30
|
+
expect(aoEnviar).toHaveBeenCalledTimes(1);
|
|
31
|
+
});
|
|
32
|
+
it("escreve as classes de item flex", () => {
|
|
33
|
+
const { container } = render(_jsx(Box, { grow: true, shrink: "0", basis: "50", minWidth: "auto", overflow: "hidden", overflowX: "auto", overflowY: "scroll", fullHeight: true, fullWidth: true, children: "x" }));
|
|
34
|
+
const el = container.firstElementChild;
|
|
35
|
+
for (const c of [
|
|
36
|
+
"umds-box--grow",
|
|
37
|
+
"umds-box--shrink-0",
|
|
38
|
+
"umds-box--basis-50",
|
|
39
|
+
"umds-box--min-w-auto",
|
|
40
|
+
"umds-box--overflow-hidden",
|
|
41
|
+
"umds-box--overflow-x-auto",
|
|
42
|
+
"umds-box--overflow-y-scroll",
|
|
43
|
+
"umds-box--full-height",
|
|
44
|
+
"umds-box--full",
|
|
45
|
+
]) {
|
|
46
|
+
expect(el).toHaveClass(c);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
it("sem as props de item não escreve nenhuma classe delas", () => {
|
|
50
|
+
const { container } = render(_jsx(Box, { padding: "md", children: "x" }));
|
|
51
|
+
const classes = container.firstElementChild.className;
|
|
52
|
+
expect(classes).not.toMatch(/grow|shrink|basis|min-w|overflow|full-height/);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import Box from "../components/Box/Box";
|
|
5
|
+
describe("Box de layout", () => {
|
|
6
|
+
it("sem props de layout não vira flex", () => {
|
|
7
|
+
const { container } = render(_jsx(Box, { padding: "md", bordered: true, children: "x" }));
|
|
8
|
+
expect(container.firstElementChild).not.toHaveClass("umds-box--flex");
|
|
9
|
+
});
|
|
10
|
+
it("com direction, gap, align, justify e wrap vira flex", () => {
|
|
11
|
+
const { container } = render(_jsx(Box, { direction: "horizontal", gap: "xxxs", align: "center", justify: "between", wrap: true, padding: "md", children: "x" }));
|
|
12
|
+
const el = container.firstElementChild;
|
|
13
|
+
for (const c of [
|
|
14
|
+
"umds-box--flex",
|
|
15
|
+
"umds-box--horizontal",
|
|
16
|
+
"umds-box--gap-xxxs",
|
|
17
|
+
"umds-box--align-center",
|
|
18
|
+
"umds-box--justify-between",
|
|
19
|
+
"umds-box--wrap",
|
|
20
|
+
"umds-box--p-md",
|
|
21
|
+
]) {
|
|
22
|
+
expect(el).toHaveClass(c);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
it("só com gap vira flex vertical", () => {
|
|
26
|
+
const { container } = render(_jsx(Box, { gap: "xs", children: "x" }));
|
|
27
|
+
expect(container.firstElementChild).toHaveClass("umds-box--flex", "umds-box--vertical");
|
|
28
|
+
});
|
|
29
|
+
it("repassa id, role, aria-label e style", () => {
|
|
30
|
+
render(_jsx(Box, { id: "r", role: "region", "aria-label": "Resumo", style: { marginTop: 4 }, children: "x" }));
|
|
31
|
+
const el = screen.getByRole("region", { name: "Resumo" });
|
|
32
|
+
expect(el.id).toBe("r");
|
|
33
|
+
expect(el.style.marginTop).toBe("4px");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
|
5
|
+
import Button from "../components/Button/Button";
|
|
6
|
+
describe("Button: variante neutral-text e tamanho xs", () => {
|
|
7
|
+
it("neutral-text escreve a classe da variante", () => {
|
|
8
|
+
render(_jsx(Button, { variant: "neutral-text", children: "Simular" }));
|
|
9
|
+
expect(screen.getByRole("button", { name: "Simular" })).toHaveClass("umds-button--neutral-text");
|
|
10
|
+
});
|
|
11
|
+
it("neutral continua sendo o contornado cinza", () => {
|
|
12
|
+
render(_jsx(Button, { variant: "neutral", children: "Ordenar" }));
|
|
13
|
+
const botao = screen.getByRole("button", { name: "Ordenar" });
|
|
14
|
+
expect(botao).toHaveClass("umds-button--neutral");
|
|
15
|
+
expect(botao).not.toHaveClass("umds-button--neutral-text");
|
|
16
|
+
});
|
|
17
|
+
it("size xs escreve a classe e o botão sem size continua md", () => {
|
|
18
|
+
render(_jsxs(_Fragment, { children: [_jsx(Button, { size: "xs", children: "Resolver" }), _jsx(Button, { children: "Padr\u00E3o" })] }));
|
|
19
|
+
expect(screen.getByRole("button", { name: "Resolver" })).toHaveClass("umds-button--xs");
|
|
20
|
+
expect(screen.getByRole("button", { name: "Padrão" })).toHaveClass("umds-button--md");
|
|
21
|
+
});
|
|
22
|
+
it("no xs o ícone usa o tamanho sm do Icon (o CSS do botão o reduz)", () => {
|
|
23
|
+
const { container } = render(_jsx(Button, { size: "xs", startIcon: faPlus, children: "Novo" }));
|
|
24
|
+
expect(container.querySelector(".umds-icon")).toHaveClass("umds-icon--sm");
|
|
25
|
+
expect(container.querySelector(".umds-icon--xs")).toBeNull();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|