Created
November 12, 2013 21:25
-
-
Save 0x-r4bbit/7439016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('useLocalStorage()', function () { | |
beforeEach(module('pascalprecht.translate', 'ngCookies', function ($translateProvider) { | |
// ensure that the local storage is cleared. | |
window.localStorage.clear(); | |
$translateProvider.translations('de_DE', { | |
'EXISTING_TRANSLATION_ID': 'foo', | |
'ANOTHER_ONE': 'bar', | |
'TRANSLATION_ID': 'Lorem Ipsum {{value}}', | |
'TRANSLATION_ID_2': 'Lorem Ipsum {{value}} + {{value}}', | |
'TRANSLATION_ID_3': 'Lorem Ipsum {{value + value}}', | |
'YET_ANOTHER': 'Hallo da!' | |
}); | |
$translateProvider.preferredLanguage('de_DE'); | |
$translateProvider.useLocalStorage(); | |
})); | |
iit('should use localstorage', function () { | |
inject(function ($window, $translate, $rootScope, $q, $timeout) { | |
var deferred = $q.defer(), | |
promise = deferred.promise, | |
result; | |
promise.then(function (value) { | |
result = value; | |
}); | |
$translate.storage().get($translate.storageKey()).then(function (value) { | |
deferred.resolve(value); | |
}, function () { | |
console.log('cant get!'); | |
}); | |
$rootScope.$digest(); | |
expect(result).toEqual('de_DE'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment