Skip to content

Commit

Permalink
WIP(ui-number-input,ui-scripts): add example usage for NumberInput
Browse files Browse the repository at this point in the history
  • Loading branch information
balzss committed Oct 5, 2023
1 parent 87b2bc7 commit 91dfd66
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
6 changes: 5 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/ui-number-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
},
"devDependencies": {
"@instructure/ui-axe-check": "^8.45.0",
"@instructure/ui-babel-preset": "8.45.0",
"@instructure/ui-test-locator": "8.45.0",
"@instructure/ui-test-utils": "8.45.0",
"@instructure/ui-themes": "8.45.0"
"@instructure/ui-themes": "8.45.0",
"@testing-library/react": "^14.0.0"
},
"dependencies": {
"@babel/runtime": "^7.22.15",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import { render } from '@testing-library/react'

// import { runAxeCheck } from '@instructure/ui-axe-check'
import { runAxeCheck } from '@instructure/ui-axe-check'
import { NumberInput } from '../index'
import NumberInputExamples from '../__examples__/NumberInput.examples'
import { generateA11yTests } from '../../../../ui-scripts/lib/test/generateA11yTests'

describe('<Breadcrumb />', () => {
const generatedComponents = generateA11yTests(
NumberInput,
NumberInputExamples
)
for (const component of generatedComponents) {
it(component.description, async () => {
const { container } = render(component.content)
const axeCheck = await runAxeCheck(container)
expect(axeCheck).toBe(true)
})
}
})
1 change: 1 addition & 0 deletions packages/ui-number-input/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{ "path": "../ui-babel-preset/tsconfig.build.json" },
{ "path": "../ui-test-locator/tsconfig.build.json" },
{ "path": "../ui-test-utils/tsconfig.build.json" },
{ "path": "../ui-axe-check/tsconfig.build.json" },
{ "path": "../ui-themes/tsconfig.build.json" },
{ "path": "../emotion/tsconfig.build.json" },
{ "path": "../shared-types/tsconfig.build.json" },
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-scripts/lib/test/generateA11yTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const renderExample = ({ Component, componentProps, key }: Example<any>) => (
)

export function generateA11yTests<Props extends Record<string, any>>(
Component: React.ComponentType,
Component: React.ComponentType<any>,
componentExample: StoryConfig<Props>
): ReturnComponentType[] {
const sections = generateComponentExamples(Component, componentExample)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-scripts/lib/test/generateComponentExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { generatePropCombinations } from './generatePropCombinations'

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / pr_validation

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not under 'rootDir' '/home/runner/work/instructure-ui/instructure-ui/packages/ui-billboard/src'. 'rootDir' is expected to contain all source files.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / pr_validation

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not listed within the file list of project '/home/runner/work/instructure-ui/instructure-ui/packages/ui-billboard/tsconfig.build.json'. Projects must list all files or use an 'include' pattern.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / pr_validation

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not under 'rootDir' '/home/runner/work/instructure-ui/instructure-ui/packages/ui-breadcrumb/src'. 'rootDir' is expected to contain all source files.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / pr_validation

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not listed within the file list of project '/home/runner/work/instructure-ui/instructure-ui/packages/ui-breadcrumb/tsconfig.build.json'. Projects must list all files or use an 'include' pattern.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / chromatic_deployment

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not under 'rootDir' '/home/runner/work/instructure-ui/instructure-ui/packages/ui-billboard/src'. 'rootDir' is expected to contain all source files.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / chromatic_deployment

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not listed within the file list of project '/home/runner/work/instructure-ui/instructure-ui/packages/ui-billboard/tsconfig.build.json'. Projects must list all files or use an 'include' pattern.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / chromatic_deployment

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not under 'rootDir' '/home/runner/work/instructure-ui/instructure-ui/packages/ui-breadcrumb/src'. 'rootDir' is expected to contain all source files.

Check failure on line 25 in packages/ui-scripts/lib/test/generateComponentExamples.tsx

View workflow job for this annotation

GitHub Actions / chromatic_deployment

File '/home/runner/work/instructure-ui/instructure-ui/packages/ui-scripts/lib/test/generatePropCombinations.ts' is not listed within the file list of project '/home/runner/work/instructure-ui/instructure-ui/packages/ui-breadcrumb/tsconfig.build.json'. Projects must list all files or use an 'include' pattern.
import React, { ComponentType, ReactNode, useId } from 'react'
import React, { ComponentType, ReactNode } from 'react'

export type StoryConfig<Props> = {
/**
Expand Down Expand Up @@ -239,7 +239,7 @@ export function generateComponentExamples<Props extends Record<string, any>>(
}
const propsString = fastSerialize(componentProps)
if (!PROPS_CACHE.includes(propsString)) {
const key = useId()
const key = `${Date.now()}${Math.round(Math.random() * 10000)}`
const exampleProps = getExampleProps(props)
exampleCount++
if (exampleCount < maxExamples) {
Expand Down

0 comments on commit 91dfd66

Please sign in to comment.