From 81f8ac5ec573e32e88bdfcbbac0f3f439d66f7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Thu, 5 Jul 2018 14:16:47 +0200 Subject: [PATCH 1/3] feat(templates): Add Autocomplete.js template --- src/templates/Autocomplete.js/.editorconfig | 9 ++ src/templates/Autocomplete.js/.eslintignore | 3 + src/templates/Autocomplete.js/.eslintrc.js | 3 + .../Autocomplete.js/.gitignore.template | 22 +++++ src/templates/Autocomplete.js/.prettierrc | 5 ++ src/templates/Autocomplete.js/.template.js | 13 +++ src/templates/Autocomplete.js/README.md | 19 ++++ src/templates/Autocomplete.js/favicon.png | Bin 0 -> 5137 bytes src/templates/Autocomplete.js/index.html.hbs | 41 +++++++++ .../Autocomplete.js/manifest.webmanifest | 15 ++++ src/templates/Autocomplete.js/package.json | 25 ++++++ src/templates/Autocomplete.js/src/app.css | 81 ++++++++++++++++++ src/templates/Autocomplete.js/src/app.js.hbs | 25 ++++++ src/templates/Autocomplete.js/src/index.css | 10 +++ 14 files changed, 271 insertions(+) create mode 100644 src/templates/Autocomplete.js/.editorconfig create mode 100644 src/templates/Autocomplete.js/.eslintignore create mode 100644 src/templates/Autocomplete.js/.eslintrc.js create mode 100644 src/templates/Autocomplete.js/.gitignore.template create mode 100644 src/templates/Autocomplete.js/.prettierrc create mode 100644 src/templates/Autocomplete.js/.template.js create mode 100644 src/templates/Autocomplete.js/README.md create mode 100644 src/templates/Autocomplete.js/favicon.png create mode 100644 src/templates/Autocomplete.js/index.html.hbs create mode 100644 src/templates/Autocomplete.js/manifest.webmanifest create mode 100644 src/templates/Autocomplete.js/package.json create mode 100644 src/templates/Autocomplete.js/src/app.css create mode 100644 src/templates/Autocomplete.js/src/app.js.hbs create mode 100644 src/templates/Autocomplete.js/src/index.css diff --git a/src/templates/Autocomplete.js/.editorconfig b/src/templates/Autocomplete.js/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/src/templates/Autocomplete.js/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/src/templates/Autocomplete.js/.eslintignore b/src/templates/Autocomplete.js/.eslintignore new file mode 100644 index 000000000..9178ddcd8 --- /dev/null +++ b/src/templates/Autocomplete.js/.eslintignore @@ -0,0 +1,3 @@ +/node_modules +/dist +/.cache diff --git a/src/templates/Autocomplete.js/.eslintrc.js b/src/templates/Autocomplete.js/.eslintrc.js new file mode 100644 index 000000000..67b68ebe5 --- /dev/null +++ b/src/templates/Autocomplete.js/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: 'algolia', +}; diff --git a/src/templates/Autocomplete.js/.gitignore.template b/src/templates/Autocomplete.js/.gitignore.template new file mode 100644 index 000000000..f0fb0457d --- /dev/null +++ b/src/templates/Autocomplete.js/.gitignore.template @@ -0,0 +1,22 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/dist +/.cache + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/src/templates/Autocomplete.js/.prettierrc b/src/templates/Autocomplete.js/.prettierrc new file mode 100644 index 000000000..833f03b62 --- /dev/null +++ b/src/templates/Autocomplete.js/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "proseWrap": "never", + "trailingComma": "es5" +} diff --git a/src/templates/Autocomplete.js/.template.js b/src/templates/Autocomplete.js/.template.js new file mode 100644 index 000000000..807224b54 --- /dev/null +++ b/src/templates/Autocomplete.js/.template.js @@ -0,0 +1,13 @@ +const install = require('../../tasks/node/install'); +const teardown = require('../../tasks/node/teardown'); + +module.exports = { + libraryName: 'autocomplete.js', + templateName: 'autocomplete.js', + appName: 'autocomplete.js-app', + keywords: ['algolia', 'Autocomplete', 'autocomplete.js'], + tasks: { + install, + teardown, + }, +}; diff --git a/src/templates/Autocomplete.js/README.md b/src/templates/Autocomplete.js/README.md new file mode 100644 index 000000000..d50acaa49 --- /dev/null +++ b/src/templates/Autocomplete.js/README.md @@ -0,0 +1,19 @@ +# {{name}} + +_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ + +## Get started + +To run this project locally, install the dependencies and run the local server: + +```sh +npm install +npm start +``` + +Alternatively, you may use [Yarn](https://http://yarnpkg.com/): + +```sh +yarn +yarn start +``` diff --git a/src/templates/Autocomplete.js/favicon.png b/src/templates/Autocomplete.js/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..e67e0becc96e191aa68c91430b167b6a4bb37778 GIT binary patch literal 5137 zcmV+s6z=PZP)gOcKY|{ob{F>Z7xs zH1l!J@v$N~lJ2ADf^KAa)vMG17T~mB?rxl%ir=+kI{d|(wzoA-6afK1aG#V17uMuzB4rI8S%B`6EPKp@CmOekN~K1}e(m3c712hSMM#Hy9X zP%x6t&YZY7_$}aa`TCum_20X9xH;H<;v%jL zSRhqM6k>Jl6@kzQfdK(jKouoC zSa~`D4AeqlZ73`WUHk3?Hm5l<0>?zcvWn0M9C#K77yvSF!`PRVMp2)CKvAJ3^?>?i z0aV=;6ffQqlyB7od^C~ZUb?%G&D8_ zY+Ml$C$Q^a!j?TLTMne`ZCR#bXeUadAmV=C2w}7;EFCs%SQM~+Nyzx9!CH9m>6owF z8}p7G38zQGimK34NC5+=w`hYKMhCzfcNd<2o=mVnEf9KExw57F>)Mb%Jh#C~>ne0( z<=$;Ew{7q7)FDgPLe)57Lq})NZlp>kRL^R5ABu$I76qKUCgOw@Ay(nm$Gd#|o-Q{} zDyKDs6zFLI0`s>C4uJj}igFY!P!C|b2RF2p51dow4=)~~RuOJ{BIZYr#cZ3l3`fw6 z3JVXQKC(~}1N1D+B+#~S!kFRbkF9X>>WDp)Det>>me+4i`1xUj5r_*A<{c~*0Q8Ui zympIZ!XN56%l`hKYVeC^H<{R<@Z~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YDSmV4Pu@zw~8PzFJT6;%!8!m1~!a{2fl*tjg`ei z!?L!~-mz}6{5|kJ0RQ#*pPAZt@Idme9S6-X-tc%!yRl*nGI*TOe|4mY80X0ZpwI96 zy%VIMm5OlDx`r$tNxwfjQu$Y4Gr;}dtD64-v|0oHZ8%HW00000NkvXXu0mjfXXo1A literal 0 HcmV?d00001 diff --git a/src/templates/Autocomplete.js/index.html.hbs b/src/templates/Autocomplete.js/index.html.hbs new file mode 100644 index 000000000..d05b16aaf --- /dev/null +++ b/src/templates/Autocomplete.js/index.html.hbs @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + {{name}} + + + +
+

