|
| 1 | +import { makePluginConfigQuestions } from "../plugin-options-form" |
| 2 | +import pluginSchemas from "../plugin-schemas.json" |
| 3 | + |
| 4 | +describe(`plugin-options-form`, () => { |
| 5 | + it(`returns an empty array when nothing is passed`, () => { |
| 6 | + const plugins = [] |
| 7 | + expect(makePluginConfigQuestions(plugins)).toEqual([]) |
| 8 | + }) |
| 9 | + |
| 10 | + it(`returns an empty array when the plugin is not available for configu`, () => { |
| 11 | + const plugins = [`not-valid-plugin`] |
| 12 | + expect(makePluginConfigQuestions(plugins)).toEqual([]) |
| 13 | + }) |
| 14 | + |
| 15 | + it(`returns an arry containing only the wordpress options (choices are included)`, () => { |
| 16 | + const plugins = [`gatsby-source-wordpress-experimental`] |
| 17 | + expect(makePluginConfigQuestions(plugins)).toEqual([ |
| 18 | + { |
| 19 | + type: `forminput`, |
| 20 | + name: `gatsby-source-wordpress-experimental`, |
| 21 | + multiple: true, |
| 22 | + message: `Configure the WordPress plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-wordpress-experimental/\u001b[39m for help.`, |
| 23 | + choices: [ |
| 24 | + { |
| 25 | + name: `url`, |
| 26 | + message: `url`, |
| 27 | + hint: `This should be the full url of your GraphQL endpoint set up by WP GraphQL`, |
| 28 | + }, |
| 29 | + ], |
| 30 | + }, |
| 31 | + ]) |
| 32 | + }) |
| 33 | + |
| 34 | + it(`returns an array with all the plugins schemas`, () => { |
| 35 | + expect(makePluginConfigQuestions(Object.keys(pluginSchemas))).toEqual([ |
| 36 | + { |
| 37 | + type: `forminput`, |
| 38 | + name: `gatsby-source-wordpress-experimental`, |
| 39 | + multiple: true, |
| 40 | + message: `Configure the WordPress plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-wordpress-experimental/\u001b[39m for help.`, |
| 41 | + choices: [ |
| 42 | + { |
| 43 | + name: `url`, |
| 44 | + message: `url`, |
| 45 | + hint: `This should be the full url of your GraphQL endpoint set up by WP GraphQL`, |
| 46 | + }, |
| 47 | + ], |
| 48 | + }, |
| 49 | + { |
| 50 | + type: `forminput`, |
| 51 | + name: `gatsby-source-contentful`, |
| 52 | + multiple: true, |
| 53 | + message: `Configure the Contentful plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-contentful/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, |
| 54 | + choices: [ |
| 55 | + { |
| 56 | + name: `accessToken`, |
| 57 | + message: `accessToken`, |
| 58 | + hint: `Contentful delivery api key, when using the Preview API use your Preview API key`, |
| 59 | + }, |
| 60 | + { name: `spaceId`, message: `spaceId`, hint: `Contentful spaceId` }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + { |
| 64 | + type: `forminput`, |
| 65 | + name: `gatsby-source-sanity`, |
| 66 | + multiple: true, |
| 67 | + message: `Configure the Sanity plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-sanity/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, |
| 68 | + choices: [ |
| 69 | + { |
| 70 | + name: `projectId`, |
| 71 | + message: `projectId`, |
| 72 | + hint: `Your Sanity project's ID`, |
| 73 | + }, |
| 74 | + { |
| 75 | + name: `dataset`, |
| 76 | + message: `dataset`, |
| 77 | + hint: `The dataset to fetch from`, |
| 78 | + }, |
| 79 | + ], |
| 80 | + }, |
| 81 | + { |
| 82 | + type: `forminput`, |
| 83 | + name: `gatsby-source-shopify`, |
| 84 | + multiple: true, |
| 85 | + message: `Configure the Shopify plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-shopify/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, |
| 86 | + choices: [ |
| 87 | + { |
| 88 | + name: `shopName`, |
| 89 | + message: `shopName`, |
| 90 | + hint: `The domain name of your Shopify shop`, |
| 91 | + }, |
| 92 | + { |
| 93 | + name: `accessToken`, |
| 94 | + message: `accessToken`, |
| 95 | + hint: `An API access token to your Shopify shop`, |
| 96 | + }, |
| 97 | + ], |
| 98 | + }, |
| 99 | + { |
| 100 | + type: `forminput`, |
| 101 | + name: `gatsby-source-datocms`, |
| 102 | + multiple: true, |
| 103 | + message: `Configure the DatoCMS plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-datocms/\u001b[39m for help.`, |
| 104 | + choices: [ |
| 105 | + { |
| 106 | + name: `apiToken`, |
| 107 | + message: `apiToken`, |
| 108 | + hint: `Your read-only API token under the Settings > API tokens section of your administrative area in DatoCMS`, |
| 109 | + }, |
| 110 | + ], |
| 111 | + }, |
| 112 | + { |
| 113 | + type: `forminput`, |
| 114 | + name: `gatsby-source-agility`, |
| 115 | + multiple: true, |
| 116 | + message: `Configure the gatsby-source-agility plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-agility/\u001b[39m for help.`, |
| 117 | + choices: [ |
| 118 | + { |
| 119 | + name: `guid`, |
| 120 | + message: `guid`, |
| 121 | + hint: `your Agility Content Fetch API Guid`, |
| 122 | + }, |
| 123 | + ], |
| 124 | + }, |
| 125 | + { |
| 126 | + type: `forminput`, |
| 127 | + name: `gatsby-plugin-google-analytics`, |
| 128 | + multiple: true, |
| 129 | + message: `Configure the gatsby-plugin-google-analytics plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-plugin-google-analytics/\u001b[39m for help.`, |
| 130 | + choices: [ |
| 131 | + { |
| 132 | + name: `trackingId`, |
| 133 | + message: `trackingId`, |
| 134 | + hint: `The property ID; the tracking code won't be generated without it`, |
| 135 | + }, |
| 136 | + ], |
| 137 | + }, |
| 138 | + ]) |
| 139 | + }) |
| 140 | +}) |
0 commit comments