-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
76 lines (61 loc) · 1.68 KB
/
test.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
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
const test = require('tape');
const requestAnimationFrame = global.requestAnimationFrame = require('raf');
// range-map - map a value from one range to another
const rangeMap = require('./range-map');
test('range-map', function(t) {
t.plan(1);
const expected = 75;
const res = rangeMap(5, {
min: 0,
max: 10
}, {
min: 50,
max: 100
});
t.same(res, expected);
});
// hex-mix - return hex value at % point between two colors
const hexMix = require('./hex-mix');
test('hex-mix', function(t) {
t.plan(1);
const expected = '#F07157';
const res = hexMix(0.5, {
from: '#f39631',
to: '#ed4c7c'
});
t.same(res, expected);
});
// set-interval-frame - run callback in request animation frame every setIntervals
const setIntervalFrame = require('./set-interval-frame');
test('set-interval-frame', function(t) {
t.plan(1);
const id = setIntervalFrame(function() {
t.pass('passed in 1 second');
clearInterval(id);
}, 1000);
});
// set-timeout-frame - run callback in request animation frame after setTimeout
const setTimeoutFrame = require('./set-timeout-frame');
test('set-interval-frame', function(t) {
t.plan(1);
const id = setTimeoutFrame(function() {
t.pass('passed in 1 second');
clearInterval(id);
}, 1000);
});
// deisplay-fade -
const displayFade = require('./display-fade');
test('display-fade-in', function(t) {
t.plan(1);
const id = displayFade.in({style: {display: '', opacity: 0}}, 1000, function() {
t.pass('faded in after 1 second');
clearInterval(id);
});
});
test('display-fade-out', function(t) {
t.plan(1);
const id = displayFade.out({style: {display: '', opacity: 0}}, 1000, function() {
t.pass('faded out after 1 second');
clearInterval(id);
});
});