Skip to content

Commit

Permalink
@fluentui/react-button - Adding conformance tests to components (micr…
Browse files Browse the repository at this point in the history
…osoft#13690)

* adding isConformant to react-button

* modifying jest setup

* Change files
  • Loading branch information
sopranopillow committed Jun 18, 2020
1 parent d4a8768 commit 7e49098
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
@@ -0,0 +1,8 @@
{
"type": "none",
"comment": "Adding conformance test to components.",
"packageName": "@fluentui/react-button",
"email": "esteban.230@hotmail.com",
"dependentChangeType": "none",
"date": "2020-06-18T20:00:55.137Z"
}
11 changes: 11 additions & 0 deletions packages/react-button/config/tests.js
@@ -0,0 +1,11 @@
/** Jest test setup file. */
const { configure } = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

// Mock requestAnimationFrame for React 16+.
global.requestAnimationFrame = callback => {
setTimeout(callback, 0);
};

// Configure enzyme.
configure({ adapter: new Adapter() });
13 changes: 13 additions & 0 deletions packages/react-button/jest.config.js
@@ -0,0 +1,13 @@
const { createConfig } = require('@uifabric/build/jest/jest-resources');
const path = require('path');

const config = createConfig({
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))],

moduleNameMapper: {
'@fluentui/react-conformance/lib/(.*)$': '@fluentui/react-conformance/lib-commonjs/$1',
'@fluentui/react-conformance$': '@fluentui/react-conformance/lib-commonjs/index',
},
});

module.exports = config;
1 change: 1 addition & 0 deletions packages/react-button/package.json
Expand Up @@ -33,6 +33,7 @@
"@types/react-dom": "16.8.4",
"@types/react-test-renderer": "^16.0.0",
"@types/webpack-env": "1.15.1",
"@fluentui/react-conformance": "^0.1.0",
"@uifabric/build": "^7.0.0",
"@uifabric/tslint-rules": "^7.2.1",
"enzyme": "~3.10.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-button/src/components/Button/Button.test.tsx
@@ -0,0 +1,12 @@
import * as path from 'path';
import { isConformant } from '@fluentui/react-conformance';
import { Button } from './Button';

describe('Button', () => {
isConformant({
componentPath: path.join(__dirname, 'Button.tsx'),
Component: Button,
displayName: 'Button',
disabledTests: ['has-docblock'],
});
});
@@ -0,0 +1,12 @@
import * as path from 'path';
import { isConformant } from '@fluentui/react-conformance';
import { ToggleButton } from './ToggleButton';

describe('ToggleButton', () => {
isConformant({
componentPath: path.join(__dirname, 'ToggleButton.tsx'),
Component: ToggleButton,
displayName: 'ToggleButton',
disabledTests: ['has-docblock'],
});
});

0 comments on commit 7e49098

Please sign in to comment.