Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(insights): add insightsClient support on storybook #664

Merged
merged 4 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import '@storybook/addon-knobs/register';
import '@storybook/addon-options/register';
import '@storybook/addon-actions/register';
Haroenv marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"devDependencies": {
"@storybook/addon-knobs": "3.4.11",
"@storybook/addon-options": "3.4.11",
"@storybook/addon-actions": "3.4.11",
"@storybook/vue": "3.4.11",
"@vue/test-utils": "1.0.0-beta.25",
"algoliasearch": "3.32.0",
Expand Down
5 changes: 5 additions & 0 deletions src/components/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default createInstantSearchComponent({
type: Object,
required: true,
},
insightsClient: {
type: Function,
required: false,
},
indexName: {
type: String,
required: true,
Expand Down Expand Up @@ -68,6 +72,7 @@ export default createInstantSearchComponent({
return {
instantSearchInstance: instantsearch({
searchClient: this.searchClient,
insightsClient: this.insightsClient,
indexName: this.indexName,
routing: this.routing,
stalledSearchDelay: this.stalledSearchDelay,
Expand Down
3 changes: 3 additions & 0 deletions src/components/__tests__/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ beforeEach(() => jest.clearAllMocks());

it('passes props to InstantSearch.js', () => {
const searchClient = {};
const insightsClient = jest.fn();
const searchFunction = helper => helper.search();
mount(InstantSearch, {
propsData: {
searchClient,
insightsClient,
indexName: 'something',
routing: {
router: {},
Expand All @@ -29,6 +31,7 @@ it('passes props to InstantSearch.js', () => {
stateMapping: {},
},
searchClient,
insightsClient,
searchFunction,
stalledSearchDelay: 250,
});
Expand Down
3 changes: 3 additions & 0 deletions stories/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import algoliasearch from 'algoliasearch/lite';

export const previewWrapper = ({
searchClient = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76'),
insightsClient,
indexName = 'instant_search',
hits = `
<ol
Expand Down Expand Up @@ -36,6 +37,7 @@ export const previewWrapper = ({
<ais-instant-search
:search-client="searchClient"
index-name="${indexName}"
:insights-client="insightsClient"
>
<div class="vis-container vis-container-preview">
<story />
Expand All @@ -59,6 +61,7 @@ export const previewWrapper = ({
data() {
return {
searchClient,
insightsClient,
};
},
});
37 changes: 36 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@
resolved "https://registry.yarnpkg.com/@icons/material/-/material-0.2.4.tgz#e90c9f71768b3736e76d7dd6783fc6c2afa88bc8"
integrity sha512-QPcGmICAPbGLGb6F/yNf/KzKqvFx8z5qx3D1yFqVAjoFmXK35EgyW+cJ57Te3CNsmzblwtzakLGFqHPqrfb4Tw==

"@storybook/addon-actions@3.4.11":
version "3.4.11"
resolved "https://registry.yarnpkg.com/@storybook/addon-actions/-/addon-actions-3.4.11.tgz#a51418c5b684fd3df2788c19ef266845d6068baf"
integrity sha512-vA7KiMg6J3SlI0U9COhyX+nxoNNXsgXTKBA7oVjE+wduNwNc86WcbYGxKIxhCjJMBoAjZYBeRL9DmYWwaHb4xQ==
dependencies:
"@storybook/components" "3.4.11"
babel-runtime "^6.26.0"
deep-equal "^1.0.1"
glamor "^2.20.40"
glamorous "^4.12.1"
global "^4.3.2"
make-error "^1.3.4"
prop-types "^15.6.1"
react-inspector "^2.2.2"
uuid "^3.2.1"

"@storybook/addon-knobs@3.4.11":
version "3.4.11"
resolved "https://registry.yarnpkg.com/@storybook/addon-knobs/-/addon-knobs-3.4.11.tgz#13ca0c73f19c0a3fda1a1d1ff07ef00fa3a914b3"
Expand Down Expand Up @@ -6032,6 +6048,11 @@ is-directory@^0.3.1:
resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1"
integrity sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=

is-dom@^1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/is-dom/-/is-dom-1.0.9.tgz#483832d52972073de12b9fe3f60320870da8370d"
integrity sha1-SDgy1SlyBz3hK5/j9gMghw2oNw0=

is-dotfile@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1"
Expand Down Expand Up @@ -7261,6 +7282,11 @@ make-dir@^1.0.0:
dependencies:
pify "^2.3.0"

make-error@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==

makeerror@1.0.x:
version "1.0.11"
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
Expand Down Expand Up @@ -9525,6 +9551,15 @@ react-icons@^2.2.7:
dependencies:
react-icon-base "2.1.0"

react-inspector@^2.2.2:
version "2.3.1"
resolved "https://registry.yarnpkg.com/react-inspector/-/react-inspector-2.3.1.tgz#f0eb7f520669b545b441af9d38ec6d706e5f649c"
integrity sha512-tUUK7t3KWgZEIUktOYko5Ic/oYwvjEvQUFAGC1UeMeDaQ5za2yZFtItJa2RTwBJB//NxPr000WQK6sEbqC6y0Q==
dependencies:
babel-runtime "^6.26.0"
is-dom "^1.0.9"
prop-types "^15.6.1"

react-is@^16.8.1:
version "16.8.3"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.3.tgz#4ad8b029c2a718fc0cfc746c8d4e1b7221e5387d"
Expand Down Expand Up @@ -11902,7 +11937,7 @@ uuid@^3.1.0:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
integrity sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==

uuid@^3.3.2:
uuid@^3.2.1, uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==
Expand Down