UNPKG

can-globals

Version:

This module provides a dependency injection container. Modules may define a key and specify a default value (which can be static, cached lazy, or dynamic lazy), but other code can set and reset the value as needed. There is also an event system, for alert

35 lines (29 loc) 780 B
'use strict'; var getGlobal = require('./global'); var QUnit = require('../../test-wrapper'); function isBrowserWindow(){ return typeof window !== 'undefined' && typeof document !== 'undefined' && typeof SimpleDOM === 'undefined'; } QUnit.module('can-globals/global/global'); QUnit.test('basics', function(assert) { if(isBrowserWindow()) { assert.ok(getGlobal() === window); } else { assert.ok(getGlobal() === global); } }); if(!isBrowserWindow()) { QUnit.module('in Node with fake window', { beforeEach: function(assert) { this.oldWindow = global.window; global.window = {}; }, afterEach: function(assert) { global.window = this.oldWindow; } }); QUnit.test('Gets the Node global', function(assert) { assert.ok(getGlobal() === global); }); }