Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adds snapshot tests to main test utils wrappers #2980

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';
import { render } from '@testing-library/react';

import { getRequiredPropsForComponent } from './required-props-for-components';
import { getAllComponents, requireComponent, supportsDOMProperties } from './utils';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { getAllComponents, requireComponent, supportsDOMProperties } from '../utils';

describe('Base props support', () => {
const componentRoot = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import React from 'react';
import { render } from '@testing-library/react';

import FormField, { FormFieldProps } from '../../lib/components/form-field';
import { FormFieldValidationControlProps } from '../../lib/components/internal/context/form-field-context';
import createWrapper, { ElementWrapper } from '../../lib/components/test-utils/dom';
import { getRequiredPropsForComponent } from './required-props-for-components';
import { requireComponent } from './utils';
import FormField, { FormFieldProps } from '../../../lib/components/form-field';
import { FormFieldValidationControlProps } from '../../../lib/components/internal/context/form-field-context';
import createWrapper, { ElementWrapper } from '../../../lib/components/test-utils/dom';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { requireComponent } from '../utils';

const formFieldControlComponents = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { pascalCase } from 'change-case';

import { getAllComponents, requireComponent } from './utils';
import { getAllComponents, requireComponent } from '../utils';

describe('component displayName matches import directory name', () => {
getAllComponents().forEach(componentName => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';
import { render } from '@testing-library/react';

import { getRequiredPropsForComponent } from './required-props-for-components';
import { getAllComponents, requireComponent } from './utils';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { getAllComponents, requireComponent } from '../utils';

const skippedComponents = ['button'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import path from 'path';

// There are no typings for package.json
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../../lib/components/package.json');
const packageJson = require('../../../lib/components/package.json');

test('all exports declarations resolve to a file', () => {
for (const exportPath of Object.values<string>(packageJson.exports)) {
// context export is a folder, cannot be resolved
if (exportPath === './internal/context/') {
continue;
}
expect(() => require.resolve(exportPath, { paths: [path.join(__dirname, '../../lib/components')] })).not.toThrow();
expect(() =>
require.resolve(exportPath, { paths: [path.join(__dirname, '../../../lib/components')] })
).not.toThrow();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';

import { getRequiredPropsForComponent } from './required-props-for-components';
import { getAllComponents, requireComponent } from './utils';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { getAllComponents, requireComponent } from '../utils';

const skipComponents = [
'modal', // it uses portal API which does not work on server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { render } from '@testing-library/react';

import '../__a11y__/to-validate-a11y';
import '../../__a11y__/to-validate-a11y';

describe('a11y validator', () => {
test('valid', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import React from 'react';
import { render } from 'react-dom';
import { render as renderTestingLibrary } from '@testing-library/react';

import Button from '../../lib/components/button';
import createWrapper from '../../lib/components/test-utils/dom';
import Button from '../../../lib/components/button';
import createWrapper from '../../../lib/components/test-utils/dom';

describe('createWrapper', () => {
let spy: jest.SpyInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { pascalCase } from 'change-case';

import { COMPONENT_METADATA_KEY } from '@cloudscape-design/component-toolkit/internal';

import { PACKAGE_VERSION } from '../../lib/components/internal/environment';
import { getRequiredPropsForComponent } from './required-props-for-components';
import { getAllComponents, requireComponent, supportsDOMProperties } from './utils';
import { PACKAGE_VERSION } from '../../../lib/components/internal/environment';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { getAllComponents, requireComponent, supportsDOMProperties } from '../utils';

describe('useBaseComponent hook is used in all allowlisted public components', () => {
const componentRoot = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';
import { render } from '@testing-library/react';

import { getRequiredPropsForComponent } from './required-props-for-components';
import { getAllComponents, requireComponent } from './utils';
import { getRequiredPropsForComponent } from '../required-props-for-components';
import { getAllComponents, requireComponent } from '../utils';

declare global {
interface Window {
Expand Down
Loading
Loading