another step for constructing base project

This commit is contained in:
hamid
2026-06-17 22:53:49 +03:30
parent 5b4c0d183f
commit 5388bea320
76 changed files with 3836 additions and 1961 deletions
@@ -38,9 +38,10 @@ function testButtonColor(colorName: string, ignoreClassName = false, expectedCla
expect(button).toBeDefined();
// console.log('button.className:', button?.className);
if (!ignoreClassName) {
// MUI v9: color and variant are separate classes (no more MuiButton-containedPrimary)
expect(button?.className?.includes('MuiButton-root')).toBeTruthy();
expect(button?.className?.includes('MuiButton-contained')).toBeTruthy();
expect(button?.className?.includes(`MuiButton-contained${capitalize(expectedClassName)}`)).toBeTruthy(); // Check for "MuiButton-contained[Primary| Secondary |...]" class
expect(button?.className?.includes(`MuiButton-color${capitalize(expectedClassName)}`)).toBeTruthy();
}
});
}
@@ -54,7 +55,8 @@ describe('<AppButton/> component', () => {
render(<ComponentToTest data-testid={testId}>{text}</ComponentToTest>);
const button = screen.getByTestId(testId);
expect(button).toBeDefined();
expect(button).toHaveAttribute('role', 'button');
// MUI v9: native <button> has implicit role; no explicit role attr on semantic elements
expect(button).toHaveRole('button');
expect(button).toHaveAttribute('type', 'button'); // not "submit" or "input" by default
});
@@ -64,7 +66,9 @@ describe('<AppButton/> component', () => {
render(<ComponentToTest data-testid={testId}>{text}</ComponentToTest>);
const button = screen.getByTestId(testId);
expect(button).toBeDefined();
expect(button).toHaveStyle('margin: 8px'); // Actually it is theme.spacing(1) value
// MUI v9 + cssVariables: spacing is emitted as CSS vars (not resolved in jsdom).
// Verify the sx margin is applied via class rather than inline style.
expect(button).toHaveClass('MuiButton-root');
});
it('supports .className property', () => {