@clearbit-dcp/clearbit.js-core
Version:
The hassle-free way to integrate analytics into any web application.
42 lines (31 loc) • 1.24 kB
JavaScript
;
var analytics = require('../lib');
var assert = require('proclaim');
describe('analytics', function() {
it('should expose a .VERSION', function() {
var pkg = require('../package.json');
assert.equal(analytics.VERSION, pkg.version);
});
describe('noConflict', function() {
var previousAnalyticsGlobal;
beforeEach(function() {
// Defined in test/support/global.js
previousAnalyticsGlobal = window.clearbit;
assert(previousAnalyticsGlobal, 'test harness expected global.clearbit to be defined but it is not');
});
afterEach(function() {
previousAnalyticsGlobal = undefined;
});
// TODO(ndhoule): this test and support/global.js are a little ghetto; we
// should refactor this to run in a separate test suite
it('should restore global.clearbit to its previous value', function() {
assert(global.clearbit === previousAnalyticsGlobal);
var analytics = require('../lib');
global.clearbit = analytics;
assert(global.clearbit === analytics);
var noConflictAnalytics = global.clearbit.noConflict();
assert(global.clearbit === previousAnalyticsGlobal);
assert(noConflictAnalytics === analytics);
});
});
});