"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/core/locale/locale.service.spec.ts" between
dspace-angular-dspace-7.0.tar.gz and dspace-angular-dspace-7.1.tar.gz

About: dspace-angular is the Angular-based frontend of DSpace, a digital repository system to capture, store, index, preserve and redistribute an organization’s research material in digital formats.

locale.service.spec.ts  (dspace-angular-dspace-7.0):locale.service.spec.ts  (dspace-angular-dspace-7.1)
skipping to change at line 24 skipping to change at line 24
describe('LocaleService test suite', () => { describe('LocaleService test suite', () => {
let service: LocaleService; let service: LocaleService;
let serviceAsAny: any; let serviceAsAny: any;
let cookieService: CookieService; let cookieService: CookieService;
let translateService: TranslateService; let translateService: TranslateService;
let window; let window;
let spyOnGet; let spyOnGet;
let spyOnSet; let spyOnSet;
let authService; let authService;
let routeService; let routeService;
let document;
authService = jasmine.createSpyObj('AuthService', { authService = jasmine.createSpyObj('AuthService', {
isAuthenticated: jasmine.createSpy('isAuthenticated'), isAuthenticated: jasmine.createSpy('isAuthenticated'),
isAuthenticationLoaded: jasmine.createSpy('isAuthenticationLoaded') isAuthenticationLoaded: jasmine.createSpy('isAuthenticationLoaded')
}); });
const langList = ['en', 'it', 'de']; const langList = ['en', 'it', 'de'];
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
return TestBed.configureTestingModule({ return TestBed.configureTestingModule({
skipping to change at line 46 skipping to change at line 47
loader: { loader: {
provide: TranslateLoader, provide: TranslateLoader,
useClass: TranslateLoaderMock useClass: TranslateLoaderMock
} }
}), }),
], ],
providers: [ providers: [
{ provide: CookieService, useValue: new CookieServiceMock() }, { provide: CookieService, useValue: new CookieServiceMock() },
{ provide: AuthService, userValue: authService }, { provide: AuthService, userValue: authService },
{ provide: RouteService, useValue: routeServiceStub }, { provide: RouteService, useValue: routeServiceStub },
{ provide: Document, useValue: document },
] ]
}); });
})); }));
beforeEach(() => { beforeEach(() => {
cookieService = TestBed.inject(CookieService); cookieService = TestBed.inject(CookieService);
translateService = TestBed.inject(TranslateService); translateService = TestBed.inject(TranslateService);
routeService = TestBed.inject(RouteService); routeService = TestBed.inject(RouteService);
window = new NativeWindowRef(); window = new NativeWindowRef();
service = new LocaleService(window, cookieService, translateService, authSer document = { documentElement: { lang: 'en' } };
vice, routeService); service = new LocaleService(window, cookieService, translateService, authSer
vice, routeService, document);
serviceAsAny = service; serviceAsAny = service;
spyOnGet = spyOn(cookieService, 'get'); spyOnGet = spyOn(cookieService, 'get');
spyOnSet = spyOn(cookieService, 'set'); spyOnSet = spyOn(cookieService, 'set');
}); });
describe('getCurrentLanguageCode', () => { describe('getCurrentLanguageCode', () => {
it('should return language saved on cookie', () => { it('should return language saved on cookie', () => {
spyOnGet.and.returnValue('de'); spyOnGet.and.returnValue('de');
expect(service.getCurrentLanguageCode()).toBe('de'); expect(service.getCurrentLanguageCode()).toBe('de');
}); });
skipping to change at line 117 skipping to change at line 120
expect(translateService.use).toHaveBeenCalledWith('it'); expect(translateService.use).toHaveBeenCalledWith('it');
expect(service.saveLanguageCodeToCookie).toHaveBeenCalledWith('it'); expect(service.saveLanguageCodeToCookie).toHaveBeenCalledWith('it');
}); });
it('should set the current language', () => { it('should set the current language', () => {
spyOn(service, 'getCurrentLanguageCode').and.returnValue('es'); spyOn(service, 'getCurrentLanguageCode').and.returnValue('es');
service.setCurrentLanguageCode(); service.setCurrentLanguageCode();
expect(translateService.use).toHaveBeenCalledWith('es'); expect(translateService.use).toHaveBeenCalledWith('es');
expect(service.saveLanguageCodeToCookie).toHaveBeenCalledWith('es'); expect(service.saveLanguageCodeToCookie).toHaveBeenCalledWith('es');
}); });
it('should set the current language on the html tag', () => {
spyOn(service, 'getCurrentLanguageCode').and.returnValue('es');
service.setCurrentLanguageCode();
expect((service as any).document.documentElement.lang).toEqual('es');
});
}); });
describe('', () => { describe('', () => {
it('should set quality to current language list', () => { it('should set quality to current language list', () => {
const langListWithQuality = ['en;q=1', 'it;q=0.9', 'de;q=0.8']; const langListWithQuality = ['en;q=1', 'it;q=0.9', 'de;q=0.8'];
spyOn(service, 'setQuality').and.returnValue(langListWithQuality); spyOn(service, 'setQuality').and.returnValue(langListWithQuality);
service.setQuality(langList, LANG_ORIGIN.BROWSER, false); service.setQuality(langList, LANG_ORIGIN.BROWSER, false);
expect(service.setQuality).toHaveBeenCalledWith(langList, LANG_ORIGIN.BROW SER, false); expect(service.setQuality).toHaveBeenCalledWith(langList, LANG_ORIGIN.BROW SER, false);
}); });
 End of changes. 4 change blocks. 
2 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)