-
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.
feat: add ability to load store from bundle
- Loading branch information
1 parent
2492e97
commit 9c7322e
Showing
62 changed files
with
6,457 additions
and
145 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
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
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
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
7 changes: 2 additions & 5 deletions
7
plugins/jest-snapshots/templates/render/enzyme-react-17.cjs.js
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
const rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
let rendered; | ||
{{=it.storeRender}} | ||
const component = mount(rendered); | ||
const serialize = () => toJson(component, { mode: 'deep' }); |
7 changes: 2 additions & 5 deletions
7
plugins/jest-snapshots/templates/render/enzyme-react-17.esm.js
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
const rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
let rendered; | ||
{{=it.storeRender}} | ||
const component = mount(rendered); | ||
const serialize = () => toJson(component, { mode: 'deep' }); |
7 changes: 2 additions & 5 deletions
7
plugins/jest-snapshots/templates/render/enzyme-react-17.ts.js
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
const rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
let rendered; | ||
{{=it.storeRender}} | ||
const component = mount(rendered); | ||
const serialize = () => toJson(component, { mode: 'deep' }); |
8 changes: 2 additions & 6 deletions
8
plugins/jest-snapshots/templates/render/react-test-renderer.cjs.js
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
let rendered; | ||
renderer.act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
{{=it.storeRender}} | ||
}) | ||
const component = renderer.create(rendered); | ||
const serialize = component ? component.toJSON : () => undefined; |
6 changes: 1 addition & 5 deletions
6
plugins/jest-snapshots/templates/render/react-test-renderer.esm.js
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
{{=it.storeRender}} | ||
}); | ||
const component = rendered ? renderer.create(rendered) : undefined; | ||
const serialize = component ? component.toJSON : () => undefined; |
8 changes: 2 additions & 6 deletions
8
plugins/jest-snapshots/templates/render/react-test-renderer.ts.js
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
}); | ||
{{=it.storeRender}} | ||
}) | ||
const component = rendered ? renderer.create(rendered) : undefined; | ||
const serialize = component ? component.toJSON : () => undefined; |
6 changes: 1 addition & 5 deletions
6
plugins/jest-snapshots/templates/render/react-testing-library.cjs.js
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
let rendered; | ||
act(() => { | ||
rendered = renderExample({ | ||
example, | ||
doc, | ||
config, | ||
}); | ||
{{=it.storeRender}} | ||
}); | ||
const { asFragment: serialize } = render(rendered); |
6 changes: 1 addition & 5 deletions
6
plugins/jest-snapshots/templates/render/react-testing-library.esm.js
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
6 changes: 1 addition & 5 deletions
6
plugins/jest-snapshots/templates/render/react-testing-library.ts.js
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,2 @@ | ||
const { loadStore } = require('@component-controls/store'); | ||
const { render: reactRender } = require('@component-controls/render/react'); |
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,2 @@ | ||
import { loadStore } from '@component-controls/store'; | ||
const { render: reactRender } = require('@component-controls/render/react'); |
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,2 @@ | ||
import { loadStore } from '@component-controls/store'; | ||
const { render: reactRender } = require('@component-controls/render/react'); |
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,6 @@ | ||
const { | ||
loadConfigurations, | ||
extractDocuments, | ||
} = require('@component-controls/config'); | ||
const { renderExample } = require('@component-controls/test-renderers'); | ||
const { render: reactRender } = require('@component-controls/render/react'); |
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,3 @@ | ||
import { loadConfigurations, extractDocuments } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; |
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,3 @@ | ||
import { loadConfigurations, extractDocuments } from '@component-controls/config'; | ||
import { renderExample } from '@component-controls/test-renderers'; | ||
import { render as reactRender } from '@component-controls/render/react'; |
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,17 @@ | ||
const store = loadStore(require('{{=it.bundlePath}}')); | ||
const renderFn = store.config.renderFn || reactRender; | ||
Object.keys(store.docs).forEach(docId => { | ||
const doc = store.docs[docId]; | ||
if (doc.stories && doc.stories.length) { | ||
const stories = doc.stories; | ||
describe(doc.title, () => { | ||
stories.forEach(storyId => { | ||
const story = store.stories[storyId]; | ||
it(story.name, async () => { | ||
{{=it.render}} | ||
expect(serialize()).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,17 @@ | ||
const store = loadStore(require('{{=it.bundlePath}}')); | ||
const renderFn = store.config.renderFn || reactRender; | ||
Object.keys(store.docs).forEach(docId => { | ||
const doc = store.docs[docId]; | ||
if (doc.stories && doc.stories.length) { | ||
const stories = doc.stories; | ||
describe(doc.title, () => { | ||
stories.forEach(storyId => { | ||
const story = store.stories[storyId]; | ||
it(story.name, async () => { | ||
{{=it.render}} | ||
expect(serialize()).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |
Oops, something went wrong.