Made analytics mock, adjusted sandbox

This commit is contained in:
Blade Barringer
2015-06-22 12:52:24 -05:00
parent 8579bb86df
commit 78689e6e7c
4 changed files with 25 additions and 14 deletions

View File

@@ -36,6 +36,7 @@ module.exports = function(config) {
'common/dist/scripts/habitrpg-shared.js', 'common/dist/scripts/habitrpg-shared.js',
"test/spec/mocks/translations.js", "test/spec/mocks/translations.js",
"test/spec/mocks/sandbox.js",
"website/public/js/env.js", "website/public/js/env.js",

View File

@@ -5,16 +5,22 @@ describe('Auth Controller', function() {
describe('AuthCtrl', function(){ describe('AuthCtrl', function(){
var scope, ctrl, user, $httpBackend, $window; var scope, ctrl, user, $httpBackend, $window;
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) { beforeEach(function(){
$httpBackend = _$httpBackend_; module(function($provide) {
scope = $rootScope.$new(); $provide.value('Analytics', analyticsMock);
scope.loginUsername = 'user'; });
scope.loginPassword = 'pass';
$window = { location: { href: ""}, alert: sandbox.spy() };
user = { user: {}, authenticate: sandbox.spy() };
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user}); inject(function(_$httpBackend_, $rootScope, $controller) {
})); $httpBackend = _$httpBackend_;
scope = $rootScope.$new();
scope.loginUsername = 'user';
scope.loginPassword = 'pass';
$window = { location: { href: ""}, alert: sandbox.spy() };
user = { user: {}, authenticate: sandbox.spy() };
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
})
});
it('should log in users with correct uname / pass', function() { it('should log in users with correct uname / pass', function() {
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'}); $httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});

View File

@@ -0,0 +1,8 @@
'use strict'
var analyticsMock = {
login: sandbox.spy(),
register: sandbox.spy(),
updateUser: sandbox.spy(),
track: sandbox.spy()
};

View File

@@ -1,8 +1,4 @@
var sandbox; var sandbox = sinon.sandbox.create();
beforeEach(function() {
sandbox = sinon.sandbox.create();
});
afterEach(function() { afterEach(function() {
sandbox.restore(); sandbox.restore();