-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdevelop.plugins.resource-sitemap.spec.js
More file actions
73 lines (55 loc) · 1.71 KB
/
develop.plugins.resource-sitemap.spec.js
File metadata and controls
73 lines (55 loc) · 1.71 KB
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
import path from 'path';
import { Runner } from 'gallinago';
import { fileURLToPath } from 'url';
import chai from 'chai';
const expect = chai.expect;
describe('Develop Sitemap With: ', function() {
const LABEL = 'Sitemap Resource plugin output';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = fileURLToPath(new URL('.', import.meta.url));
const hostname = 'http://localhost';
const port = 1984;
let runner;
before(function() {
this.context = {
hostname: `${hostname}:${port}`
};
runner = new Runner();
});
describe(LABEL, function() {
before(async function() {
runner.setup(outputPath);
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 5000);
runner.runCommand(cliPath, 'develop', { async: true });
});
});
describe('Sitemap.xml', function() {
let response = {};
let text;
before(async function() {
response = await fetch(`${hostname}:${port}/sitemap.xml`);
text = await response.text();
});
it('should return a 200', function() {
expect(response.status).to.equal(200);
});
it('should return the correct content type', function() {
expect(response.headers.get('content-type')).to.equal('text/xml');
});
it('should contain loc element', function() {
const regex = /<loc>(http:\/\/www\.example\.com\/about\/)<\/loc>/;
const match = text.match(regex);
expect(match[1]).to.equal('http://www.example.com/about/');
});
});
});
after(function() {
runner.stopCommand();
runner.teardown([
path.join(outputPath, '.greenwood')
]);
});
});