Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/converter/generate-component-finders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ export default function wrapper(root: Element = document.body) {
console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly')
};
return new ElementWrapper(root);
}`,
}

export { wrapper as createWrapper };`,

selectors: `
export default function wrapper(root: string = 'body') {
return new ElementWrapper(root);
}`,
}

export { wrapper as createWrapper };`,
};

export interface GenerateFindersParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export default function wrapper(root: Element = document.body) {
};
return new ElementWrapper(root);
}

export { wrapper as createWrapper };
"
`;

Expand Down Expand Up @@ -214,5 +216,7 @@ ElementWrapper.prototype.findAllTestComponentBs = function(selector) {
export default function wrapper(root: string = 'body') {
return new ElementWrapper(root);
}

export { wrapper as createWrapper };
"
`;
3 changes: 2 additions & 1 deletion src/converter/test/generate-component-finders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ describe(`${generateComponentFinders.name}`, () => {
}
});

test('it exports the wrapper creator', () => {
test('it exports the wrapper creator as default and named exports', () => {
if (testUtilType === 'dom') {
expect(sourceFileContent).toMatch('export default function wrapper(root: Element = document.body)');
} else {
expect(sourceFileContent).toMatch(`export default function wrapper(root: string = 'body')`);
}
expect(sourceFileContent).toMatch('export { wrapper as createWrapper };');
});
});
});
4 changes: 2 additions & 2 deletions src/converter/test/test-utils-generator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function renderTestNode() {
describe(`${generateTestUtils.name}`, () => {
describe('generated dom index file', () => {
test('component finders return the first matching node', async () => {
const { default: createWrapper } = await import('./mock-test-utils/dom');
const { createWrapper } = await import('./mock-test-utils/dom');
const container = renderTestNode();
const wrapper = createWrapper(container);

Expand Down Expand Up @@ -61,7 +61,7 @@ describe(`${generateTestUtils.name}`, () => {

describe('generated selectors index file', () => {
test('component finders return the selector matching the first component', async () => {
const { default: createWrapper } = await import('./mock-test-utils/selectors');
const { createWrapper } = await import('./mock-test-utils/selectors');
const container = renderTestNode();
const wrapper = createWrapper();

Expand Down
Loading