-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: upgrade ui tests to story based
- Loading branch information
1 parent
5f799be
commit 6139d5e
Showing
319 changed files
with
70,581 additions
and
60,608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import MatchMediaMock from 'jest-matchmedia-mock'; | ||
import { loadConfigurations } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; | ||
import { render, act } from '@testing-library/react'; | ||
|
||
const renderErr = () => { | ||
throw new Error('Could not render the story'); | ||
}; | ||
|
||
import doc, { overview } from './Catalog.stories'; | ||
|
||
describe('Catalog', () => { | ||
let matchMedia: MatchMediaMock; | ||
beforeAll(() => { | ||
jest.mock('rc-util/lib/Portal'); | ||
matchMedia = new MatchMediaMock(); | ||
}); | ||
afterEach(() => { | ||
matchMedia.clear(); | ||
}); | ||
const configPath = path.resolve(__dirname, '../../.config'); | ||
const config = loadConfigurations(configPath); | ||
if (!config.renderFn) { | ||
config.renderFn = reactRender; | ||
} | ||
|
||
test('overview', () => { | ||
const example = overview; | ||
|
||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
if (!rendered) { | ||
renderErr(); | ||
return; | ||
} | ||
const { asFragment } = render(rendered); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import MatchMediaMock from 'jest-matchmedia-mock'; | ||
import { loadConfigurations } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; | ||
import { render, act } from '@testing-library/react'; | ||
|
||
const renderErr = () => { | ||
throw new Error('Could not render the story'); | ||
}; | ||
|
||
import doc, { overview } from './ComponentCard.stories'; | ||
|
||
describe('ComponentCard', () => { | ||
let matchMedia: MatchMediaMock; | ||
beforeAll(() => { | ||
jest.mock('rc-util/lib/Portal'); | ||
matchMedia = new MatchMediaMock(); | ||
}); | ||
afterEach(() => { | ||
matchMedia.clear(); | ||
}); | ||
const configPath = path.resolve(__dirname, '../../.config'); | ||
const config = loadConfigurations(configPath); | ||
if (!config.renderFn) { | ||
config.renderFn = reactRender; | ||
} | ||
|
||
test('overview', () => { | ||
const example = overview; | ||
|
||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
if (!rendered) { | ||
renderErr(); | ||
return; | ||
} | ||
const { asFragment } = render(rendered); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import MatchMediaMock from 'jest-matchmedia-mock'; | ||
import { loadConfigurations } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; | ||
import { render, act } from '@testing-library/react'; | ||
|
||
const renderErr = () => { | ||
throw new Error('Could not render the story'); | ||
}; | ||
|
||
import doc, { overview } from './ComponentFilter.stories'; | ||
|
||
describe('ComponentFilter', () => { | ||
let matchMedia: MatchMediaMock; | ||
beforeAll(() => { | ||
jest.mock('rc-util/lib/Portal'); | ||
matchMedia = new MatchMediaMock(); | ||
}); | ||
afterEach(() => { | ||
matchMedia.clear(); | ||
}); | ||
const configPath = path.resolve(__dirname, '../../.config'); | ||
const config = loadConfigurations(configPath); | ||
if (!config.renderFn) { | ||
config.renderFn = reactRender; | ||
} | ||
|
||
test('overview', () => { | ||
const example = overview; | ||
|
||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
if (!rendered) { | ||
renderErr(); | ||
return; | ||
} | ||
const { asFragment } = render(rendered); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import MatchMediaMock from 'jest-matchmedia-mock'; | ||
import { loadConfigurations } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; | ||
import { render, act } from '@testing-library/react'; | ||
|
||
const renderErr = () => { | ||
throw new Error('Could not render the story'); | ||
}; | ||
|
||
import doc, { overview } from './ComponentList.stories'; | ||
|
||
describe('ComponentList', () => { | ||
let matchMedia: MatchMediaMock; | ||
beforeAll(() => { | ||
jest.mock('rc-util/lib/Portal'); | ||
matchMedia = new MatchMediaMock(); | ||
}); | ||
afterEach(() => { | ||
matchMedia.clear(); | ||
}); | ||
const configPath = path.resolve(__dirname, '../../.config'); | ||
const config = loadConfigurations(configPath); | ||
if (!config.renderFn) { | ||
config.renderFn = reactRender; | ||
} | ||
|
||
test('overview', () => { | ||
const example = overview; | ||
|
||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
if (!rendered) { | ||
renderErr(); | ||
return; | ||
} | ||
const { asFragment } = render(rendered); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
plugins/addon-catalog/src/stories/ComponentsCatalog.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path'; | ||
import MatchMediaMock from 'jest-matchmedia-mock'; | ||
import { loadConfigurations } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; | ||
import { render, act } from '@testing-library/react'; | ||
|
||
const renderErr = () => { | ||
throw new Error('Could not render the story'); | ||
}; | ||
|
||
import doc, { overview } from './ComponentsCatalog.stories'; | ||
|
||
describe('ComponentsCatalog', () => { | ||
let matchMedia: MatchMediaMock; | ||
beforeAll(() => { | ||
jest.mock('rc-util/lib/Portal'); | ||
matchMedia = new MatchMediaMock(); | ||
}); | ||
afterEach(() => { | ||
matchMedia.clear(); | ||
}); | ||
const configPath = path.resolve(__dirname, '../../.config'); | ||
const config = loadConfigurations(configPath); | ||
if (!config.renderFn) { | ||
config.renderFn = reactRender; | ||
} | ||
|
||
test('overview', () => { | ||
const example = overview; | ||
|
||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
if (!rendered) { | ||
renderErr(); | ||
return; | ||
} | ||
const { asFragment } = render(rendered); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.