mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Made analytics mock, adjusted sandbox
This commit is contained in:
@@ -36,6 +36,7 @@ module.exports = function(config) {
|
||||
'common/dist/scripts/habitrpg-shared.js',
|
||||
|
||||
"test/spec/mocks/translations.js",
|
||||
"test/spec/mocks/sandbox.js",
|
||||
|
||||
"website/public/js/env.js",
|
||||
|
||||
|
||||
@@ -5,7 +5,12 @@ describe('Auth Controller', function() {
|
||||
describe('AuthCtrl', function(){
|
||||
var scope, ctrl, user, $httpBackend, $window;
|
||||
|
||||
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
|
||||
beforeEach(function(){
|
||||
module(function($provide) {
|
||||
$provide.value('Analytics', analyticsMock);
|
||||
});
|
||||
|
||||
inject(function(_$httpBackend_, $rootScope, $controller) {
|
||||
$httpBackend = _$httpBackend_;
|
||||
scope = $rootScope.$new();
|
||||
scope.loginUsername = 'user';
|
||||
@@ -14,7 +19,8 @@ describe('Auth Controller', function() {
|
||||
user = { user: {}, authenticate: sandbox.spy() };
|
||||
|
||||
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
||||
}));
|
||||
})
|
||||
});
|
||||
|
||||
it('should log in users with correct uname / pass', function() {
|
||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
||||
|
||||
8
test/spec/mocks/analyticsMock.js
Normal file
8
test/spec/mocks/analyticsMock.js
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
var analyticsMock = {
|
||||
login: sandbox.spy(),
|
||||
register: sandbox.spy(),
|
||||
updateUser: sandbox.spy(),
|
||||
track: sandbox.spy()
|
||||
};
|
||||
@@ -1,8 +1,4 @@
|
||||
var sandbox;
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox = sinon.sandbox.create();
|
||||
});
|
||||
var sandbox = sinon.sandbox.create();
|
||||
|
||||
afterEach(function() {
|
||||
sandbox.restore();
|
||||
|
||||
Reference in New Issue
Block a user