Skip to content

Commit

Permalink
fix: set domain as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
luqven committed Feb 6, 2023
1 parent 35df3b9 commit 99310b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/modules/gatsby-plugin/pluginOptionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const pluginOptionsSchema: NonNullable<

const schema = Joi.object<IImgixGatsbyOptions & { plugins: any }>().keys({
domain: Joi.string()
.required()
.optional()
.description(
"This is the domain of your imgix source, which can be created at https://dashboard.imgix.com/. The source specified must be a 'Web Proxy' source type.",
),
Expand Down
23 changes: 13 additions & 10 deletions test/unit/pluginHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import * as fetchImgixMetadataModule from '../../src/api/fetchImgixMetadata';
import { createImgixUrlSchemaFieldConfig } from '../../src/modules/gatsby-plugin/createImgixUrlFieldConfig';
import { createImgixGatsbyTypes } from '../../src/pluginHelpers';

// test('should be able to call createImgixUrlFieldConfig with no domain and resolve a url', async () => {
// const config = createImgixUrlSchemaFieldConfig({
// resolveUrl: (node) => (node as any).url,
// });
test('should be able to call createImgixUrlFieldConfig with no domain and resolve a url', async () => {
const config = createImgixUrlSchemaFieldConfig({
imgixClientOptions: { domain: '' },
resolveUrl: () => 'https://assets.imgix.net/amsterdam.jpg',
paramsInputType: '',
});

// const resolved = await (config as any).resolve(
// { url: 'https://assets.imgix.net/amsterdam.jpg' },
// {},
// );
const resolved = await (config as any).resolve(
{ url: 'https://assets.imgix.net/amsterdam.jpg' },
{},
);

// expect(resolved).toMatch(/^https:\/\/assets.imgix.net\/amsterdam.jpg\?/);
// });
expect(resolved).toMatch(/^https:\/\/assets.imgix.net\/amsterdam.jpg\?/);
});
// test('should be able to call createImgixUrlFieldConfig with a domain and resolve a url', async () => {
// const config = createImgixUrlSchemaFieldConfig({
// resolveUrl: (node) => (node as any).url,
Expand Down

0 comments on commit 99310b1

Please sign in to comment.