-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-methods.js
49 lines (38 loc) · 1.01 KB
/
test-methods.js
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
function describe( testString, tests ) {
console.group( testString );
tests();
console.groupEnd();
}
function it( testString, test ) {
let testResult = test();
let color = ( false === testResult.result ) ? 'red' : 'green';
console.log( `%c ${testString} ${testResult.message}`, `color:${color}` );
}
function assertEquals( value1, value2 ) {
let message = '';
let expression = value1 % value2 < 1;
if ( false === expression ) {
message = '\n \t Fail: ' + (value1 % value2).toFixed(1);
}
return {
result: expression,
message: message
};
}
function assertGreaterThan( value1, value2 ) {
let message = '';
let expression = value1 > value2;
if ( false === expression ) {
message = '\n \t Fail: ' + (value1 % value2).toFixed(1);
}
return {
result: expression,
message: message
};
}
function $( selector ) {
return document.querySelector( selector );
}
function getCustomPropertyValue( selector, propertyName ) {
return window.getComputedStyle( $( selector ) ).getPropertyValue( propertyName );
}