Skip to content

Commit

Permalink
feat: Generate JSON schema for Design Tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Longo committed Jul 20, 2023
1 parent de8ff94 commit d10f466
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions build-tools/tasks/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function stylesTask(theme) {
designTokensOutputDir,
designTokensFileName: theme.designTokensOutput,
descriptions,
jsonSchema: true,
});
});
}
Expand Down
17 changes: 10 additions & 7 deletions src/__tests__/design-tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(['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<string>(themeNames)(`Design tokens JSON for %s matches the snapshot`, (themeName: string) => {
const jsonContent = requireDesignTokensFile(`index-${themeName}.json`);
expect(jsonContent).toMatchSnapshot(themeName);
});
test.each<string>(themeNames)(`Design tokens JSON schema is generated`, (themeName: string) => {
const jsonSchema = requireDesignTokensFile(`index-${themeName}-schema.json`);
expect(jsonSchema).not.toBeUndefined();
});
});

0 comments on commit d10f466

Please sign in to comment.