forked from metalsmith/metalsmith.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetalsmith.test.js
More file actions
34 lines (27 loc) · 887 Bytes
/
metalsmith.test.js
File metadata and controls
34 lines (27 loc) · 887 Bytes
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
/* eslint-env jest */
const cheerio = require('cheerio');
const fs = require('fs');
const path = require('path');
const sitePath = path.join(__dirname, 'build');
test('build should have key files', () => {
const sitePaths = [
path.join(sitePath, 'index.html'),
path.join(sitePath, 'index.css'),
path.join(sitePath, 'index.js')
];
// Divider images
for (let i = 1; i < 7; i += 1) {
sitePaths.push(path.join(sitePath, '/img', `divider-${i}.png`));
}
sitePaths.forEach(filePath => {
expect(() => {
fs.accessSync(filePath);
}).not.toThrow();
});
});
test('index.html should have key elements', () => {
const indexContent = fs.readFileSync(path.join(sitePath, 'index.html')).toString();
const $ = cheerio.load(indexContent);
expect($('title').text()).toEqual('Metalsmith');
expect($('.PluginList li').length).toBeGreaterThan(0);
});