Skip to content

Commit b4434bc

Browse files
committed
Support tests of toSource() with "expectedToSource" property
1 parent 06f2283 commit b4434bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ for (let i = 0; i < total; i++) {
6363
log(ansidiff.lines(expected_dump, dump || ''));
6464
failures++;
6565
}
66+
} else if (test.expectedToSource) {
67+
const source = Array.isArray(result) ? result.map(x => x.toSource()).join('') : result.toSource();
68+
const expected_source = test.expectedToSource;
69+
if (source == expected_source) {
70+
log(`Test ${i} of ${total}: PASS`);
71+
} else {
72+
log(`Test ${i} of ${total}: FAIL\nCSS: ${test.css}\nTokens: ${tokens.join(' ')}`);
73+
log(`Unexpected toSource(): ` + ansidiff.lines(expected_source, source || ''));
74+
failures++;
75+
}
6676
} else {
6777
// no specified test, fallback to pass
6878
log(`Test ${i} of ${total}: PASS`);

0 commit comments

Comments
 (0)