Skip to content

Commit

Permalink
fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jul 30, 2024
1 parent 36ec12e commit 2603b25
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/mui-lab/src/Masonry/Masonry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('<Masonry />', () => {
}),
);

const theme = createTheme({ spacing: 8 });
const theme = createTheme({ cssVariables: false, spacing: 8 });
const maxColumnHeight = 100;

describe('render', () => {
Expand Down
16 changes: 7 additions & 9 deletions packages/mui-material/src/Drawer/Drawer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect } from 'chai';
import { spy } from 'sinon';
import { createRenderer, screen } from '@mui/internal-test-utils';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import defaultTheme from '@mui/material/styles/defaultTheme';
import Drawer, { drawerClasses as classes } from '@mui/material/Drawer';
import { getAnchor, isHorizontal } from './Drawer';
import describeConformance from '../../test/describeConformance';
Expand Down Expand Up @@ -37,8 +38,8 @@ describe('<Drawer />', () => {
if (/jsdom/.test(window.navigator.userAgent)) {
this.skip();
}
const theme = createTheme();
const enteringScreenDurationInSeconds = theme.transitions.duration.enteringScreen / 1000;
const enteringScreenDurationInSeconds =
defaultTheme.transitions.duration.enteringScreen / 1000;
render(
<Drawer open>
<div />
Expand Down Expand Up @@ -321,16 +322,13 @@ describe('<Drawer />', () => {

describe('zIndex', () => {
it('should set correct zIndex on the root element', () => {
const theme = createTheme();
render(
<ThemeProvider theme={theme}>
<Drawer open>
<div />
</Drawer>
</ThemeProvider>,
<Drawer open>
<div />
</Drawer>,
);
expect(document.querySelector(`.${classes.root}`)).toHaveComputedStyle({
zIndex: String(theme.zIndex.drawer),
zIndex: String(defaultTheme.zIndex.drawer),
});
});
});
Expand Down
21 changes: 13 additions & 8 deletions packages/mui-material/src/Grid/Grid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,13 @@ describe('Material UI <Grid />', () => {
});

it('should generate correct responsive styles regardless of breakpoints order', () => {
const theme = createTheme();
expect(
generateDirection({
ownerState: {
container: true,
direction: { sm: 'column', xs: 'row' },
},
theme,
theme: defaultTheme,
}),
).to.deep.equal({
'@media (min-width:0px)': {
Expand Down Expand Up @@ -210,6 +209,7 @@ describe('Material UI <Grid />', () => {

it('should generate correct responsive styles regardless of custom breakpoints order', () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -713,14 +713,13 @@ describe('Material UI <Grid />', () => {

describe('prop: rowSpacing, columnSpacing', () => {
it('should generate correct responsive styles', () => {
const theme = createTheme();
expect(
generateRowGap({
ownerState: {
container: true,
rowSpacing: { xs: 1, sm: 2 },
},
theme,
theme: defaultTheme,
}),
).to.deep.equal({
'@media (min-width:0px)': {
Expand All @@ -743,7 +742,7 @@ describe('Material UI <Grid />', () => {
container: true,
columnSpacing: { xs: 1, sm: 2 },
},
theme,
theme: defaultTheme,
}),
).to.deep.equal({
'@media (min-width:0px)': {
Expand All @@ -765,6 +764,7 @@ describe('Material UI <Grid />', () => {

it('should support custom breakpoints and generate correct responsive styles', () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -824,6 +824,7 @@ describe('Material UI <Grid />', () => {

it("shouldn't support custom breakpoints with values of zeros and shouldn't generate responsive styles", () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -872,6 +873,7 @@ describe('Material UI <Grid />', () => {

it("shouldn't support custom breakpoints without its spacing values and shouldn't generate responsive styles", () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -918,6 +920,7 @@ describe('Material UI <Grid />', () => {

it("should ignore custom breakpoints that doesn't exist in the theme and shouldn't generate responsive styles", () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -963,14 +966,13 @@ describe('Material UI <Grid />', () => {
});

it('should generate correct responsive styles regardless of breakpoints order ', () => {
const theme = createTheme();
expect(
generateRowGap({
ownerState: {
container: true,
rowSpacing: { sm: 2, xs: 1 },
},
theme,
theme: defaultTheme,
}),
).to.deep.equal({
'@media (min-width:0px)': {
Expand All @@ -993,7 +995,7 @@ describe('Material UI <Grid />', () => {
container: true,
columnSpacing: { sm: 2, xs: 1 },
},
theme,
theme: defaultTheme,
}),
).to.deep.equal({
'@media (min-width:0px)': {
Expand All @@ -1015,6 +1017,7 @@ describe('Material UI <Grid />', () => {

it('should generate correct responsive styles regardless of custom breakpoints order ', () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
keys: ['mobile', 'desktop'],
values: {
Expand Down Expand Up @@ -1074,6 +1077,7 @@ describe('Material UI <Grid />', () => {

it('should generate correct responsive styles for overriding with zero value styles for higher breakpoints', () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
values: {
mobile: 0,
Expand Down Expand Up @@ -1208,6 +1212,7 @@ describe('Material UI <Grid />', () => {

it('should not generate responsive styles for lower breakpoints below a given non-zero breakpoint', () => {
const theme = createTheme({
cssVariables: false,
breakpoints: {
values: {
mobile: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Link/getTextDecoration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import getTextDecoration from './getTextDecoration';

describe('getTextDecoration', () => {
describe('without theme.vars', () => {
const theme = createTheme();
const theme = createTheme({ cssVariables: false });

it('deprecated color', () => {
expect(getTextDecoration({ theme, ownerState: { color: 'textPrimary' } })).to.equal(
Expand Down
3 changes: 3 additions & 0 deletions packages/mui-material/src/styles/styled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('styled', () => {
`;

const theme = createTheme({
cssVariables: false,
spacing: 10,
});

Expand All @@ -82,6 +83,7 @@ describe('styled', () => {
}));

const theme = createTheme({
cssVariables: false,
spacing: 10,
});

Expand Down Expand Up @@ -140,6 +142,7 @@ describe('styled', () => {

before(() => {
theme = createTheme({
cssVariables: false,
palette: {
primary: {
main: 'rgb(0, 0, 255)',
Expand Down
1 change: 1 addition & 0 deletions packages/mui-styles/test/theme-scoping.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('Theme scoping', () => {
<material.ThemeProvider
theme={{
[material.THEME_ID]: material.createTheme({
cssVariables: false,
palette: {
divider: 'darken',
},
Expand Down
8 changes: 6 additions & 2 deletions packages/mui-system/src/cssVars/createCssVarsProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ describe('createCssVarsProvider', () => {
describe('[option]: `disableTransitionOnChange`', () => {
clock.withFakeTimers();

beforeEach(() => {
document.head.replaceChildren([]);
});

it('disable all css transitions when switching between modes, given `disableTransitionOnChange` is true', () => {
const { CssVarsProvider, useColorScheme } = createCssVarsProvider({
theme: createCssVarsTheme({
Expand All @@ -268,7 +272,7 @@ describe('createCssVarsProvider', () => {
<Consumer />
</CssVarsProvider>,
);

clock.runToLast();
expect(document.head.children[document.head.children.length - 1]?.textContent).not.to.equal(
DISABLE_CSS_TRANSITION,
);
Expand Down Expand Up @@ -309,7 +313,7 @@ describe('createCssVarsProvider', () => {
<Consumer />
</CssVarsProvider>,
);

clock.runToLast();
expect(document.head.children[document.head.children.length - 1]?.textContent).not.to.equal(
DISABLE_CSS_TRANSITION,
);
Expand Down

0 comments on commit 2603b25

Please sign in to comment.