Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/build/tasks/__tests__/theme-json-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,56 @@ describe('validateJson', () => {
});
});
});

describe('font-decoration-thickness', () => {
test('accepts certain formats', () => {
['1px', '0.5em', '1rem', '10%', 'auto', 'from-font'].forEach((validValue) => {
expect(
validateTokens({
'font-decoration-thickness-link': {
$value: validValue,
},
}),
).toBe(true);
});
});

test('rejects invalid formats', () => {
['1', 'thin', '1 px'].forEach((invalidValue) => {
expect(() =>
validateTokens({
'font-decoration-thickness-link': {
$value: invalidValue,
},
}),
).toThrowError('Tokens validation error');
});
});
});

describe('font-decoration-style', () => {
test('accepts valid values', () => {
['solid', 'double', 'dotted', 'dashed', 'wavy', 'underline', 'none'].forEach((validValue) => {
expect(
validateTokens({
'font-decoration-style-link': {
$value: validValue,
},
}),
).toBe(true);
});
});

test('rejects invalid values', () => {
['bold', 'italic', '1px'].forEach((invalidValue) => {
expect(() =>
validateTokens({
'font-decoration-style-link': {
$value: invalidValue,
},
}),
).toThrowError('Tokens validation error');
});
});
});
});
10 changes: 10 additions & 0 deletions src/build/tasks/theme-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const borderWidthValueSchema: GenericSchema = {
type: 'string',
pattern: '^\\d+(\\.\\d+)?(px|rem|em)$',
};
const textDecorationThicknessValueSchema: GenericSchema = {
type: 'string',
pattern: '^(auto|from-font|0|(\\d+(\\.\\d+)?|\\.\\d+)(px|rem|em|%))$',
};
const textDecorationStyleValueSchema: GenericSchema = {
Comment thread
at-susie marked this conversation as resolved.
type: 'string',
pattern: '^(solid|double|dotted|dashed|wavy|none|underline|overline|line-through)$',
};
const textSizeValueSchema: GenericSchema = {
type: 'string',
pattern: '^\\d+(\\.\\d+)?(px|rem|em)$',
Expand Down Expand Up @@ -85,6 +93,8 @@ const tokensSchema: GenericSchema = {
'^motion-keyframes-': getTokenSchema(getComplexValueSchema(stringValueSchema, motionModes)),
'^shadow-': getTokenSchema(getComplexValueSchema(stringValueSchema, visualModes)),
'^font-size-': getTokenSchema(textSizeValueSchema),
'^font-decoration-thickness-': getTokenSchema(textDecorationThicknessValueSchema),
'^font-decoration-style-': getTokenSchema(textDecorationStyleValueSchema),
'^line-height-': getTokenSchema(textSizeValueSchema),
'^font-weight-': getTokenSchema(textWeightValueSchema),
'^letter-spacing-': getTokenSchema(letterSpacingValueSchema),
Expand Down
Loading