Skip to content

Commit a4a104b

Browse files
committed
All test passes and build fixed
1 parent e2fcfbb commit a4a104b

28 files changed

+1299
-1488
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"rimraf": "^3.0.2",
9696
"ts-node": "^10.2.1",
9797
"vitest": "^0.24.3",
98-
"cases-of-test": "^0.0.1",
9998
"typescript": "^4.9.1-beta"
10099
}
101100
}

src/bin/css_to_ts/spacing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ export function generateSpacingTsCode(rawCssCode: string) {
9797
Object.fromEntries(spacingTokenAndValues.map(({ token, value }) => [token, value])),
9898
null,
9999
4
100-
)};`,
100+
)} as const;`,
101101
``,
102-
`type SpacingTokenByValue = typeof spacingTokenByValue;`,
102+
`export type SpacingTokenByValue = typeof spacingTokenByValue;`,
103103
``,
104104
`export type SpacingToken = keyof SpacingTokenByValue;`,
105105
``

src/lib/spacing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { capitalize } from "tsafe/capitalize";
44
import { spacingTokenByValue } from "./generatedFromCss/spacing";
55
import type { SpacingToken, SpacingTokenByValue } from "./generatedFromCss/spacing";
66

7+
export type { SpacingToken };
8+
79
export function spacing<T extends SpacingToken>(token: T): SpacingTokenByValue[T];
810
export function spacing<
911
Kind extends "padding" | "margin",

test/behavior/bin/breakpoints.test/generateBreakpointsTsCode.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { it, expect } from "vitest";
22
import { generateBreakpointsTsCode } from "../../../../src/bin/css_to_ts/breakpoints";
33

4-
export default () =>
5-
it("Generation of TS code for breakpoints", () => {
6-
const input = `
4+
it("Generation of TS code for breakpoints", () => {
5+
const input = `
76
@media (min-width: 36em) {
87
/*! media sm */
98
@@ -42,7 +41,7 @@ export default () =>
4241
}
4342
`;
4443

45-
const expected = `
44+
const expected = `
4645
import { assert } from "tsafe/assert";
4746
import type { Extends } from "tsafe";
4847
@@ -63,7 +62,7 @@ export const breakpointValues = {
6362
assert<Extends<typeof breakpointValues, Record<BreakpointKeys, number>>>();
6463
`.replace(/^\n/, "");
6564

66-
const got = generateBreakpointsTsCode(input);
65+
const got = generateBreakpointsTsCode(input);
6766

68-
expect(got).toBe(expected);
69-
});
67+
expect(got).toBe(expected);
68+
});

