From d10f4660e5e87dac08bbd23fc774a478a3aac878 Mon Sep 17 00:00:00 2001 From: Francesco Longo Date: Thu, 20 Jul 2023 11:11:46 +0200 Subject: [PATCH] feat: Generate JSON schema for Design Tokens --- build-tools/tasks/styles.js | 1 + src/__tests__/design-tokens.test.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build-tools/tasks/styles.js b/build-tools/tasks/styles.js index e07495127c..ff26d033a2 100644 --- a/build-tools/tasks/styles.js +++ b/build-tools/tasks/styles.js @@ -79,6 +79,7 @@ function stylesTask(theme) { designTokensOutputDir, designTokensFileName: theme.designTokensOutput, descriptions, + jsonSchema: true, }); }); } diff --git a/src/__tests__/design-tokens.test.ts b/src/__tests__/design-tokens.test.ts index cceef2a97a..0ea13cfb03 100644 --- a/src/__tests__/design-tokens.test.ts +++ b/src/__tests__/design-tokens.test.ts @@ -2,12 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 import { requireDesignTokensFile } from './utils'; +const themeNames = ['classic', 'visual-refresh']; + describe('Design tokens artifacts', () => { - test.each(['classic', 'visual-refresh'])( - `Design tokens JSON for %s matches the snapshot`, - (themeName: string) => { - const jsonContent = requireDesignTokensFile(`index-${themeName}.json`); - expect(jsonContent).toMatchSnapshot(themeName); - } - ); + test.each(themeNames)(`Design tokens JSON for %s matches the snapshot`, (themeName: string) => { + const jsonContent = requireDesignTokensFile(`index-${themeName}.json`); + expect(jsonContent).toMatchSnapshot(themeName); + }); + test.each(themeNames)(`Design tokens JSON schema is generated`, (themeName: string) => { + const jsonSchema = requireDesignTokensFile(`index-${themeName}-schema.json`); + expect(jsonSchema).not.toBeUndefined(); + }); });