Skip to content
This repository was archived by the owner on Sep 7, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FacebookPixel.prototype.initialize = function(){
};
window.fbq.push = window.fbq;
window.fbq.loaded = true;
window.fbq.disablePushState = true; // disables automatic pageview tracking
window.fbq.agent = 'seg';
window.fbq.version = '2.0';
window.fbq.queue = [];
Expand Down
17 changes: 13 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,30 @@ describe('Facebook Pixel', function() {
describe('before loading', function() {
beforeEach(function() {
analytics.stub(facebookPixel, 'load');
analytics.initialize();
});

afterEach(function() {
facebookPixel.reset();
});

describe('#initialize', function() {
it('should load on initialize', function() {
analytics.initialize();
it('should call load on initialize', function() {
analytics.called(facebookPixel.load);
});
});

describe('#loaded', function() {
it('should set the correct agent and version', function() {
analytics.equal(window.fbq.agent, 'seg');
analytics.equal(window.fbq.version, '2.0');
});

it('should set disablePushState to true', function() {
analytics.equal(window.fbq.disablePushState, true);
});

it('should create fbq object', function() {
analytics.assert(window.fbq instanceof Function);
});
});
});

Expand Down