Skip to content

Commit

Permalink
test: update data loading test
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 7, 2021
1 parent ad17804 commit d029ef7
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 35 deletions.
146 changes: 112 additions & 34 deletions plugins/cc-cli/test/__snapshots__/cli-document-data.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,136 @@

exports[`cli-document-data create cjs document 1`] = `
Object {
"VariantButton.data.js": "module.exports = {
"Popover.data.js": "module.exports = {
overview: {
'0': {
text: 'Gisselle Mohr',
icon: 'Kaden Powlowski',
fontSize: 12,
placement: 'bottom-end',
trigger: 'hover',
},
'1': {
text: 'Barbara Brakus',
icon: 'Miss Dolly Ferry',
fontSize: 22,
placement: 'top-end',
trigger: 'hover',
},
'2': {
placement: 'bottom-end',
trigger: 'click',
},
'3': {
placement: 'right-end',
trigger: 'hover',
},
'4': {
placement: 'auto-start',
trigger: 'right-click',
},
},
};
",
"Popover.test.js": "const path = require('path');
const { run } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
require('@component-controls/jest-axe-matcher');
const { loadConfigurations } = require('@component-controls/config');
const { renderDocument } = require('@component-controls/test-renderers');
const { render, act } = require('@testing-library/react');
const { renderErr } = require('@component-controls/test-renderers');
const examples = require('../../../../ui/components/src/Popover/Popover.stories');
const data = require('./Popover.data');
describe('Popover', () => {
const configPath = path.resolve(
__dirname,
'../../../../ui/components/.config',
);
const config = loadConfigurations(configPath);
let renderedExamples = [];
act(() => {
renderedExamples = renderDocument(examples, config, data);
});
if (!renderedExamples) {
renderErr();
return;
}
renderedExamples.forEach(({ name, rendered, dataId, values }) => {
describe(name, () => {
const runTests = () => {
it('snapshot', () => {
const { asFragment } = render(rendered);
expect(asFragment()).toMatchSnapshot();
});
it('accessibility', async () => {
const axeResults = await reactRunDOM(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
};
if (values) {
describe(dataId, runTests);
} else {
runTests();
}
});
});
});
",
}
`;

exports[`cli-document-data create cjs document 2`] = `
Object {
"VariantButton.data.js": "module.exports = {
overview: {
'0': {
text: 'Bart Bechtelar',
icon: 'Dayana Roob',
fontSize: 22,
},
'1': {
text: 'Adah Nolan',
icon: 'Anais Pagac',
fontSize: 22,
},
'3': {
'2': {
text: 'Jon Will',
icon: 'Geraldine Metz',
fontSize: 20,
},
'4': {
'3': {
text: 'Mr. Dulce Rice',
icon: 'Karianne Bins',
fontSize: 16,
},
'5': {
'4': {
text: 'Mrs. Jermey Jacobson',
icon: 'Mikayla Gusikowski',
fontSize: 29,
},
'6': {
'5': {
text: 'Clark Hickle',
icon: 'Marielle Durgan',
fontSize: 16,
},
'7': {
'6': {
text: 'Ibrahim Purdy',
icon: 'Cullen Heller',
fontSize: 27,
},
'8': {
'7': {
text: 'Jody Legros',
icon: 'Dedric Smitham',
fontSize: 16,
},
'9': {
'8': {
text: 'Ford Kunze',
icon: 'Trinity Hickle',
fontSize: 12,
},
'9': {
text: 'Ms. Mariah Pollich',
icon: 'Kenny Mueller',
fontSize: 26,
},
},
};
",
Expand Down Expand Up @@ -110,15 +188,15 @@ Object {
"VariantButton.data.ts": "export default {
overview: {
'0': {
text: 'Jonas Kihn',
icon: 'Sandrine Pagac',
fontSize: 12,
},
'1': {
text: 'Hugh Lockman',
icon: 'Ansel Nicolas',
fontSize: 14,
},
'1': {
text: 'Mohamed Bins',
icon: 'Consuelo Sipes',
fontSize: 24,
},
},
};
",
Expand Down Expand Up @@ -170,15 +248,15 @@ Object {
"VariantButton.data.js": "export default {
overview: {
'0': {
text: 'Ms. Mariah Pollich',
icon: 'Kenny Mueller',
fontSize: 26,
},
'1': {
text: 'Dorothea Tremblay',
icon: 'Juliet Harber',
fontSize: 32,
},
'1': {
text: 'Alana Kunde',
icon: 'Alexys Cartwright',
fontSize: 29,
},
},
};
",
Expand Down Expand Up @@ -234,15 +312,15 @@ Object {
"VariantButton.data.ts": "export default {
overview: {
'0': {
text: 'Emilia Feeney',
icon: 'Gage Dicki',
fontSize: 19,
},
'1': {
text: 'Alexa Feest',
icon: 'Mozelle Murphy',
fontSize: 25,
},
'1': {
text: 'Jonas Kihn',
icon: 'Sandrine Pagac',
fontSize: 12,
},
},
};
",
Expand Down Expand Up @@ -302,15 +380,15 @@ Object {
"VariantButton.data.ts": "export default {
overview: {
'0': {
text: 'Alana Kunde',
icon: 'Alexys Cartwright',
fontSize: 29,
},
'1': {
text: 'Dawn Gerlach DDS',
icon: 'Nasir Cassin',
fontSize: 14,
},
'1': {
text: 'Emilia Feeney',
icon: 'Gage Dicki',
fontSize: 19,
},
},
};
",
Expand Down
1 change: 0 additions & 1 deletion plugins/cc-cli/test/cli-document-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('cli-document-data', () => {
'-i',
'Popover',
]);
return;
runTests('create cjs document', ['-g', 'doc', '-f', 'cjs', '-d', '10']);
runTests('create esm document', ['-g', 'doc', '-f', 'esm', '-d', '2']);
runTests('create typescript document', ['-g', 'doc', '-f', 'ts', '-d', '2']);
Expand Down

0 comments on commit d029ef7

Please sign in to comment.