Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(service): use $window/$windowProvider instead of window
Browse files Browse the repository at this point in the history
fix(docs): update ngdocs on storage-local.js
  • Loading branch information
tspaeth authored and knalli committed Feb 8, 2015
1 parent 8dcf3e2 commit bfa7b7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/service/storage-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ angular.module('pascalprecht.translate')
* @ngdoc object
* @name pascalprecht.translate.$translateLocalStorage
* @requires $window
* @requires $translateCookieStorage
*
* @description
* Abstraction layer for localStorage. This service is used when telling angular-translate
Expand Down
4 changes: 2 additions & 2 deletions src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* and similar to configure translation behavior directly inside of a module.
*
*/
angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY', function ($STORAGE_KEY) {
angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY', '$windowProvider', function ($STORAGE_KEY, $windowProvider) {

var $translationTable = {},
$preferredLanguage,
Expand Down Expand Up @@ -38,7 +38,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',

// tries to determine the browsers language
var getFirstBrowserLanguage = function () {
var nav = window.navigator,
var nav = $windowProvider.$get().navigator,
browserLanguagePropertyKeys = ['language', 'browserLanguage', 'systemLanguage', 'userLanguage'],
i,
language;
Expand Down
12 changes: 8 additions & 4 deletions test/unit/service/storage-local.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
describe('pascalprecht.translate', function () {

var $translateLocalStorage, $window;

describe('$translateLocalStorage', function () {

beforeEach(module('pascalprecht.translate', 'ngCookies'));

var $translateLocalStorage;

beforeEach(inject(function (_$translateLocalStorage_) {

beforeEach(inject(function (_$translateLocalStorage_, _$window_) {
//beforeEach(inject(function (_$translateLocalStorage_) {
$translateLocalStorage = _$translateLocalStorage_;
$window = _$window_;
}));

it('should be defined', function () {
Expand Down Expand Up @@ -44,7 +48,7 @@ describe('pascalprecht.translate', function () {

beforeEach(module('pascalprecht.translate', 'ngCookies', function ($translateProvider) {
// ensure that the local storage is cleared.
window.localStorage.clear();
$window.localStorage.clear();
$translateProvider
.translations('de_DE', {
'EXISTING_TRANSLATION_ID': 'foo',
Expand All @@ -59,7 +63,7 @@ describe('pascalprecht.translate', function () {
}));

it('should use localstorage', function () {
inject(function ($window, $translate) {
inject(function ($translate) {
expect($translate.storage().get($translate.storageKey())).toEqual('de_DE');
});
});
Expand Down

0 comments on commit bfa7b7b

Please sign in to comment.