Skip to content

Commit 597816f

Browse files
committed
Add tests
1 parent 998fd55 commit 597816f

File tree

15 files changed

+104
-0
lines changed

15 files changed

+104
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
"env": {
3+
"commonjs": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"globals": {
9+
"Atomics": "readonly",
10+
"SharedArrayBuffer": "readonly",
11+
"describe": "readonly"
12+
},
13+
"parserOptions": {
14+
"ecmaVersion": 2018
15+
},
16+
"rules": {
17+
}
18+
};

test/index.test.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const {expect, test} = require('@oclif/test');
2+
const cmd = require('../src');
3+
4+
describe('#index', () => {
5+
6+
test
7+
.stdout()
8+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site/about']))
9+
.it('basic sitemap xml', ctx => {
10+
expect(ctx.stdout).to.contain('<loc>https://example.com</loc>');
11+
expect(ctx.stdout).to.contain('<?xml version="1.0" encoding="UTF-8"?>');
12+
expect(ctx.stdout).to.contain('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
13+
});
14+
15+
test
16+
.stdout()
17+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site/about', '--text']))
18+
.it('output text', ctx => {
19+
expect(ctx.stdout).to.equal('https://example.com\n\n');
20+
});
21+
22+
test
23+
.stdout()
24+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site', '--priority', 'about/index.html=0.1']))
25+
.it('priority', ctx => {
26+
expect(ctx.stdout).to.contain('<priority>0.1</priority>');
27+
});
28+
29+
test
30+
.stdout()
31+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site', '--changefreq', 'about/index.html=weekly']))
32+
.it('changefreq', ctx => {
33+
expect(ctx.stdout).to.contain('<changefreq>weekly</changefreq>');
34+
});
35+
36+
test
37+
.stdout()
38+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site']))
39+
.it('clean urls', ctx => {
40+
expect(ctx.stdout).to.not.contain('.html');
41+
expect(ctx.stdout).to.contain('post-1</loc>');
42+
expect(ctx.stdout).to.contain('https://example.com/blog/events/event-1</loc>');
43+
});
44+
45+
test
46+
.stdout()
47+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site', '--no-clean']))
48+
.it('no clean urls', ctx => {
49+
expect(ctx.stdout).to.contain('https://example.com/index.html</loc>');
50+
expect(ctx.stdout).to.contain('https://example.com/blog/news/post-2.html</loc>');
51+
});
52+
53+
test
54+
.stdout()
55+
.do(() => cmd.run(['https://example.com', '--root', 'test/test-site', '--slash']))
56+
.it('trailing slash', ctx => {
57+
expect(ctx.stdout).to.contain('https://example.com/</loc>');
58+
expect(ctx.stdout).to.contain('https://example.com/blog/mixed-1/</loc>');
59+
});
60+
61+
62+
/*
63+
test
64+
.stdout()
65+
.do(() => cmd.run([]))
66+
.it('the test', ctx => {
67+
expect(ctx.stdout)
68+
});
69+
*/
70+
71+
});
72+

test/mocha.opts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--recursive
2+
--reporter spec
3+
--timeout 5000

test/test-site/404.html

Whitespace-only changes.

test/test-site/about/index.html

Whitespace-only changes.

test/test-site/blog/events/event-1.html

Whitespace-only changes.

test/test-site/blog/events/event-2.html

Whitespace-only changes.

test/test-site/blog/index.html

Whitespace-only changes.

test/test-site/blog/mixed-1.html

Whitespace-only changes.

0 commit comments

Comments
 (0)