Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import { expect } from 'chai';
|
|
import sinon from 'sinon';
|
|
import { getMaterialUiComponentInfo } from './getMaterialUiComponentInfo';
|
|
|
|
describe('getMaterialUiComponentInfo', () => {
|
|
it('return correct info for material component file', () => {
|
|
const componentInfo = getMaterialUiComponentInfo(
|
|
path.join(process.cwd(), `/packages/mui-material/src/Button/Button.js`),
|
|
);
|
|
sinon.assert.match(componentInfo, {
|
|
name: 'Button',
|
|
apiPathname: '/material-ui/api/button/',
|
|
muiName: 'MuiButton',
|
|
apiPagesDirectory: sinon.match((value) =>
|
|
value.endsWith(path.join('docs', 'pages', 'material-ui', 'api')),
|
|
),
|
|
});
|
|
|
|
expect(componentInfo.getInheritance('ButtonBase')).to.deep.equal({
|
|
name: 'ButtonBase',
|
|
apiPathname: '/material-ui/api/button-base/',
|
|
});
|
|
|
|
let existed = false;
|
|
try {
|
|
fs.readdirSync(path.join(process.cwd(), 'docs/data'));
|
|
existed = true;
|
|
// eslint-disable-next-line no-empty
|
|
} catch (error) {}
|
|
if (existed) {
|
|
const demos = componentInfo.getDemos();
|
|
expect(demos).to.not.have.lengthOf(0);
|
|
|
|
expect(demos[0]).to.deep.include({
|
|
demoPageTitle: 'Button Group',
|
|
demoPathname: '/material-ui/react-button-group/',
|
|
});
|
|
expect(demos[0].filePath).to.include('button-group/button-group.md');
|
|
|
|
expect(demos[1]).to.deep.include({
|
|
demoPageTitle: 'Button',
|
|
demoPathname: '/material-ui/react-button/',
|
|
});
|
|
expect(demos[1].filePath).to.include('buttons/buttons.md');
|
|
}
|
|
});
|
|
});
|