additional-data.component.spec.ts 2.06 KB
Newer Older
1 2
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3
import { RouterTestingModule } from '@angular/router/testing';
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
4
import { TranslateService } from '@ngx-translate/core';
5 6
import { TranslatePipeMock } from '../../../_mocks/_pipes/TranslatePipeMock';
import { TranslateServiceMock } from '../../../_mocks/_services/TranslateServiceMock';
7 8
import { QuizMockService } from '../../service/quiz/quiz-mock.service';
import { QuizService } from '../../service/quiz/quiz.service';
9 10
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
11 12 13 14 15 16 17 18 19

import { AdditionalDataComponent } from './additional-data.component';

describe('AdditionalDataComponent', () => {
  let component: AdditionalDataComponent;
  let fixture: ComponentFixture<AdditionalDataComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
20
      imports: [
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
21
        RouterTestingModule, HttpClientTestingModule,
22 23
      ],
      providers: [
24 25 26 27 28 29
        {
          provide: QuizService,
          useClass: QuizMockService,
        }, {
          provide: TrackingService,
          useClass: TrackingMockService,
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
30 31 32
        }, {
          provide: TranslateService,
          useClass: TranslateServiceMock,
33
        },
34
      ],
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
35
      declarations: [AdditionalDataComponent, TranslatePipeMock],
36
    }).compileComponents();
37 38 39 40 41 42 43 44 45 46 47
  }));

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

  it('should create', () => {
    expect(component).toBeTruthy();
  });
48 49 50 51

  it('should contain a TYPE definition', async(() => {
    expect(AdditionalDataComponent.TYPE).toEqual('AdditionalDataComponent');
  }));
52

53 54 55 56 57 58
  it('#switchShowMoreOrLess', () => {
    const baseState = window.innerWidth >= 768;
    expect(component.isShowingMore).toEqual(baseState);
    component.switchShowMoreOrLess();
    expect(component.isShowingMore).toEqual(!baseState);
  });
59
});