Skip to content

support not setting default in variant when using PARAGON_THEME_URLSΒ #808

@brian-smith-tcril

Description

@brian-smith-tcril

If we add the following test

    it('returns expected object when only brand override URLs are present, fallback to PARAGON_THEME', () => {
      const config = {
        PARAGON_THEME_URLS: {
          core: {
            urls: {
              brandOverride: 'https://www.example.com/example-brand-core.css',
            },
          },
          defaults: {
            light: 'light',
          },
          variants: {
            light: {
              urls: {
                brandOverride: 'https://www.example.com/example-brand-light.css'
              },
            }
          },
        },
      };
      mergeConfig(config);
      const { result } = renderHook(() => useParagonThemeUrls());
      expect(result.current).toEqual(
        expect.objectContaining({
          core: {
            urls: {
              default: '//localhost:8080/local-core.min.css',
              brandOverride: 'https://www.example.com/example-brand-core.css',
            },
          },
          defaults: {
            light: 'light',
          },
          variants: {
            light: {
              urls: {
                default: '//localhost:8080/local-light.min.css',
                brandOverride: 'https://www.example.com/example-brand-light.css',
              },
            },
          },
        }),
      );
    });

to useParagonThemeUrls.test.js it will fail because actual result will have an undefined for default in light

@@ -10,10 +10,10 @@
    },
    "variants": Object {
      "light": Object {
        "urls": Object {
          "brandOverride": "https://www.example.com/example-brand-light.css",
-         "default": "//localhost:8080/local-light.min.css",
+         "default": undefined,
        },
      },
    },
  }

Considering core handles not having a URL for default gracefully, it would be nice to have the variants handle that gracefully too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions