|
| 1 | +// Setup global test variables |
| 2 | +var $rootScope, $q, $log; |
| 3 | + |
| 4 | +// Helper globals |
| 5 | +var fail = function (msg) { |
| 6 | + assert.equal('should not reach this!: ' + msg, 'failure'); |
| 7 | + }, |
| 8 | + TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () {}], |
| 9 | + TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () {}], |
| 10 | + TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () {}], |
| 11 | + TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () {}], |
| 12 | + TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () {}], |
| 13 | + TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () {}], |
| 14 | + TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () {}], |
| 15 | + TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () {}], |
| 16 | + TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false]; |
| 17 | + |
| 18 | +angular.module('jmdobry.angular-data', ['ng', 'jmdobry.binary-heap', 'ngMock']); |
| 19 | + |
| 20 | +beforeEach(module('jmdobry.angular-data')); |
| 21 | + |
| 22 | +// Setup before each test |
| 23 | +beforeEach(inject(function (_$rootScope_, _$q_) { |
| 24 | + // Setup global mocks |
| 25 | + $q = _$q_; |
| 26 | + $rootScope = _$rootScope_; |
| 27 | + $log = { |
| 28 | + warn: function () {}, |
| 29 | + log: function () {}, |
| 30 | + info: function () {}, |
| 31 | + error: function () {}, |
| 32 | + debug: function () {} |
| 33 | + }; |
| 34 | + |
| 35 | + // Setup global spies |
| 36 | + sinon.spy($log, 'warn'); |
| 37 | + sinon.spy($log, 'log'); |
| 38 | + sinon.spy($log, 'info'); |
| 39 | + sinon.spy($log, 'error'); |
| 40 | + sinon.spy($log, 'debug'); |
| 41 | +})); |
| 42 | + |
| 43 | +// Clean up after each test |
| 44 | +afterEach(function () { |
| 45 | + // Tear down global spies |
| 46 | + $log.warn.restore(); |
| 47 | + $log.log.restore(); |
| 48 | + $log.info.restore(); |
| 49 | + $log.error.restore(); |
| 50 | + $log.debug.restore(); |
| 51 | +}); |
0 commit comments