@cccsaurora/howler-ui 3.2.0-dev.1783.1 → 3.2.0-dev.1786.1
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.
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/// <reference types="vitest" />
|
|
3
|
+
import { createTheme, ThemeProvider } from '@mui/material';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
6
|
const mockUseMediaQuery = vi.hoisted(() => vi.fn(() => false));
|
|
6
7
|
const mockAppUser = vi.hoisted(() => ({ user: { is_admin: true } }));
|
|
7
8
|
const mockLocation = vi.hoisted(() => ({ hash: '#overview' }));
|
|
9
|
+
const mockAppBar = vi.hoisted(() => ({ autoHide: false }));
|
|
10
|
+
const mockAppLayout = vi.hoisted(() => ({ current: 'side' }));
|
|
8
11
|
vi.mock('@mui/material', async (importOriginal) => {
|
|
9
12
|
const actual = await importOriginal();
|
|
10
13
|
return {
|
|
@@ -13,9 +16,9 @@ vi.mock('@mui/material', async (importOriginal) => {
|
|
|
13
16
|
};
|
|
14
17
|
});
|
|
15
18
|
vi.mock('@tui/core', () => ({
|
|
16
|
-
PageCenter: ({ children }) => _jsx("div", { children: children }),
|
|
17
|
-
useAppBar: () =>
|
|
18
|
-
useAppLayout: () =>
|
|
19
|
+
PageCenter: ({ children, className }) => (_jsx("div", { className: className, children: children })),
|
|
20
|
+
useAppBar: () => mockAppBar,
|
|
21
|
+
useAppLayout: () => mockAppLayout,
|
|
19
22
|
useAppUser: () => mockAppUser
|
|
20
23
|
}));
|
|
21
24
|
vi.mock('components/hooks/useScrollRestoration', () => ({
|
|
@@ -43,7 +46,12 @@ const config = {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
};
|
|
49
|
+
const documentationWithSpacing = (spacing) => (_jsx(ThemeProvider, { theme: createTheme({ spacing }), children: _jsx(ApiConfigContext.Provider, { value: { config }, children: _jsx(SearchDocumentation, {}) }) }));
|
|
46
50
|
describe('SearchDocumentation', () => {
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
mockAppBar.autoHide = false;
|
|
53
|
+
mockAppLayout.current = 'side';
|
|
54
|
+
});
|
|
47
55
|
it('returns nothing when indexes are unavailable', () => {
|
|
48
56
|
const { container } = render(_jsx(ApiConfigContext.Provider, { value: { config: {} }, children: _jsx(SearchDocumentation, {}) }));
|
|
49
57
|
expect(container).toBeEmptyDOMElement();
|
|
@@ -62,4 +70,39 @@ describe('SearchDocumentation', () => {
|
|
|
62
70
|
expect(screen.getAllByText('ranges').length).toBeGreaterThan(0);
|
|
63
71
|
expect(screen.getAllByText('reserved').length).toBeGreaterThan(0);
|
|
64
72
|
});
|
|
73
|
+
it.each([
|
|
74
|
+
{ density: 'default', spacing: 8 },
|
|
75
|
+
{ density: 'compact', spacing: 6 },
|
|
76
|
+
{ density: 'dense', spacing: 4 }
|
|
77
|
+
])('keeps section spacing positive at $density density', ({ spacing }) => {
|
|
78
|
+
const { container } = render(documentationWithSpacing(spacing));
|
|
79
|
+
const paragraphs = container.querySelectorAll('.paragraph');
|
|
80
|
+
expect(paragraphs.length).toBeGreaterThan(0);
|
|
81
|
+
paragraphs.forEach(paragraph => {
|
|
82
|
+
const spacer = paragraph.querySelector('.spacer');
|
|
83
|
+
expect(paragraph).toHaveStyle({ marginTop: `${-12 * spacing}px` });
|
|
84
|
+
expect(spacer).toHaveStyle({ height: `${14 * spacing}px` });
|
|
85
|
+
expect(parseFloat(getComputedStyle(paragraph).marginTop) + parseFloat(getComputedStyle(spacer).height)).toBe(2 * spacing);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it('updates section offsets when density changes without remounting', () => {
|
|
89
|
+
const { container, rerender } = render(documentationWithSpacing(8));
|
|
90
|
+
const paragraph = container.querySelector('#overview');
|
|
91
|
+
expect(paragraph).toHaveStyle({ marginTop: '-96px' });
|
|
92
|
+
rerender(documentationWithSpacing(6));
|
|
93
|
+
expect(paragraph).toHaveStyle({ marginTop: '-72px' });
|
|
94
|
+
rerender(documentationWithSpacing(4));
|
|
95
|
+
expect(paragraph).toHaveStyle({ marginTop: '-48px' });
|
|
96
|
+
});
|
|
97
|
+
it.each([
|
|
98
|
+
{ layout: 'side', marginTop: '0px' },
|
|
99
|
+
{ layout: 'top', marginTop: '-48px' }
|
|
100
|
+
])('preserves auto-hide offsets in the $layout layout at dense density', ({ layout, marginTop }) => {
|
|
101
|
+
mockAppBar.autoHide = true;
|
|
102
|
+
mockAppLayout.current = layout;
|
|
103
|
+
const { container } = render(documentationWithSpacing(4));
|
|
104
|
+
const paragraph = container.querySelector('#overview');
|
|
105
|
+
expect(paragraph).toHaveStyle({ marginTop });
|
|
106
|
+
expect(paragraph.classList.contains('autoHide')).toBe(layout === 'side');
|
|
107
|
+
});
|
|
65
108
|
});
|
package/package.json
CHANGED