Skip to content

Commit

Permalink
fix: typescript imports
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 26, 2021
1 parent f58f4ae commit c33643c
Show file tree
Hide file tree
Showing 19 changed files with 944 additions and 841 deletions.
4 changes: 2 additions & 2 deletions plugins/cc-cli/templates/accessibility/import/import.ts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`enzyme bundle ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadStore } from '@component-controls/store';
import { mount, configure } from 'enzyme';
Expand All @@ -12,12 +13,12 @@ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
configure({ adapter: new Adapter() });
describe('Components/Header', () => {
const store = loadStore(
require(path.resolve(__dirname, './bundle/component-controls.js')),
);
const store = loadStore(require(path.resolve(__dirname, './bundle/component-controls.js')));
const renderFn = store.config.renderFn;
Object.keys(store.docs).forEach(docId => {
Object.keys(store.docs).forEach(docId => {
const doc = store.docs[docId];
if (doc.stories && doc.stories.length) {
const stories = doc.stories;
Expand All @@ -31,10 +32,11 @@ describe('Components/Header', () => {
expect(toJson(component, { mode: 'deep' })).toMatchSnapshot();
});
it('accessibility', async () => {
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
});
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
});
});
});
}
Expand Down
20 changes: 11 additions & 9 deletions plugins/cc-cli/test/__snapshots__/document-enzyme-ts.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`enzyme ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadConfigurations } from '@component-controls/config';
import { renderDocument } from '@component-controls/test-renderers';
Expand All @@ -16,15 +17,16 @@ configure({ adapter: new Adapter() });
import * as examples from './fixtures/VariantButton.docs';
describe('VariantButton', () => {
const configPath = path.resolve(__dirname, '.config');
const configPath = path.resolve(__dirname, '.config');
const config = loadConfigurations(configPath);
const renderedExamples = renderDocument(examples, config);
renderedExamples.forEach(({ name, rendered }) => {
it(name, async () => {
const component = mount(rendered);
expect(toJson(component, { mode: 'deep' })).toMatchSnapshot();
});
renderedExamples.forEach(({ name, rendered}) => {
it(name, async () => {
const component = mount(rendered);
expect(toJson(component, { mode: 'deep' })).toMatchSnapshot();
});
});
});
"
`;
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rtl bundle ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadStore } from '@component-controls/store';
import { render, act } from '@testing-library/react';
import { renderErr } from '@component-controls/test-renderers';
describe('Components/Header', () => {
const store = loadStore(
require(path.resolve(__dirname, './bundle/component-controls.js')),
);
const store = loadStore(require(path.resolve(__dirname, './bundle/component-controls.js')));
const renderFn = store.config.renderFn;
Object.keys(store.docs).forEach(docId => {
Object.keys(store.docs).forEach(docId => {
const doc = store.docs[docId];
if (doc.stories && doc.stories.length) {
const stories = doc.stories;
Expand All @@ -25,19 +26,20 @@ describe('Components/Header', () => {
let rendered;
act(() => {
rendered = renderFn(story, doc);
});
});
if (!rendered) {
renderErr();
return;
}
it('snapshot', () => {
const { asFragment } = render(rendered);
expect(asFragment()).toMatchSnapshot();
});
});
it('accessibility', async () => {
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
});
});
});
Expand Down
37 changes: 20 additions & 17 deletions plugins/cc-cli/test/__snapshots__/document-rtl-ts.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rtl ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadConfigurations } from '@component-controls/config';
import { renderDocument } from '@component-controls/test-renderers';
Expand All @@ -13,22 +14,24 @@ import { renderErr } from '@component-controls/test-renderers';
import * as examples from './fixtures/VariantButton.docs';
describe('VariantButton', () => {
const configPath = path.resolve(__dirname, '.config');
const configPath = path.resolve(__dirname, '.config');
const config = loadConfigurations(configPath);
let renderedExamples: ReturnType<typeof renderDocument> = [];
act(() => {
renderedExamples = renderDocument(examples, config);
});
if (!renderedExamples) {
renderErr();
return;
}
renderedExamples.forEach(({ name, rendered }) => {
it(name, async () => {
const { asFragment } = render(rendered);
expect(asFragment()).toMatchSnapshot();
});
let renderedExamples : ReturnType<typeof renderDocument> = [];
act(() => {
renderedExamples = renderDocument(examples, config);
});
if (!renderedExamples) {
renderErr();
return;
}
renderedExamples.forEach(({ name, rendered}) => {
it(name, async () => {
const { asFragment } = render(rendered);
expect(asFragment()).toMatchSnapshot();
});
});
});
"
`;
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rtr bundle ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadStore } from '@component-controls/store';
import renderer, { act } from 'react-test-renderer';
import { renderErr, componentErr } from '@component-controls/test-renderers';
describe('Components/Header', () => {
const store = loadStore(
require(path.resolve(__dirname, './bundle/component-controls.js')),
);
const store = loadStore(require(path.resolve(__dirname, './bundle/component-controls.js')));
const renderFn = store.config.renderFn;
Object.keys(store.docs).forEach(docId => {
Object.keys(store.docs).forEach(docId => {
const doc = store.docs[docId];
if (doc.stories && doc.stories.length) {
const stories = doc.stories;
Expand All @@ -25,7 +26,7 @@ describe('Components/Header', () => {
let rendered;
act(() => {
rendered = renderFn(story, doc);
});
});
if (!rendered) {
renderErr();
return;
Expand All @@ -35,13 +36,14 @@ describe('Components/Header', () => {
if (!component) {
componentErr();
return;
}
}
expect(component.toJSON()).toMatchSnapshot();
});
it('accessibility', async () => {
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
});
});
});
Expand Down
44 changes: 23 additions & 21 deletions plugins/cc-cli/test/__snapshots__/document-rtr-ts.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rtr ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadConfigurations } from '@component-controls/config';
import { renderDocument } from '@component-controls/test-renderers';
Expand All @@ -13,26 +14,27 @@ import { renderErr, componentErr } from '@component-controls/test-renderers';
import * as examples from './fixtures/VariantButton.docs';
describe('VariantButton', () => {
const configPath = path.resolve(__dirname, '.config');
const configPath = path.resolve(__dirname, '.config');
const config = loadConfigurations(configPath);
let renderedExamples: ReturnType<typeof renderDocument> = [];
act(() => {
renderedExamples = renderDocument(examples, config);
});
if (!renderedExamples.length) {
renderErr();
return;
}
renderedExamples.forEach(({ name, rendered }) => {
it(name, async () => {
const component = renderer.create(rendered);
if (!component) {
componentErr();
return;
}
expect(component.toJSON()).toMatchSnapshot();
});
let renderedExamples : ReturnType<typeof renderDocument> = [];
act(() => {
renderedExamples = renderDocument(examples, config);
});
if (!renderedExamples.length) {
renderErr();
return;
}
renderedExamples.forEach(({ name, rendered}) => {
it(name, async () => {
const component = renderer.create(rendered);
if (!component) {
componentErr();
return;
}
expect(component.toJSON()).toMatchSnapshot();
});
});
});
"
`;
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`enzyme bundle ts 1`] = `
"import * as path from 'path';
const { run, AxeResults } = require('axe-core');
const { reactRunDOM } = require('@component-controls/test-renderers');
"
import * as path from 'path';
import { run, AxeResults } = require('axe-core');
import { reactRunDOM } = require('@component-controls/test-renderers');
import '@component-controls/jest-axe-matcher';
import { loadStore } from '@component-controls/store';
import { mount, configure } from 'enzyme';
Expand All @@ -12,10 +13,9 @@ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
configure({ adapter: new Adapter() });
describe('component-controls generated', () => {
const store = loadStore(
require(path.resolve(__dirname, './bundle/component-controls.js')),
);
const store = loadStore(require(path.resolve(__dirname, './bundle/component-controls.js')));
const renderFn = store.config.renderFn;
Object.keys(store.docs).forEach(docId => {
const doc = store.docs[docId];
Expand All @@ -25,21 +25,24 @@ describe('component-controls generated', () => {
stories.forEach(storyId => {
const story = store.stories[storyId];
describe(story.name, () => {
const rendered = renderFn(story, doc);
const rendered = renderFn(story, doc);
it('snapshot', () => {
const component = mount(rendered);
expect(toJson(component, { mode: 'deep' })).toMatchSnapshot();
});
it('accessibility', async () => {
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
it('snapshot', () => {
const component = mount(rendered);
expect(toJson(component, { mode: 'deep' })).toMatchSnapshot();
});
it('accessibility', async () => {
const axeResults = await reactRunDOM<AxeResults>(rendered, run);
expect(axeResults).toHaveNoAxeViolations();
});
});
});
});
}
});
});
"
`;
Loading

0 comments on commit c33643c

Please sign in to comment.