colorize tests: add color, normalize type

This commit is contained in:
Martin Aeschlimann 2016-04-11 21:14:30 +02:00
parent 4431fb83c1
commit 3a486b145e
2 changed files with 8 additions and 6 deletions

View file

@ -25,9 +25,7 @@ function assertUnchangedTokens(testFixurePath:string, done) {
try {
assert.deepEqual(data, previousData);
} catch (e) {
fs.writeFileSync(resultPath, JSON.stringify(data, null, '\t'), { mode: 'w' });
let errorResultPath = join(resultsFolderPath, fileName.replace('.', '_') + '.previous.json');
fs.writeFileSync(errorResultPath, JSON.stringify(previousData, null, '\t'), { mode: 'w' });
fs.writeFileSync(resultPath, JSON.stringify(data, null, '\t'), { flag: 'w' });
throw e;
}
} else {

View file

@ -57,9 +57,13 @@ class Snapper {
return element;
}
private normalizeType(type: string) : string {
return type.split('.').sort().join('.');
}
private getStyle(testNode: Element, scope: string) : string {
testNode.className = 'token ' + scope;
testNode.className = 'token ' + scope.replace(/\./g, ' ');
let cssStyles = window.getComputedStyle(testNode);
if (cssStyles) {
@ -110,7 +114,7 @@ class Snapper {
let testNode = this.getTestNode(themeId);
let themeName = getThemeName(themeId);
data.forEach(entry => {
entry.r[themeName] = this.getMatchedCSSRule(testNode, entry.t);
entry.r[themeName] = this.getMatchedCSSRule(testNode, entry.t) + ' ' + this.getStyle(testNode, entry.t)
});
}
});
@ -133,7 +137,7 @@ class Snapper {
let content = model.getValueInRange({ startLineNumber: lineNumber, endLineNumber: lineNumber, startColumn: tokenInfo.startColumn, endColumn: tokenInfo.endColumn});
result.push({
c: content,
t: tokenInfo.token.type,
t: this.normalizeType(tokenInfo.token.type),
r: {}
});
}