1
0
Files
yel-dspace-angular/src/app/shared/mocks/theme-service.mock.ts

20 lines
662 B
TypeScript

import { ThemeService } from '../theme-support/theme.service';
import { of as observableOf } from 'rxjs';
import { ThemeConfig } from '../../../config/theme.config';
import { isNotEmpty } from '../empty.util';
export function getMockThemeService(themeName = 'base', themes?: ThemeConfig[]): ThemeService {
const spy = jasmine.createSpyObj('themeService', {
getThemeName: themeName,
getThemeName$: observableOf(themeName),
getThemeConfigFor: undefined,
listenForRouteChanges: undefined,
});
if (isNotEmpty(themes)) {
spy.getThemeConfigFor.and.callFake((name: string) => themes.find(theme => theme.name === name));
}
return spy;
}