can-globals
Advanced tools
Comparing version 0.2.2 to 0.2.3
'use strict'; | ||
var Globals = require('./can-globals-proto'); | ||
var QUnit = require('./test-wrapper'); | ||
var sinon = require('sinon'); | ||
var spy = require('./spy'); | ||
var globals; | ||
function mapEvents(spy){ | ||
return spy.args.reduce(function(acc, cur) { | ||
return acc.concat(cur[0]); | ||
return spy.calls.reduce(function(acc, cur) { | ||
return acc.concat(cur.calledWith[0]); | ||
}, []); | ||
@@ -62,5 +62,3 @@ } | ||
QUnit.test('define with cache disabled', function() { | ||
var getter = sinon.spy(function(){ | ||
return 'bar'; | ||
}); | ||
var getter = spy('bar'); | ||
globals = new Globals(); | ||
@@ -75,5 +73,3 @@ globals.define('foo', getter, false); | ||
QUnit.test('define with cache enabled', function() { | ||
var getter = sinon.spy(function(){ | ||
return 'bar'; | ||
}); | ||
var getter = spy('bar'); | ||
globals = new Globals(); | ||
@@ -84,3 +80,3 @@ globals.define('foo', getter); | ||
}, 5); | ||
equal(getter.calledOnce, true); | ||
equal(getter.callCount, 1); | ||
}); | ||
@@ -119,5 +115,5 @@ | ||
var globals = new Globals(); | ||
var bar = sinon.spy(function(){ | ||
var bar = function() { | ||
return 'bar'; | ||
}); | ||
}; | ||
globals.define('foo', bar); | ||
@@ -141,5 +137,3 @@ globals.getKeyValue('foo'); | ||
var globals = new Globals(); | ||
var bar = sinon.spy(function(){ | ||
return 'bar'; | ||
}); | ||
var bar = spy('bar'); | ||
globals.define('foo', bar); | ||
@@ -152,3 +146,3 @@ globals.getKeyValue('foo'); | ||
globals.getKeyValue('foo'); | ||
equal(bar.calledTwice, true); | ||
equal(bar.callCount, 2); | ||
}); | ||
@@ -158,3 +152,3 @@ | ||
var globals = new Globals(); | ||
var handler = sinon.spy(); | ||
var handler = spy(); | ||
globals.define('test', 'default'); | ||
@@ -175,3 +169,3 @@ globals.define('foo', 'bar'); | ||
var globals = new Globals(); | ||
var handler = sinon.spy(); | ||
var handler = spy(); | ||
globals.define('test', 'foo'); | ||
@@ -181,3 +175,3 @@ globals.onKeyValue('test', handler); | ||
globals.setKeyValue('test', 'updated'); | ||
equal(handler.called, false); | ||
equal(handler.callCount, 0); | ||
}); | ||
@@ -209,8 +203,4 @@ | ||
var globals = new Globals(); | ||
var bar = sinon.spy(function(){ | ||
return 'bar'; | ||
}); | ||
var qux = sinon.spy(function(){ | ||
return 'qux'; | ||
}); | ||
var bar = spy('bar'); | ||
var qux = spy('qux'); | ||
globals.define('foo', bar); | ||
@@ -227,4 +217,4 @@ globals.define('baz', qux); | ||
}, 5); | ||
equal(bar.calledTwice, true); | ||
equal(qux.calledTwice, true); | ||
equal(bar.callCount, 2); | ||
equal(qux.callCount, 2); | ||
}); | ||
@@ -234,4 +224,4 @@ | ||
var globals = new Globals(); | ||
var fooHandler = sinon.spy(); | ||
var barHandler = sinon.spy(); | ||
var fooHandler = spy(); | ||
var barHandler = spy(); | ||
globals.define('foo', true); | ||
@@ -244,4 +234,4 @@ globals.define('bar', true); | ||
globals.reset(); | ||
equal(fooHandler.called, true); | ||
equal(barHandler.called, true); | ||
equal(fooHandler.callCount, 1); | ||
equal(barHandler.callCount, 1); | ||
}); | ||
@@ -251,3 +241,3 @@ | ||
var globals = new Globals(); | ||
var spy = sinon.spy(); | ||
var foo = spy(); | ||
globals.setKeyValue('foo', function(){ | ||
@@ -257,7 +247,7 @@ return function(){}; | ||
var fooExport = globals.makeExport('foo'); | ||
fooExport(spy); | ||
fooExport(foo); | ||
QUnit.equal(typeof fooExport(), 'function'); | ||
QUnit.equal(spy.callCount, 0); | ||
QUnit.equal(foo.callCount, 0); | ||
fooExport()(); | ||
QUnit.equal(spy.callCount, 1); | ||
QUnit.equal(foo.callCount, 1); | ||
}); |
{ | ||
"name": "can-globals", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "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 alerting on value changes, both specific to a key and for any key.", | ||
@@ -48,6 +48,4 @@ "main": "can-globals.js", | ||
"bit-docs": "0.0.7", | ||
"formatio": "^1.2.0", | ||
"jshint": "^2.9.5", | ||
"qunitjs": "^2.4.0", | ||
"sinon": "^3.0.0", | ||
"steal": "^1.5.6", | ||
@@ -58,9 +56,2 @@ "steal-qunit": "^1.0.1", | ||
}, | ||
"steal": { | ||
"meta": { | ||
"formatio": { | ||
"format": "cjs" | ||
} | ||
} | ||
}, | ||
"bit-docs": { | ||
@@ -67,0 +58,0 @@ "dependencies": { |
@@ -6,2 +6,3 @@ # can-globals | ||
[![npm version](https://badge.fury.io/js/can-globals.svg)](https://www.npmjs.com/package/can-globals) | ||
[![Build Status](https://travis-ci.org/canjs/can-globals.svg?branch=master)](https://travis-ci.org/canjs/can-globals) | ||
@@ -8,0 +9,0 @@ An environment agnostic container for global variables. Useful for testing and server-side rendering (SSR), typically used internally by CanJS. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34069
7
30
837
25