Skip to content

Commit 900f459

Browse files
committed
Add tests for coverage
1 parent dc0bc59 commit 900f459

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

packages/@stylexjs/stylex/__tests__/stylex-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('stylex', () => {
2222
'keyframes',
2323
'positionTry',
2424
'viewTransitionClass',
25+
'defaultMarker',
2526
].forEach((api) => {
2627
test(`stylex.${api}`, () => {
2728
expect(() => stylex[api]()).toThrow();
@@ -47,6 +48,18 @@ describe('stylex', () => {
4748
expect(() => stylex.types[api]()).toThrow();
4849
});
4950
});
51+
52+
[
53+
'ancestor',
54+
'descendant',
55+
'siblingBefore',
56+
'siblingAfter',
57+
'anySibling',
58+
].forEach((api) => {
59+
test(`stylex.when${api}`, () => {
60+
expect(() => stylex.when[api](':hover')).toThrow();
61+
});
62+
});
5063
});
5164

5265
describe('props', () => {

packages/@stylexjs/stylex/src/stylex.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ export const defaultMarker = (): StaticStyles<> => {
135135
throw errorForFn('defaultMarker');
136136
};
137137

138+
export const when = {
139+
ancestor: (_pseudo?: string): string => {
140+
throw errorForFn('when.ancestor');
141+
},
142+
descendant: (_pseudo?: string): string => {
143+
throw errorForFn('when.descendant');
144+
},
145+
siblingBefore: (_pseudo?: string): string => {
146+
throw errorForFn('when.siblingBefore');
147+
},
148+
siblingAfter: (_pseudo?: string): string => {
149+
throw errorForFn('when.siblingAfter');
150+
},
151+
anySibling: (_pseudo?: string): string => {
152+
throw errorForFn('when.anySibling');
153+
},
154+
};
155+
138156
export const types = {
139157
angle: <T: string | 0 = string | 0>(
140158
_v: ValueWithDefault<T>,
@@ -222,6 +240,7 @@ type IStyleX = {
222240
}>,
223241
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string,
224242
types: typeof types,
243+
when: typeof when,
225244
__customProperties?: { [string]: mixed },
226245
...
227246
};
@@ -242,6 +261,7 @@ _legacyMerge.keyframes = keyframes;
242261
_legacyMerge.positionTry = positionTry;
243262
_legacyMerge.props = props;
244263
_legacyMerge.types = types;
264+
_legacyMerge.when = when;
245265
_legacyMerge.viewTransitionClass = viewTransitionClass;
246266

247267
export const legacyMerge: IStyleX = _legacyMerge;

0 commit comments

Comments
 (0)