test/behavior/bin/breakpoints.test/index.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/behavior/bin/breakpoints.test/parseBreakpointsValues.test.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import type {
88
//import { same } from "evt/tools/inDepth/same";
99
import { id } from "tsafe";
1010

11-
export default () =>
12-
it("Parsing of breakpoint", () => {
13-
const input = `
11+
it("Parsing of breakpoint", () => {
12+
const input = `
1413
@media (min-width: 36em) {
1514
/*! media sm */
1615
@@ -49,23 +48,23 @@ export default () =>
4948
}
5049
`;
5150

52-
const expected = {
53-
"breakpointsValues": id<BreakpointsValues>({
54-
"unit": "em",
55-
"sm": 36,
56-
"md": 48,
57-
"lg": 62,
58-
"xl": 78
59-
}),
60-
"mediaQueryByBreakpoint": id<MediaQueryByBreakpoint>({
61-
"sm": "(min-width: 36em)",
62-
"md": "(min-width: 48em)",
63-
"lg": "(min-width: 62em)",
64-
"xl": "(min-width: 78em)"
65-
})
66-
};
51+
const expected = {
52+
"breakpointsValues": id<BreakpointsValues>({
53+
"unit": "em",
54+
"sm": 36,
55+
"md": 48,
56+
"lg": 62,
57+
"xl": 78
58+
}),
59+
"mediaQueryByBreakpoint": id<MediaQueryByBreakpoint>({
60+
"sm": "(min-width: 36em)",
61+
"md": "(min-width: 48em)",
62+
"lg": "(min-width: 62em)",
63+
"xl": "(min-width: 78em)"
64+
})
65+
};
6766

68-
const got = parseBreakpointsValues(input);
67+
const got = parseBreakpointsValues(input);
6968

70-
expect(got).toStrictEqual(expected);
71-
});
69+
expect(got).toStrictEqual(expected);
70+
});

test/behavior/bin/colorDecisions/generateGetColorDecisionsTsCode.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { it, expect } from "vitest";
22
import { generateGetColorDecisionsTsCode } from "../../../../src/bin/css_to_ts/colorDecisions";
33

4-
export default () =>
5-
it("Generates the correct TS code for breakpoints", () => {
6-
const input = `
4+
it("Generates the correct TS code for breakpoints", () => {
5+
const input = `
76
:root {
87
--grey-1000-50-hover: #ffffff;
98
--grey-1000-50: #ffffff;
@@ -35,7 +34,7 @@ export default () =>
3534
@media (min-width: 78em) { }
3635
`;
3736

38-
const expected = `
37+
const expected = `
3938
export function getColorDecisions(
4039
params: {
4140
colorOptions: ColorOptions;
@@ -73,7 +72,7 @@ export function getColorDecisions(
7372
} as const;
7473
}`.replace(/^\n/, "");
7574

76-
const got = generateGetColorDecisionsTsCode(input);
75+
const got = generateGetColorDecisionsTsCode(input);
7776

78-
expect(got).toBe(expected);
79-
});
77+
expect(got).toBe(expected);
78+
});

test/behavior/bin/colorDecisions/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/behavior/bin/colorDecisions/parseColorDecision.test.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { it, expect } from "vitest";
22
import { parseColorDecision } from "../../../../src/bin/css_to_ts/colorDecisions";
33
import type { ColorDecision } from "../../../../src/bin/css_to_ts/colorDecisions";
44

5-
export default () =>
6-
it("Color decisions to be successfully parsed", () => {
7-
const rawCssCode = `
5+
it("Color decisions to be successfully parsed", () => {
6+
const rawCssCode = `
87
:root {
98
--grey-1000-50-hover: #ffffff;
109
--grey-1000-50: #ffffff;
@@ -36,30 +35,30 @@ export default () =>
3635
@media (min-width: 78em) { }
3736
`;
3837

39-
const got = parseColorDecision(rawCssCode);
38+
const got = parseColorDecision(rawCssCode);
4039

41-
const expected: ColorDecision[] = [
42-
{
43-
"themePath": ["background", "default", "grey", "hover"],
44-
"optionThemePath": ["grey", "_1000_50", "hover"]
45-
},
46-
{
47-
"themePath": ["background", "default", "grey", "default"],
48-
"optionThemePath": ["grey", "_1000_50", "default"]
49-
},
50-
{
51-
"themePath": ["border", "actionLow", "orangeTerreBattue", "default"],
52-
"optionThemePath": ["orangeTerreBattue", "_850_200", "default"]
53-
},
54-
{
55-
"themePath": ["background", "altRaised", "grey", "hover"],
56-
"optionThemePath": ["grey", "_975_100", "hover"]
57-
},
58-
{
59-
"themePath": ["background", "contrastOverlap", "grey", "default"],
60-
"optionThemePath": ["grey", "_950_150", "default"]
61-
}
62-
];
40+
const expected: ColorDecision[] = [
41+
{
42+
"themePath": ["background", "default", "grey", "hover"],
43+
"optionThemePath": ["grey", "_1000_50", "hover"]
44+
},
45+
{
46+
"themePath": ["background", "default", "grey", "default"],
47+
"optionThemePath": ["grey", "_1000_50", "default"]
48+
},
49+
{
50+
"themePath": ["border", "actionLow", "orangeTerreBattue", "default"],
51+
"optionThemePath": ["orangeTerreBattue", "_850_200", "default"]
52+
},
53+
{
54+
"themePath": ["background", "altRaised", "grey", "hover"],
55+
"optionThemePath": ["grey", "_975_100", "hover"]
56+
},
57+
{
58+
"themePath": ["background", "contrastOverlap", "grey", "default"],
59+
"optionThemePath": ["grey", "_950_150", "default"]
60+
}
61+
];
6362

64-
expect(got).toStrictEqual(expected);
65-
});
63+
expect(got).toStrictEqual(expected);
64+
});

0 commit comments

Comments
 (0)