mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
This pends a lot of tests that are failing due to translations not being loaded in the environment, as well as some issues with the page reload in groupServicesSpec. We removed the module declarations for habitrpg in each spec since that has been moved to specHelper.
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
describe('userServices', function() {
|
|
var $httpBackend, $window, user, STORAGE_USER_ID, STORAGE_SETTINGS_ID;
|
|
|
|
beforeEach(module('habitrpg'));
|
|
|
|
beforeEach(function(){
|
|
module(function($provide){
|
|
$window = {href: '', alert: sinon.spy(), location: {search: '', pathname: ''}};
|
|
$provide.value('$window', $window);
|
|
});
|
|
|
|
inject(function(_$httpBackend_, User, _STORAGE_USER_ID_, _STORAGE_SETTINGS_ID_) {
|
|
$httpBackend = _$httpBackend_;
|
|
user = User;
|
|
STORAGE_USER_ID = _STORAGE_USER_ID_;
|
|
STORAGE_SETTINGS_ID = _STORAGE_SETTINGS_ID_;
|
|
});
|
|
localStorage.removeItem(STORAGE_SETTINGS_ID);
|
|
localStorage.removeItem(STORAGE_USER_ID);
|
|
});
|
|
|
|
it('checks online status', function(){
|
|
user.online(true);
|
|
expect(user.settings.online).to.be.true;
|
|
user.online(false);
|
|
expect(user.settings.online).to.be.false;
|
|
})
|
|
|
|
it('saves user data to local storage', function(){
|
|
user.save();
|
|
var settings = JSON.parse(localStorage[STORAGE_SETTINGS_ID]);
|
|
var user_id = JSON.parse(localStorage[STORAGE_USER_ID]);
|
|
expect(settings).to.eql(user.settings);
|
|
expect(user_id).to.eql(user.user);
|
|
});
|
|
|
|
it('alerts when not authenticated', function(){
|
|
user.log();
|
|
expect($window.alert).to.have.been.calledWith("Not authenticated, can't sync, go to settings first.");
|
|
});
|
|
|
|
it('puts items in que queue', function(){
|
|
user.log({});
|
|
//TODO where does that null comes from?
|
|
expect(user.settings.sync.queue).to.eql([null, {}]);
|
|
});
|
|
});
|