diff options
author | Phillip Johnsen <johphi@gmail.com> | 2017-01-25 21:54:34 +0100 |
---|---|---|
committer | Phillip Johnsen <johphi@gmail.com> | 2017-01-25 21:54:34 +0100 |
commit | 01b90ee1db9276d6c1af0e6e0352fd4759ebb68d (patch) | |
tree | 4cc05f5854b0b9f1ff4c4b4c84ccddf8eb5e1b66 /test/doctool | |
parent | 124d155f5ec22568c740d4a465f4496cda44deb6 (diff) | |
download | node-new-01b90ee1db9276d6c1af0e6e0352fd4759ebb68d.tar.gz |
tools,doc: add Google Analytics tracking.
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:
```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```
By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.
It respects "Do Not Track" settings end users might have in their
browser.
Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.
PR-URL: https://github.com/nodejs/node/pull/6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test/doctool')
-rw-r--r-- | test/doctool/test-doctool-html.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index e5c825aebb..442381b54d 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -72,11 +72,18 @@ const testData = [ '<p>I exist and am being linked to.</p>' + '<!-- [end-include:doc_inc_2.md] -->' }, + { + file: path.join(common.fixturesDir, 'sample_document.md'), + html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' + + '<li>Bluefish</li></ol>', + analyticsId: 'UA-67020396-1' + }, ]; testData.forEach((item) => { // Normalize expected data by stripping whitespace const expected = item.html.replace(/\s/g, ''); + const includeAnalytics = typeof item.analyticsId !== 'undefined'; fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); @@ -89,6 +96,7 @@ testData.forEach((item) => { filename: 'foo', template: 'doc/template.html', nodeVersion: process.version, + analytics: item.analyticsId, }, common.mustCall((err, output) => { assert.ifError(err); @@ -97,6 +105,16 @@ testData.forEach((item) => { // Assert that the input stripped of all whitespace contains the // expected list assert.notStrictEqual(actual.indexOf(expected), -1); + + // Testing the insertion of Google Analytics script when + // an analytics id is provided. Should not be present by default + if (includeAnalytics) { + assert.notStrictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was not present'); + } else { + assert.strictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was present'); + } })); })); })); |