artifact-common-properties.component.spec.ts 1.89 KB
Newer Older
1
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2 3 4 5 6

import { ArtifactCommonPropertiesComponent } from './artifact-common-properties.component';
import { ClarityModule } from "@clr/angular";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { TranslateFakeLoader, TranslateLoader, TranslateModule, TranslateService } from "@ngx-translate/core";
7
import { ExtraAttrs } from "../../../../../../ng-swagger-gen/models/extra-attrs";
8 9 10 11 12 13 14 15 16 17 18

describe('ArtifactCommonPropertiesComponent', () => {
  let component: ArtifactCommonPropertiesComponent;
  let fixture: ComponentFixture<ArtifactCommonPropertiesComponent>;
  const mockedExtraAttrs: ExtraAttrs = {
    architecture: "amd64",
    author: "",
    created: "2019-11-11T09:42:44.892055836Z",
    os: "linux"
  };

19
  beforeEach(waitForAsync(() => {
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    TestBed.configureTestingModule({
      imports: [
        ClarityModule,
        BrowserAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useClass: TranslateFakeLoader,
          }
        })
      ],
      declarations: [ ArtifactCommonPropertiesComponent ],
      providers: [
        TranslateService
      ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(ArtifactCommonPropertiesComponent);
    component = fixture.componentInstance;
    component.artifactDetails = {};
    component.artifactDetails.extra_attrs = mockedExtraAttrs;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
  it('should render all properties', async () => {
    component.commonProperties = mockedExtraAttrs;
    fixture.detectChanges();
    await fixture.whenStable();
    const contentRows = fixture.nativeElement.getElementsByTagName('clr-stack-content');
    expect(contentRows.length).toEqual(4);
  });
});