<commit_before>import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';

import { HeaderComponent } from './header.component';
import { MaterialConfigModule } from '../../../routing/material-config.module';
import { ConfigService } from '../../../core/shared/config.service';
import { GlobalEventsManagerService } from '../../../core/shared/global-events-manager.service';
import { UserService } from '../../../user/shared/user.service';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ConfigResolver } from '../../../routing/shared/config-resolver.service';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { ActivatedRouteStub } from '../../../../testing/router-stubs';
import { HttpClientModule } from '@angular/common/http';
import { ProgressService } from '../../providers/progress.service';
import { NotificationService } from '../../providers/notification.service';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

class RouterStub {
  navigate(url: string) {
    return url;
  }
}

class ConfigServiceStub {
  getTenantList(): Promise<string[]> {
    return Promise.resolve(Array.from(['demo', 'one', 'two', 'three']));
  }
}

describe('HeaderComponent', () => {
  let component: HeaderComponent;
  let fixture: ComponentFixture<HeaderComponent>;
  let activatedRoute: ActivatedRouteStub;
  let configServiceStub: ConfigServiceStub;

  beforeEach(async(() => {
    activatedRoute = new ActivatedRouteStub();
    configServiceStub = new ConfigServiceStub();

    TestBed.configureTestingModule({
      imports: [MaterialConfigModule, HttpClientModule, NoopAnimationsModule],
      declarations: [HeaderComponent],
      providers: [
        { provide: ActivatedRoute, useValue: activatedRoute },
        { provide: Router, useClass: RouterStub },
        { provide: ConfigService, useValue: configServiceStub },
        ConfigResolver,
        GlobalEventsManagerService,
        ProgressService,
        UserService,
        NotificationService
      ],
      schemas: [NO_ERRORS_SCHEMA]
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(HeaderComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should be created', () => {
    expect(component).toBeTruthy();
  });<commit_msg>Fix HeaderComponent tests to use a MockUserService.<commit_after>import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';

import { HeaderComponent } from './header.component';
import { MaterialConfigModule } from '../../../routing/material-config.module';
import { ConfigService } from '../../../core/shared/config.service';
import { GlobalEventsManagerService } from '../../../core/shared/global-events-manager.service';
import { UserService } from '../../../user/shared/user.service';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ConfigResolver } from '../../../routing/shared/config-resolver.service';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { ActivatedRouteStub } from '../../../../testing/router-stubs';
import { HttpClientModule } from '@angular/common/http';
import { ProgressService } from '../../providers/progress.service';
import { NotificationService } from '../../providers/notification.service';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { User } from '../../../user/shared/user';

class RouterStub {
  navigate(url: string) {
    return url;
  }
}

class ConfigServiceStub {
  getTenantList(): Promise<string[]> {
    return Promise.resolve(Array.from(['demo', 'one', 'two', 'three']));
  }
}

class MockUserService extends UserService {
  constructor() {
    super(null, null, null);
  }

  getUserObservable(): Observable<User> {
    return of(new User('testUser'));
  }
}

describe('HeaderComponent', () => {
  let component: HeaderComponent;
  let fixture: ComponentFixture<HeaderComponent>;
  let activatedRoute: ActivatedRouteStub;
  let configServiceStub: ConfigServiceStub;

  beforeEach(async(() => {
    activatedRoute = new ActivatedRouteStub();
    configServiceStub = new ConfigServiceStub();

    TestBed.configureTestingModule({
      imports: [MaterialConfigModule, HttpClientModule, NoopAnimationsModule],
      declarations: [HeaderComponent],
      providers: [
        { provide: ActivatedRoute, useValue: activatedRoute },
        { provide: Router, useClass: RouterStub },
        { provide: ConfigService, useValue: configServiceStub },
        { provide: UserService, useValue: new MockUserService() },
        ConfigResolver,
        GlobalEventsManagerService,
        ProgressService,
        NotificationService
      ],
      schemas: [NO_ERRORS_SCHEMA]
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(HeaderComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should be created', () => {
    expect(component).toBeTruthy();
  });
{'fraction_non_alphanumeric': 0.14838709677419354, 'fraction_numerical': 0.0, 'mean_word_length': 3.9718172983479105, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1885166', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1398, 'n_words': 300}