Browse Source
test: fix argo-ci skipped demo (#39245)
* test: fix image test cases
* test: wrong skip for image test cases
* chore: fix skipped demo
* Apply suggestions from code review
* Update components/steps/__tests__/image.test.ts
pull/39257/head
afc163
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
15 additions and
7 deletions
-
components/image/__tests__/image.test.ts
-
tests/shared/demoTest.tsx
-
tests/shared/imageTest.tsx
|
|
@ -0,0 +1,5 @@ |
|
|
|
import { imageDemoTest } from '../../../tests/shared/imageTest'; |
|
|
|
|
|
|
|
describe('Image image', () => { |
|
|
|
imageDemoTest('image'); |
|
|
|
}); |
|
|
@ -56,10 +56,11 @@ function baseText(doInject: boolean, component: string, options: Options = {}) { |
|
|
|
let cssinjsTest = false; |
|
|
|
|
|
|
|
files.forEach((file) => { |
|
|
|
let testMethod = options.skip === true ? test.skip : test; |
|
|
|
if (Array.isArray(options.skip) && options.skip.some((c) => file.includes(c))) { |
|
|
|
testMethod = test.skip; |
|
|
|
} |
|
|
|
const testMethod = |
|
|
|
options.skip === true || |
|
|
|
(Array.isArray(options.skip) && options.skip.some((c) => file.includes(c))) |
|
|
|
? test.skip |
|
|
|
: test; |
|
|
|
|
|
|
|
if (!doInject && !cssinjsTest && testMethod !== test.skip) { |
|
|
|
cssinjsTest = true; |
|
|
|
|
|
@ -65,14 +65,16 @@ type Options = { |
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-export
|
|
|
|
export function imageDemoTest(component: string, options: Options = {}) { |
|
|
|
let testMethod = options.skip === true ? describe.skip : describe; |
|
|
|
let describeMethod = options.skip === true ? describe.skip : describe; |
|
|
|
const files = glob.sync(`./components/${component}/demo/*.tsx`); |
|
|
|
|
|
|
|
files.forEach((file) => { |
|
|
|
if (Array.isArray(options.skip) && options.skip.some((c) => file.includes(c))) { |
|
|
|
testMethod = test.skip; |
|
|
|
describeMethod = describe.skip; |
|
|
|
} else { |
|
|
|
describeMethod = describe; |
|
|
|
} |
|
|
|
testMethod(`Test ${file} image`, () => { |
|
|
|
describeMethod(`Test ${file} image`, () => { |
|
|
|
// eslint-disable-next-line global-require,import/no-dynamic-require
|
|
|
|
let Demo = require(`../.${file}`).default; |
|
|
|
if (typeof Demo === 'function') { |
|
|
|