import { of } from 'rxjs';

import { ThemeConfig } from '../../../config/theme.config';
import { isNotEmpty } from '../empty.util';
import { ThemeService } from '../theme-support/theme.service';

export function getMockThemeService(themeName = 'base', themes?: ThemeConfig[]): ThemeService {
  const spy = jasmine.createSpyObj('themeService', {
    getThemeName: themeName,
    getThemeName$: of(themeName),
    getThemeConfigFor: undefined,
    listenForRouteChanges: undefined,
  });

  if (isNotEmpty(themes)) {
    spy.getThemeConfigFor.and.callFake((name: string) => themes.find(theme => theme.name === name));
  }

  return spy;
}
