Skip to content

Commit

Permalink
Add tests for canonical URL
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 16, 2019
1 parent ce680a6 commit a4fbaf2
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/404_test.js
Expand Up @@ -25,6 +25,10 @@ describe('404', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/404/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/about_test.js
Expand Up @@ -22,6 +22,10 @@ describe('About', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/about/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/books_test.js
Expand Up @@ -27,6 +27,10 @@ describe('books', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/books/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/bootlint_legacy_test.js
Expand Up @@ -24,6 +24,10 @@ describe('legacy/bootlint', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/legacy/bootlint/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/bootlint_test.js
Expand Up @@ -30,6 +30,10 @@ describe('bootlint', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/bootlint/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/bootstrap_legacy_test.js
Expand Up @@ -24,6 +24,10 @@ describe('legacy/bootstrap', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/legacy/bootstrap/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/bootswatch4_test.js
Expand Up @@ -29,6 +29,10 @@ describe('bootswatch4', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/bootswatch/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/bootswatch_legacy_test.js
Expand Up @@ -29,6 +29,10 @@ describe('bootswatch3', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/legacy/bootswatch/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/fontawesome_legacy_test.js
Expand Up @@ -24,6 +24,10 @@ describe('legacy/fontawesome', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/legacy/fontawesome/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/fontawesome_test.js
Expand Up @@ -30,6 +30,10 @@ describe('fontawesome', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/fontawesome/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/index_test.js
Expand Up @@ -30,6 +30,10 @@ describe('index', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/integrations_test.js
Expand Up @@ -27,6 +27,10 @@ describe('integrations', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/integrations/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/jobs_test.js
Expand Up @@ -22,6 +22,10 @@ describe('jobs', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/jobs/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/privacy_policy_test.js
Expand Up @@ -22,6 +22,10 @@ describe('privacy-policy', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/privacy-policy/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
4 changes: 4 additions & 0 deletions test/showcase_test.js
Expand Up @@ -27,6 +27,10 @@ describe('showcase', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/showcase/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down
8 changes: 8 additions & 0 deletions test/test_helpers.js
Expand Up @@ -140,6 +140,13 @@ function assertPageHeader(txt, res, cb) {
cb();
}

function assertCanonicalUrl(str, res, cb) {
const expected = `<link rel="canonical" href="${new URL(str, config.siteurl)}">`;

assert.ok(res.body.includes(expected), 'Expects page to have a canonical URL');
cb();
}

function assertPageBodyClass(bodyClass, res, cb) {
const expected = `<body class="${bodyClass}`;

Expand Down Expand Up @@ -186,6 +193,7 @@ module.exports = {
stopServer,
assert: {
authors: assertAuthors,
canonicalUrl: assertCanonicalUrl,
bodyClass: assertPageBodyClass,
itWorks: assertItWorks,
pageHeader: assertPageHeader,
Expand Down
4 changes: 4 additions & 0 deletions test/themes_test.js
Expand Up @@ -31,6 +31,10 @@ describe('themes', () => {
.then(() => done());
});

it('contains canonical URL', (done) => {
helpers.assert.canonicalUrl('/themes/', response, done);
});

it('contains authors', (done) => {
helpers.assert.authors(response, done);
});
Expand Down

0 comments on commit a4fbaf2

Please sign in to comment.