Skip to content

Instantly share code, notes, and snippets.

@0x-r4bbit
Created November 12, 2013 21:25
Show Gist options
  • Save 0x-r4bbit/7439016 to your computer and use it in GitHub Desktop.
Save 0x-r4bbit/7439016 to your computer and use it in GitHub Desktop.
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