|
| 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 | + |
0 commit comments