Skip to content

Commit

Permalink
fix test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 committed Feb 9, 2021
1 parent 5a3ab36 commit 29d2c56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/react-conformance/src/defaultTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import consoleUtil from './utils/consoleUtil';

/* eslint-disable @typescript-eslint/naming-convention */

const hasAs = (componentInfo: ComponentDoc) =>
!!componentInfo.props.as && componentInfo.props.as.parent?.fileName !== 'react/index.d.ts';

export const defaultTests: TestObject = {
/** Component has a docblock with 5 to 25 words */
'has-docblock': (componentInfo: ComponentDoc, testInfo: IsConformantOptions) => {
Expand Down Expand Up @@ -328,7 +331,7 @@ export const defaultTests: TestObject = {

/** If it has "as" prop: Renders as functional component or passes as to the next component */
'as-renders-fc': (componentInfo: ComponentDoc, testInfo: IsConformantOptions) => {
if (componentInfo.props.as) {
if (hasAs(componentInfo)) {
it(`renders as a functional component or passes "as" to the next component`, () => {
try {
const {
Expand Down Expand Up @@ -365,7 +368,7 @@ export const defaultTests: TestObject = {

/** If it has "as" prop: Renders as ReactClass or passes as to the next component */
'as-renders-react-class': (componentInfo: ComponentDoc, testInfo: IsConformantOptions) => {
if (componentInfo.props.as && !testInfo.asPropHandlesRef) {
if (hasAs(componentInfo) && !testInfo.asPropHandlesRef) {
it(`renders as a ReactClass or passes "as" to the next component`, () => {
try {
const { requiredProps, Component, customMount = mount, wrapperComponent, helperComponents = [] } = testInfo;
Expand Down Expand Up @@ -396,7 +399,8 @@ export const defaultTests: TestObject = {

/** If it has "as" prop: Passes extra props to the component it renders as */
'as-passes-as-value': (componentInfo: ComponentDoc, testInfo: IsConformantOptions) => {
if (componentInfo.props.as) {
// 2nd check: React.AllHTMLAttributes can also include `as`
if (hasAs(componentInfo)) {
it(`passes extra props to the component it is renders as`, () => {
try {
const { customMount = mount, Component, requiredProps, targetComponent, asPropHandlesRef } = testInfo;
Expand All @@ -423,7 +427,7 @@ export const defaultTests: TestObject = {

/** If it has "as" prop: Renders component as HTML tags */
'as-renders-html': (componentInfo: ComponentDoc, testInfo: IsConformantOptions) => {
if (componentInfo.props.as) {
if (hasAs(componentInfo)) {
it(`renders component as HTML tags or passes "as" to the next component`, () => {
try {
// silence element nesting warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,15 @@ exports[`DatePicker renders default DatePicker correctly 1`] = `
ms-DatePicker-event--without-label
msDatePickerDisabled
{
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
color: #605e5c;
cursor: pointer;
display: inline-block;
font-family: "FabricMDL2Icons";
font-size: 16px;
font-style: normal;
font-weight: normal;
line-height: 18px;
padding-bottom: 5px;
padding-left: 5px;
Expand All @@ -204,10 +209,13 @@ exports[`DatePicker renders default DatePicker correctly 1`] = `
pointer-events: initial;
position: absolute;
right: 4px;
speak: none;
}
data-icon-name="Calendar"
onClick={[Function]}
/>
>
</i>
</div>
</div>
</div>
Expand Down

0 comments on commit 29d2c56

Please sign in to comment.