forked from nagoshiashumari/Rpg-Awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpg-awesome-tests.js
59 lines (51 loc) · 1.89 KB
/
rpg-awesome-tests.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
/* global
document: false,
HTTP: false,
Tinytest: false
*/
'use strict';
var fontAssets = [
'rpgawesome-webfont.eot',
'rpgawesome-webfont.svg',
'rpgawesome-webfont.ttf',
'rpgawesome-webfont.woff',
'rpgawesome-webfont.woff2',
'RpgAwesome.otf',
];
// Check that the font files are downloadable. Meteor places assets at /packages/<packageName>/.
fontAssets.forEach(function (filename) {
Tinytest.addAsync(filename + ' font is shipped', function (test, done) {
var path = '/packages/nagoshiashumari_rpg-awesome/fonts/' + filename;
HTTP.get(path, function callback(error, result) {
if (error) {
test.fail({message: 'Font failed to load'});
}
else {
var errStr = filename + ' font could not be downloaded';
test.isTrue(result.content.length > 1000, errStr);
}
done();
});
});
})
;
// Visual check.
// Fonts are set by font-awesome.css in @font-face { src: url('../fonts/...') }.
// TODO How does Meteor find those occurrences in the source and resolve them
// to /packages/<packageName>/fonts/... ?
Tinytest.addAsync('Visual check', function (test, done) {
var iconsDropZone = document.createElement('div');
document.body.appendChild(iconsDropZone);
// TODO ideally we'd get src/test.html straight from this repo, but no idea
// how to do this from TinyTest
HTTP.get('https://rawgit.com/nagoshiashumari/Rpg-Awesome/gh-pages/index.html', function callback(error, result) {
if (error) {
test.fail('Error getting the icons. Do we have an Internet connection to rawgit.com?');
} else {
// [^] matches across newlines. Exclude the Stacked Icons section and below, because they transclude some other HTML.
iconsDropZone.innerHTML = result.content.match(/<section[^]+(?=<h3>Stacked)/);
test.ok({message: 'Test passed if the icons look OK.'});
}
done();
});
});