mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
Write tests
This commit is contained in:
parent
612b878793
commit
313e65e00c
@ -52,7 +52,6 @@ export class DerivedVariables {
|
||||
private _detectAliases() {
|
||||
const newVariablesToDerive: string[] = [];
|
||||
for (const variable of this._variablesToDerive) {
|
||||
// If this is an alias, store it for processing later
|
||||
const [alias, value] = variable.split("=");
|
||||
if (value) {
|
||||
this._aliases[alias] = value;
|
||||
@ -99,3 +98,34 @@ export class DerivedVariables {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import pkg from "off-color";
|
||||
const {offColor} = pkg;
|
||||
|
||||
export function tests() {
|
||||
return {
|
||||
"Simple variable derivation": assert => {
|
||||
const deriver = new DerivedVariables({ "background-color": "#ff00ff" }, ["background-color--darker-5"], false);
|
||||
const result = deriver.toVariables();
|
||||
const resultColor = offColor("#ff00ff").darken(5/100).hex();
|
||||
assert.deepEqual(result, {"background-color--darker-5": resultColor});
|
||||
},
|
||||
|
||||
"For dark themes, lighten and darken are inverted": assert => {
|
||||
const deriver = new DerivedVariables({ "background-color": "#ff00ff" }, ["background-color--darker-5"], true);
|
||||
const result = deriver.toVariables();
|
||||
const resultColor = offColor("#ff00ff").lighten(5/100).hex();
|
||||
assert.deepEqual(result, {"background-color--darker-5": resultColor});
|
||||
},
|
||||
|
||||
"Aliases can be derived": assert => {
|
||||
const deriver = new DerivedVariables({ "background-color": "#ff00ff" }, ["my-awesome-alias=background-color","my-awesome-alias--darker-5"], false);
|
||||
const result = deriver.toVariables();
|
||||
const resultColor = offColor("#ff00ff").darken(5/100).hex();
|
||||
assert.deepEqual(result, {
|
||||
"my-awesome-alias": "#ff00ff",
|
||||
"my-awesome-alias--darker-5": resultColor,
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user