-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
169 lines (145 loc) · 3.99 KB
/
test.js
File metadata and controls
169 lines (145 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import fs from 'node:fs';
import {fileURLToPath} from 'node:url';
import path from 'node:path';
import test from 'node:test';
import assert from 'node:assert';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const cssPath = path.join(__dirname, 'index.css');
test('CSS file exists and is valid', () => {
assert.ok(fs.existsSync(cssPath), 'index.css should exist');
const cssContent = fs.readFileSync(cssPath, 'utf8');
// Check that file is not empty
assert.ok(cssContent.length > 0, 'CSS file should not be empty');
// Check for required @function declarations
const functions = [
// Math & Number
'--negate',
'--lerp',
'--map-range',
'--ratio',
// Color
'--opacity',
'--tint',
'--shade',
'--saturate',
'--lighten',
'--darken',
'--rotate-hue',
'--complement',
'--invert',
'--grayscale',
'--text-on',
'--opaque',
'--mix',
'--triadic',
'--tetradic',
'--black',
'--white',
// Typography
'--fluid-type',
'--modular-scale',
'--line-height-length',
'--line-height-ratio',
'--line-height-unitless',
// Layout
'--sidebar-layout',
'--conditional-radius',
'--responsive-value',
'--aspect-height',
'--aspect-width',
// Spacing
'--spacing',
'--container-padding',
// Animation
'--ease-out',
'--elastic-ease',
// Utility
'--px-to-rem',
'--rem-to-px',
// Grid
'--auto-grid',
'--grid-span',
// Filter
'--smooth-shadow',
'--glow',
// Theme
'--light-dark',
'--theme-color',
];
for (const functionName of functions) {
assert.ok(
cssContent.includes(`@function ${functionName}`),
`CSS should contain @function ${functionName}`,
);
}
// Check for result descriptors
assert.ok(
cssContent.match(/result:/g).length > 0,
'CSS should contain result descriptors',
);
// Check for proper CSS comments
assert.ok(
cssContent.includes('/**'),
'CSS should contain documentation comments',
);
// Check for parameter definitions
assert.ok(
cssContent.includes('--value'),
'CSS should contain parameter definitions',
);
console.log('✓ All CSS function declarations found');
console.log(`✓ Total functions: ${functions.length}`);
});
test('Documentation exists', () => {
const readmePath = path.join(__dirname, 'readme.md');
assert.ok(fs.existsSync(readmePath), 'readme.md should exist');
const readmeContent = fs.readFileSync(readmePath, 'utf8');
// Check for important sections
const sections = [
'## Install',
'## Usage',
'## Functions',
'## Examples',
'## Browser support',
];
for (const section of sections) {
assert.ok(
readmeContent.includes(section),
`README should contain section: ${section}`,
);
}
console.log('✓ Documentation is complete');
});
test('Example file exists and references index.css', () => {
const examplePath = path.join(__dirname, 'example.html');
assert.ok(fs.existsSync(examplePath), 'example.html should exist');
const exampleContent = fs.readFileSync(examplePath, 'utf8');
// Check that example references the CSS file
assert.ok(
exampleContent.includes('index.css'),
'Example should reference index.css',
);
// Check for function usage examples
const exampleFunctions = [
'--fluid-type',
'--spacing',
'--smooth-shadow',
'--conditional-radius',
];
for (const functionName of exampleFunctions) {
assert.ok(
exampleContent.includes(functionName),
`Example should demonstrate ${functionName}`,
);
}
console.log('✓ Example file is properly configured');
});
test('Package.json is properly configured', () => {
const packagePath = path.join(__dirname, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
assert.strictEqual(packageJson.name, 'css-extras', 'Package name should be css-extras');
assert.strictEqual(packageJson.exports, './index.css', 'Should export index.css');
assert.ok(packageJson.keywords.includes('css'), 'Keywords should include css');
assert.ok(packageJson.keywords.includes('functions'), 'Keywords should include functions');
console.log('✓ Package.json is valid');
});