-
-
Notifications
You must be signed in to change notification settings - Fork 257
/
themes_test.js
68 lines (55 loc) · 1.88 KB
/
themes_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
'use strict';
const assert = require('assert').strict;
const path = require('path');
const { htmlEncode } = require('htmlencode');
const staticify = require('staticify')(path.join(__dirname, '../public'));
const helpers = require('./test_helpers.js');
describe('themes', () => {
const config = helpers.getConfig();
const uri = helpers.getURI('themes');
let response = {};
before((done) => {
helpers.prefetch(uri, (res) => {
response = res;
done();
});
});
after((done) => {
helpers.stopServer(done);
});
it('works', (done) => {
helpers.assert.itWorks(response.statusCode, done);
});
it('valid html', (done) => {
helpers.assert.validHTML(response, done);
});
it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
it('has page header', (done) => {
helpers.assert.pageHeader('Bootstrap Themes', response, done);
});
it('has body class', (done) => {
helpers.assert.bodyClass('page-themes', response, done);
});
config.themesAd.forEach((theme) => {
describe(theme.name, () => {
it('has name', (done) => {
assert.ok(response.body.includes(htmlEncode(theme.name)),
`Expects response body to include "${theme.name}"`);
done();
});
it('has image', (done) => {
const img = staticify.getVersionedPath(theme.img);
assert.ok(response.body.includes(img),
`Expects response body to include "${img}"`);
done();
});
it('has url', (done) => {
assert.ok(response.body.includes(htmlEncode(theme.url)),
`Expects response body to include "${theme.url}"`);
done();
});
});
});
});