Skip to content

Commit

Permalink
Revert test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JCQuintas committed Nov 5, 2024
1 parent 9aafe1d commit ef00405
Show file tree
Hide file tree
Showing 73 changed files with 303 additions and 449 deletions.
2 changes: 1 addition & 1 deletion apps/pigment-css-vite-app/src/pages/fixtures/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function main() {
it(`creates screenshots of ${route}`, async function test() {
// With the playwright inspector we might want to call `page.pause` which would lead to a timeout.
if (process.env.PWDEBUG) {
this?.timeout?.(0);
this.timeout(0);
}

const testcase = await renderFixture(index);
Expand Down
4 changes: 0 additions & 4 deletions packages-internal/babel-plugin-minify-errors/vitest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages-internal/scripts/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"noEmit": true
},
"include": ["./**/*.ts"],
"exclude": ["./build", "./node_modules", "vitest.config.ts"],
"exclude": ["./build", "./node_modules"],
"references": [{ "path": "../../packages-internal/docs-utils/tsconfig.build.json" }]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('typescript-to-proptypes', () => {

before(function beforeHook() {
// Creating a TS program might take a while.
this?.timeout?.(20000);
this.timeout(20000);

const buildProject = createTypeScriptProjectBuilder({
test: {
Expand Down
4 changes: 0 additions & 4 deletions packages-internal/scripts/vitest.config.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/api-docs-builder-core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
rules: {
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',
},
};
2 changes: 1 addition & 1 deletion packages/api-docs-builder-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"types": ["node", "mocha"]
},
"include": ["./**/*.ts", "./**/*.js"],
"exclude": ["node_modules", "vitest.config.ts"]
"exclude": ["node_modules"]
}
4 changes: 0 additions & 4 deletions packages/api-docs-builder-core/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/api-docs-builder/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/eslint-plugin-material-ui/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/markdown/vitest.config.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/mui-base/src/Dropdown/Dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('<Dropdown />', () => {
it('registers a popup id correctly', async () => {
function TestComponent() {
const { registerPopup, popupId } = React.useContext(DropdownContext)!;
expect(context).not.to.equal(null);

React.useEffect(() => {
registerPopup('test-popup');
Expand All @@ -53,6 +54,7 @@ describe('<Dropdown />', () => {

function TestComponent() {
const { registerTrigger, triggerElement } = React.useContext(DropdownContext)!;
expect(context).not.to.equal(null);

React.useEffect(() => {
registerTrigger(trigger);
Expand Down
29 changes: 14 additions & 15 deletions packages/mui-base/src/Transitions/CssTransition.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@ describe('CssTransition', () => {
onExitedSpy.resetHistory();
});

const { render, clock } = createRenderer({ clock: 'fake' });
const { render, clock } = createRenderer();

describe('prop: className', () => {
it('applies it unconditionally', () => {
const { getByTestId } = render(
<TestTransitionContextProvider requestEnter>
<CssTransition className="foo" data-testid="root" />
</TestTransitionContextProvider>,
);
const root = getByTestId('root');
expect(root).to.have.class('foo');
});
});

describe('prop: enterClassName, exitClassName', () => {
clock.withFakeTimers();
Expand All @@ -53,7 +65,7 @@ describe('CssTransition', () => {
clock.runToLast();
});

it('applies exitClassName, then immediately enterClassName when requested to enter', async () => {
it('applies exitClassName, then immediately enterClassName when requested to enter', () => {
const { getByTestId } = render(
<TestTransitionContextProvider requestEnter>
<CssTransition enterClassName="enter" exitClassName="exit" data-testid="root" />
Expand All @@ -67,21 +79,8 @@ describe('CssTransition', () => {
expect(root).not.to.have.class('enter');

clock.runToLast();

expect(root).to.have.class('enter');
expect(root).not.to.have.class('exit');
});
});

describe('prop: className', () => {
it('applies it unconditionally', () => {
const { getByTestId } = render(
<TestTransitionContextProvider requestEnter>
<CssTransition className="foo" data-testid="root" />
</TestTransitionContextProvider>,
);
const root = getByTestId('root');
expect(root).to.have.class('foo');
});
});
});
10 changes: 4 additions & 6 deletions packages/mui-base/src/useList/useList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ import { EventHandlers } from '../utils/types';
const EMPTY_OBJECT = {};
const NOOP = () => {};

function defaultItemComparer<ItemValue>(optionA: ItemValue, optionB: ItemValue) {
return optionA === optionB;
}
const defaultItemComparer = <ItemValue>(optionA: ItemValue, optionB: ItemValue) =>
optionA === optionB;

const defaultIsItemDisabled = () => false;

function defaultItemStringifier<ItemValue>(item: ItemValue) {
return typeof item === 'string' ? item : String(item);
}
const defaultItemStringifier = <ItemValue>(item: ItemValue) =>
typeof item === 'string' ? item : String(item);

const defaultGetInitialState = () => ({
highlightedValue: null,
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/useSelect/defaultOptionStringifier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SelectOption } from '../useOption';

function defaultOptionStringifier<OptionValue>(option: SelectOption<OptionValue>) {
const defaultOptionStringifier = <OptionValue>(option: SelectOption<OptionValue>) => {
const { label, value } = option;
if (typeof label === 'string') {
return label;
Expand All @@ -12,6 +12,6 @@ function defaultOptionStringifier<OptionValue>(option: SelectOption<OptionValue>

// Fallback string representation
return String(option);
}
};

export { defaultOptionStringifier };
4 changes: 0 additions & 4 deletions packages/mui-base/vitest.config.ts

This file was deleted.

5 changes: 1 addition & 4 deletions packages/mui-codemod/src/v4.0.0/top-level-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ export default function transformer(fileInfo, api, options) {
let requirePath = importModule;

if (process.env.NODE_ENV === 'test') {
requirePath = requirePath.replace(
/^@material-ui\/core/,
process.env.VITEST ? '@mui/material' : '../../../mui-material/src',
);
requirePath = requirePath.replace(/^@material-ui\/core/, '../../../mui-material/src');
}

// eslint-disable-next-line global-require, import/no-dynamic-require
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-codemod/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/mui-docs/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/mui-envinfo/vitest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/mui-icons-material/builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fileURLToPath } from 'url';
import intersection from 'lodash/intersection.js';
import { Queue } from '@mui/internal-waterfall';

const currentDirectory = path.dirname(fileURLToPath(new URL(import.meta.url)));
const currentDirectory = fileURLToPath(new URL('.', import.meta.url));

export const RENAME_FILTER_DEFAULT = './renameFilters/default.mjs';
export const RENAME_FILTER_MUI = './renameFilters/material-design-icons.mjs';
Expand Down
95 changes: 28 additions & 67 deletions packages/mui-icons-material/builder.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
import fse from 'fs-extra';
import { RENAME_FILTER_MUI, RENAME_FILTER_DEFAULT, getComponentName, handler } from './builder.mjs';

const currentDirectory = path.dirname(fileURLToPath(new URL(import.meta.url)));
const currentDirectory = fileURLToPath(new URL('.', import.meta.url));

const DISABLE_LOG = true;

Expand Down Expand Up @@ -43,28 +43,15 @@ describe('builder', () => {
outputDir: null,
};

// eslint-disable-next-line mocha/handle-done-callback
beforeEach(
process.env.VITEST
? async function beforeEachHook(ctx) {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
ctx.task.name,
);
await fse.emptyDir(options.outputDir);
}
: async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
},
);
beforeEach(async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
});

it('script outputs to directory', async () => {
await handler(options);
Expand All @@ -83,28 +70,15 @@ describe('builder', () => {
outputDir: null,
};

// eslint-disable-next-line mocha/handle-done-callback
beforeEach(
process.env.VITEST
? async function beforeEachHook(ctx) {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
ctx.task.name,
);
await fse.emptyDir(options.outputDir);
}
: async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
},
);
beforeEach(async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
});

it('script outputs to directory', async () => {
await handler(options);
Expand Down Expand Up @@ -137,28 +111,15 @@ describe('builder', () => {
outputDir: null,
};

// eslint-disable-next-line mocha/handle-done-callback
beforeEach(
process.env.VITEST
? async function beforeEachHook(ctx) {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
ctx.task.name,
);
await fse.emptyDir(options.outputDir);
}
: async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
},
);
beforeEach(async function beforeEachHook() {
// DON'T CLEAN UP TO MAKE TEST INSPECTABLE
options.outputDir = path.join(
os.tmpdir(),
'material-ui-icons-builder-test',
this.currentTest.fullTitle(),
);
await fse.emptyDir(options.outputDir);
});

it('should produce the expected output', async () => {
await handler(options);
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-icons-material/vitest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ describe('Joy <Autocomplete />', () => {
it('should ignore keydown event until the IME is confirmed', function test() {
// TODO: Often times out in Firefox 78.
// Is this slow because of testing-library or because of the implementation?
this?.timeout?.(4000);
this.timeout(4000);

const { getByRole } = render(<Autocomplete open options={['가1', '가2']} autoFocus />);
const textbox = getByRole('combobox');
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-joy/src/CssBaseline/CssBaseline.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
describe('<CssBaseline />', () => {
it('To do', () => {});
});
describe('<CssBaseline />', () => {});
4 changes: 1 addition & 3 deletions packages/mui-joy/src/Option/Option.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
describe('<Option />', () => {
it('To do', () => {});
});
describe('<Option />', () => {});
2 changes: 1 addition & 1 deletion packages/mui-joy/src/styles/CssVarsProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('[Joy] CssVarsProvider', () => {
beforeEach(() => {
originalMatchmedia = window.matchMedia;
// Create mocks of localStorage getItem and setItem functions
Object.defineProperty(globalThis, 'localStorage', {
Object.defineProperty(global, 'localStorage', {
value: {
getItem: (key: string) => storage[key],
setItem: (key: string, value: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-joy/src/styles/extendTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('extendTheme', () => {
beforeEach(() => {
originalMatchmedia = window.matchMedia;
// Create mocks of localStorage getItem and setItem functions
Object.defineProperty(globalThis, 'localStorage', {
Object.defineProperty(global, 'localStorage', {
value: {
getItem: (key) => storage[key],
setItem: (key, value) => {
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-joy/vitest.config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/mui-lab/src/AlertTitle/AlertTitle.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/mui-lab/vitest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/mui-material-nextjs/vitest.config.ts

This file was deleted.

Loading

0 comments on commit ef00405

Please sign in to comment.