Skip to content

Commit

Permalink
add initialization test with existing script tag
Browse files Browse the repository at this point in the history
  • Loading branch information
fargerio committed Jun 15, 2018
1 parent 73ea7f6 commit 4eaca03
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,24 @@ describe('piwik-react-router client tests', function () {
assert.isTrue(piwikScripts.length === 0);
});

it ('should inject piwik.js if another script object is already present', () => {
let emptyScriptTag = document.createElement('script');
document.getElementsByTagName('head')[0].appendChild(emptyScriptTag);

const piwikReactRouter = testUtils.requireNoCache('../')({
url: 'foo.bar',
siteId: 1,
injectScript: true
});

var allScripts = [].slice.call(window.document.scripts);
var piwikScripts = allScripts.filter((script) => {
return script.src.indexOf('piwik.js') !== -1;
});

assert.isTrue(piwikScripts.length >= 1);
});

it ('should warn about a missing siteId if opts.injectScript is disabled and the external piwik script is not initialized', () => {
let warningSpy = sinon.spy();
const piwikReactRouter = testUtils.requireNoCache('../', {
Expand Down

0 comments on commit 4eaca03

Please sign in to comment.