-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
90 lines (76 loc) · 2.88 KB
/
index.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WCAG Color Contast tests</title>
<script src="jasmine/jasmine.js"></script>
<script src="jasmine/jasmine-html.js"></script>
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css"/>
<script src="wcag-color-contrast.js"></script>
</head>
<body>
<script>
(function () {
describe("Test validate", function() {
it('valid #FFFFFF', function() {
expect(WCAGColorContrast.validRGB('FFFFFF')).toBeTruthy();
});
it('valid #FFF', function() {
expect(WCAGColorContrast.validRGB('FFF')).toBeTruthy();
});
it('valid #111', function() {
expect(WCAGColorContrast.validRGB('111')).toBeTruthy();
});
it('valid #f11', function() {
expect(WCAGColorContrast.validRGB('f11')).toBeTruthy();
});
it('invalid #11', function() {
expect(WCAGColorContrast.validRGB('11')).toBeFalsy();
});
it('invalid #11123', function() {
expect(WCAGColorContrast.validRGB('11123')).toBeFalsy();
});
it('invalid #x12345', function() {
expect(WCAGColorContrast.validRGB('x12345')).toBeFalsy();
});
});
describe("Test contrast", function() {
it('#FFFFFF and #000000 must be 21', function() {
expect(WCAGColorContrast.ratio('FFFFFF', '000000')).toBe(21);
});
it('#000000 and #FFFFFF must be 21', function() {
expect(WCAGColorContrast.ratio('000000', 'FFFFFF')).toBe(21);
});
it('#000 and #FFF must be 21', function() {
expect(WCAGColorContrast.ratio('000', 'FFF')).toBe(21);
});
it('#123 and #FFF must be 16.15', function() {
expect(WCAGColorContrast.ratio('123', 'FFF').toFixed(2)).toBe('16.15');
});
it('#8883C4 and #1169FF must be 1.36', function() {
expect(WCAGColorContrast.ratio('8883C4', '1169FF').toFixed(2)).toBe('1.36');
});
it('#x123 and #1169FF must throw Exception', function() {
var test = function() {
WCAGColorContrast.ratio('x123', '1169FF')
};
expect(test).toThrow();
});
});
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 250;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function (spec) {
return htmlReporter.specFilter(spec);
};
window.onload = function () {
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</body>
</html>