Skip to content

Commit

Permalink
fix(design): align generated file to builder default config (#2040)
Browse files Browse the repository at this point in the history
## Proposed change

fix(design): align generated file to builder default config
fix(design): align generated file to builder default config
  • Loading branch information
kpanot authored Aug 8, 2024
2 parents fa1b685 + cd09e8d commit 82dfc6e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/@o3r/design/schematics/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('new otter application with Design', () => {
const diff = getGitDiff(workspacePath);
expect(diff.modified).toContain('package.json');
expect(diff.modified).toContain('angular.json');
expect(diff.added).toContain(path.posix.join('apps', appName, 'src/style/design-token.custom.json'));
expect(diff.added).toContain(path.posix.join('apps', appName, 'src/style/design-token.custom.theme.json'));
expect(diff.added).toContain(path.posix.join('apps', appName, 'src/style/theme.scss'));
expect(diff.added).toContain(path.posix.join('apps', appName, 'design-token.template.json'));

Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/design/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('ng-add', () => {
projectName: 'test-project'
}, initialTree);

expect(tree.exists('src/style/design-token.custom.json')).toBe(true);
expect(tree.exists('src/style/design-token.custom.theme.json')).toBe(true);
expect(tree.exists('design-token.template.json')).toBe(true);
expect(tree.exists('src/style/theme.scss')).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ describe('Design Token Parser', () => {

describe('parseDesignToken', () => {

test('should support single root key', () => {
const result = parser.parseDesignToken({
document: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'my.variable': {
$value: '{external}'
}
}
});
const var1 = result.get('my.variable');
const var2 = result.get('.my.variable');

expect(result.size).toBe(1);
expect(var2).not.toBeDefined();
expect(var1).toBeDefined();
expect(var1.getKey()).toBe('my-variable');
});

test('should generate a simple type variable', () => {
const result = parser.parseDesignToken(exampleVariable);
const var1 = result.get('example.var1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { dirname } from 'node:path';

const tokenReferenceRegExp = /\{([^}]+)\}/g;

const getTokenReferenceName = (tokenName: string, parents: string[]) => (`${parents.join('.')}.${tokenName}`);
const getTokenReferenceName = (tokenName: string, parents: string[]) => parents.join('.') + (parents.length ? '.' : '') + tokenName;
const getExtensions = (nodes: NodeReference[], context: DesignTokenContext | undefined) => {
return nodes.reduce((acc, {tokenNode}, i) => {
const nodeNames = nodes.slice(0, i + 1).map(({ name }) => name);
Expand Down

0 comments on commit 82dfc6e

Please sign in to comment.