+ {{name}} +

+

using + Autocomplete.js +

+
+ +
+
+ +
+
+ + + + + diff --git a/src/templates/Autocomplete.js/manifest.webmanifest b/src/templates/Autocomplete.js/manifest.webmanifest new file mode 100644 index 000000000..20ac76f5c --- /dev/null +++ b/src/templates/Autocomplete.js/manifest.webmanifest @@ -0,0 +1,15 @@ +{ + "short_name": "{{name}}", + "name": "{{name}} Sample", + "icons": [ + { + "src": "favicon.png", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/src/templates/Autocomplete.js/package.json b/src/templates/Autocomplete.js/package.json new file mode 100644 index 000000000..14e7c8ee4 --- /dev/null +++ b/src/templates/Autocomplete.js/package.json @@ -0,0 +1,25 @@ +{ + "name": "{{name}}", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "parcel index.html --port 3000", + "build": "parcel build index.html", + "lint": "eslint .", + "lint:fix": "npm run lint -- --fix" + }, + "dependencies": { + "algoliasearch": "3.29.0", + "autocomplete.js": "{{libraryVersion}}" + }, + "devDependencies": { + "babel-eslint": "8.2.5", + "eslint": "4.19.1", + "eslint-config-algolia": "13.1.0", + "eslint-config-prettier": "2.9.0", + "eslint-plugin-import": "2.13.0", + "eslint-plugin-prettier": "2.6.1", + "parcel-bundler": "1.9.4", + "prettier": "1.13.7" + } +} diff --git a/src/templates/Autocomplete.js/src/app.css b/src/templates/Autocomplete.js/src/app.css new file mode 100644 index 000000000..604987c87 --- /dev/null +++ b/src/templates/Autocomplete.js/src/app.css @@ -0,0 +1,81 @@ +.header { + display: flex; + align-items: center; + min-height: 50px; + padding: 0.5rem 1rem; + background-image: linear-gradient(73deg, #3369e7, #1cc7d0); + color: #fff; + margin-bottom: 1rem; +} + +.header a { + color: #fff; + text-decoration: none; +} + +.header-title { + font-size: 1.2rem; + font-weight: normal; +} + +.header-title::after { + content: ' ▸ '; + padding: 0 0.5rem; +} + +.header-subtitle { + font-size: 1.2rem; +} + +.container { + max-width: 1200px; + margin: 0 auto; + padding: 1rem; +} + +#searchBox { + margin-bottom: 2rem; +} + +.algolia-autocomplete { + width: 100%; +} + +.algolia-autocomplete .aa-input, +.algolia-autocomplete .aa-hint { + width: 100%; +} + +.algolia-autocomplete .aa-input { + padding: 12px; + font: inherit; + border-radius: 2px; + border: 1px solid rgba(150, 150, 150, 0.16); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16); +} + +.algolia-autocomplete .aa-hint { + color: #999; +} + +.algolia-autocomplete .aa-dropdown-menu { + width: 100%; + background-color: #fff; + border: 1px solid rgba(150, 150, 150, 0.16); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16); +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion { + font-weight: bold; + cursor: pointer; + padding: 12px; +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em { + font-weight: normal; + font-style: normal; +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor { + background-color: rgba(150, 150, 150, 0.16); +} diff --git a/src/templates/Autocomplete.js/src/app.js.hbs b/src/templates/Autocomplete.js/src/app.js.hbs new file mode 100644 index 000000000..9bca5d3aa --- /dev/null +++ b/src/templates/Autocomplete.js/src/app.js.hbs @@ -0,0 +1,25 @@ +import algoliasearch from 'algoliasearch'; +import autocomplete from 'autocomplete.js'; + +const client = algoliasearch('{{appId}}', '{{apiKey}}'); +const index = client.initIndex('{{indexName}}'); + +const $hits = document.querySelector('#hits'); + +autocomplete('#searchBox input[type=search]', { hint: false }, [ + { + source: autocomplete.sources.hits(index, { hitsPerPage: 5 }), + displayKey: '{{mainAttribute}}', + templates: { + suggestion(suggestion) { + {{#if mainAttribute}} + return suggestion._highlightResult.{{mainAttribute}}.value; + {{else}} + return JSON.stringify(suggestion); + {{/if}} + }, + }, + }, +]).on('autocomplete:selected', (event, suggestion, dataset) => { + console.log({ suggestion, dataset }); +}); diff --git a/src/templates/Autocomplete.js/src/index.css b/src/templates/Autocomplete.js/src/index.css new file mode 100644 index 000000000..12f1b9911 --- /dev/null +++ b/src/templates/Autocomplete.js/src/index.css @@ -0,0 +1,10 @@ +body, +h1 { + margin: 0; + padding: 0; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, + Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; +} From 375e965679bd06a8d8c42d4d3e439649ba0b2f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Thu, 5 Jul 2018 14:17:00 +0200 Subject: [PATCH 2/3] test(snapshots): Update template snapshots --- .../autocomplete.js/favicon.png-snap.png | Bin 0 -> 5137 bytes .../__snapshots__/e2e-templates.test.js.snap | 308 ++++++++++++++++++ 2 files changed, 308 insertions(+) create mode 100644 scripts/__image_snapshots__/autocomplete.js/favicon.png-snap.png diff --git a/scripts/__image_snapshots__/autocomplete.js/favicon.png-snap.png b/scripts/__image_snapshots__/autocomplete.js/favicon.png-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..e67e0becc96e191aa68c91430b167b6a4bb37778 GIT binary patch literal 5137 zcmV+s6z=PZP)gOcKY|{ob{F>Z7xs zH1l!J@v$N~lJ2ADf^KAa)vMG17T~mB?rxl%ir=+kI{d|(wzoA-6afK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hU9yi5br8t$$4ULKLwg+P>2YRd>4>{-f2B)qHNn^`H6A7F5rcBSeq>9aHYD|&Y zNmI=PJ2YdNIFRzlu7pQ+rx=BwIi|`VoZn#MvWSPac6rASrg`n7J$`OPhyq7@Glv`R z&jeR5m%jKJb>HW6=GM0f)euzSiYevPhVTz(*ZKK#nk-)&ad0MO%dQ@eP4w8dKV>>r ztmlymLl+4wY8W<-2U%RddOV_55jIcs`1YN%y!)Y;2smj-=qV%$X24_e-unuLTm=Bk z9|X@PxMU?+BI1r2_=R!9Z=6!&^o>+bhg;EOD&tpGvuBYs}5t6TWlMVo=Vl3u6@_ z#kn~zTp#>!v{&>1D1O(cg8_mir8o{383#(oDtlshG*(b&u{YI(r8Qx3RY(=~bd}v* zcpz3tp&r1o6=7k;?e`Vv*<#X&lunDm)WLg1F8eV6TDHI<^9RAT7eE*Yq&Vrk#Gp(N6#40w?XYpI_#hNF{^vpP+lvVftf$QPC9C-uMiC7I)LeS( zknC<-0z`$<%&=G2{{*Jj?mgy@ul}M~zuAX1_l^ zG9*c=R`OZ^oC`PrxUr61oiSzWPbYDSmV4Pu@zw~8PzFJT6;%!8!m1~!a{2fl*tjg`ei z!?L!~-mz}6{5|kJ0RQ#*pPAZt@Idme9S6-X-tc%!yRl*nGI*TOe|4mY80X0ZpwI96 zy%VIMm5OlDx`r$tNxwfjQu$Y4Gr;}dtD64-v|0oHZ8%HW00000NkvXXu0mjfXXo1A literal 0 HcmV?d00001 diff --git a/scripts/__snapshots__/e2e-templates.test.js.snap b/scripts/__snapshots__/e2e-templates.test.js.snap index a7fa7e33b..3950ed568 100644 --- a/scripts/__snapshots__/e2e-templates.test.js.snap +++ b/scripts/__snapshots__/e2e-templates.test.js.snap @@ -945,6 +945,314 @@ Array [ ] `; +exports[`Templates Autocomplete.js File content: .editorconfig 1`] = ` +"root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true" +`; + +exports[`Templates Autocomplete.js File content: .eslintignore 1`] = ` +"/node_modules +/dist +/.cache" +`; + +exports[`Templates Autocomplete.js File content: .eslintrc.js 1`] = ` +"module.exports = { + extends: 'algolia', +};" +`; + +exports[`Templates Autocomplete.js File content: .gitignore 1`] = ` +"# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/dist +/.cache + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log*" +`; + +exports[`Templates Autocomplete.js File content: .prettierrc 1`] = ` +"{ + \\"singleQuote\\": true, + \\"proseWrap\\": \\"never\\", + \\"trailingComma\\": \\"es5\\" +}" +`; + +exports[`Templates Autocomplete.js File content: README.md 1`] = ` +"# autocomplete.js-app + +_This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._ + +## Get started + +To run this project locally, install the dependencies and run the local server: + +\`\`\`sh +npm install +npm start +\`\`\` + +Alternatively, you may use [Yarn](https://http://yarnpkg.com/): + +\`\`\`sh +yarn +yarn start +\`\`\`" +`; + +exports[`Templates Autocomplete.js File content: index.html 1`] = ` +" + + + + + + + + + + + + + + autocomplete.js-app + + + +
+

+ autocomplete.js-app +

+

using + Autocomplete.js +

+
+ +
+
+
+
+ +
+
+
+
+ + + + +" +`; + +exports[`Templates Autocomplete.js File content: manifest.webmanifest 1`] = ` +"{ + \\"short_name\\": \\"autocomplete.js-app\\", + \\"name\\": \\"autocomplete.js-app Sample\\", + \\"icons\\": [ + { + \\"src\\": \\"favicon.png\\", + \\"sizes\\": \\"64x64 32x32 24x24 16x16\\", + \\"type\\": \\"image/x-icon\\" + } + ], + \\"start_url\\": \\"./index.html\\", + \\"display\\": \\"standalone\\", + \\"theme_color\\": \\"#000000\\", + \\"background_color\\": \\"#ffffff\\" +}" +`; + +exports[`Templates Autocomplete.js File content: package.json 1`] = ` +"{ + \\"name\\": \\"autocomplete.js-app\\", + \\"version\\": \\"1.0.0\\", + \\"private\\": true, + \\"scripts\\": { + \\"start\\": \\"parcel index.html --port 3000\\", + \\"build\\": \\"parcel build index.html\\", + \\"lint\\": \\"eslint .\\", + \\"lint:fix\\": \\"npm run lint -- --fix\\" + }, + \\"dependencies\\": { + \\"algoliasearch\\": \\"3.29.0\\", + \\"autocomplete.js\\": \\"1.0.0\\" + }, + \\"devDependencies\\": { + \\"babel-eslint\\": \\"8.2.5\\", + \\"eslint\\": \\"4.19.1\\", + \\"eslint-config-algolia\\": \\"13.1.0\\", + \\"eslint-config-prettier\\": \\"2.9.0\\", + \\"eslint-plugin-import\\": \\"2.13.0\\", + \\"eslint-plugin-prettier\\": \\"2.6.1\\", + \\"parcel-bundler\\": \\"1.9.4\\", + \\"prettier\\": \\"1.13.7\\" + } +}" +`; + +exports[`Templates Autocomplete.js File content: src/app.css 1`] = ` +".header { + display: flex; + align-items: center; + min-height: 50px; + padding: 0.5rem 1rem; + background-image: linear-gradient(73deg, #3369e7, #1cc7d0); + color: #fff; + margin-bottom: 1rem; +} + +.header a { + color: #fff; + text-decoration: none; +} + +.header-title { + font-size: 1.2rem; + font-weight: normal; +} + +.header-title::after { + content: ' ▸ '; + padding: 0 0.5rem; +} + +.header-subtitle { + font-size: 1.2rem; +} + +.container { + max-width: 1200px; + margin: 0 auto; + padding: 1rem; +} + +#searchBox { + margin-bottom: 2rem; +} + +.algolia-autocomplete { + width: 100%; +} + +.algolia-autocomplete .aa-input, +.algolia-autocomplete .aa-hint { + width: 100%; +} + +.algolia-autocomplete .aa-input { + padding: 12px; + font: inherit; + border-radius: 2px; + border: 1px solid rgba(150, 150, 150, 0.16); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16); +} + +.algolia-autocomplete .aa-hint { + color: #999; +} + +.algolia-autocomplete .aa-dropdown-menu { + width: 100%; + background-color: #fff; + border: 1px solid rgba(150, 150, 150, 0.16); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16); +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion { + font-weight: bold; + cursor: pointer; + padding: 12px; +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em { + font-weight: normal; + font-style: normal; +} + +.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor { + background-color: rgba(150, 150, 150, 0.16); +}" +`; + +exports[`Templates Autocomplete.js File content: src/app.js 1`] = ` +"import algoliasearch from 'algoliasearch'; +import autocomplete from 'autocomplete.js'; + +const client = algoliasearch('appId', 'apiKey'); +const index = client.initIndex('indexName'); + +const $hits = document.querySelector('#hits'); + +autocomplete('#searchBox input[type=search]', { hint: false }, [ + { + source: autocomplete.sources.hits(index, { hitsPerPage: 5 }), + displayKey: 'mainAttribute', + templates: { + suggestion(suggestion) { + return suggestion._highlightResult.mainAttribute.value; + }, + }, + }, +]).on('autocomplete:selected', (event, suggestion, dataset) => { + console.log({ suggestion, dataset }); +});" +`; + +exports[`Templates Autocomplete.js File content: src/index.css 1`] = ` +"body, +h1 { + margin: 0; + padding: 0; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, + Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; +}" +`; + +exports[`Templates Autocomplete.js Folder structure: contains the right files 1`] = ` +Array [ + ".editorconfig", + ".eslintignore", + ".eslintrc.js", + ".gitignore", + ".prettierrc", + "README.md", + "favicon.png", + "index.html", + "manifest.webmanifest", + "package.json", + "src/app.css", + "src/app.js", + "src/index.css", +] +`; + exports[`Templates InstantSearch Android File content: .gitignore 1`] = ` "# IDE Files *.iml From f9b589b4777171d062b21fd061809bf45846b98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Thu, 5 Jul 2018 14:22:49 +0200 Subject: [PATCH 3/3] test(snapshots): Update snapshots --- src/api/__tests__/__snapshots__/index.test.js.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/__tests__/__snapshots__/index.test.js.snap b/src/api/__tests__/__snapshots__/index.test.js.snap index 65675d7f5..e44a65501 100644 --- a/src/api/__tests__/__snapshots__/index.test.js.snap +++ b/src/api/__tests__/__snapshots__/index.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`; +exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`; exports[`Options with unvalid name throws 1`] = ` "Could not create a project called \\"./WrongNpmName\\" because of npm naming restrictions. @@ -8,8 +8,8 @@ exports[`Options with unvalid name throws 1`] = ` - name can only contain URL-friendly characters" `; -exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`; +exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`; exports[`Options without path throws 1`] = `"The option \`path\` is required."`; -exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`; +exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete.js, InstantSearch Android, InstantSearch iOS, InstantSearch.js, React InstantSearch, React InstantSearch Native, Vue InstantSearch"`;