|
| 1 | +import { ItemVersionHistoryComponent } from './item-version-history.component'; |
| 2 | +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 3 | +import { VarDirective } from '../../../shared/utils/var.directive'; |
| 4 | +import { RouterTestingModule } from '@angular/router/testing'; |
| 5 | +import { TranslateModule } from '@ngx-translate/core'; |
| 6 | +import { NO_ERRORS_SCHEMA } from '@angular/core'; |
| 7 | +import { Item } from '../../../core/shared/item.model'; |
| 8 | +import { ActivatedRoute } from '@angular/router'; |
| 9 | +import { of as observableOf } from 'rxjs'; |
| 10 | +import { createSuccessfulRemoteDataObject } from '../../../shared/testing/utils'; |
| 11 | + |
| 12 | +describe('ItemVersionHistoryComponent', () => { |
| 13 | + let component: ItemVersionHistoryComponent; |
| 14 | + let fixture: ComponentFixture<ItemVersionHistoryComponent>; |
| 15 | + |
| 16 | + const item = Object.assign(new Item(), { |
| 17 | + uuid: 'item-identifier-1', |
| 18 | + handle: '123456789/1', |
| 19 | + }); |
| 20 | + |
| 21 | + beforeEach(async(() => { |
| 22 | + TestBed.configureTestingModule({ |
| 23 | + declarations: [ItemVersionHistoryComponent, VarDirective], |
| 24 | + imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], |
| 25 | + providers: [ |
| 26 | + { provide: ActivatedRoute, useValue: { parent: { data: observableOf({ item: createSuccessfulRemoteDataObject(item) }) } } } |
| 27 | + ], |
| 28 | + schemas: [NO_ERRORS_SCHEMA] |
| 29 | + }).compileComponents(); |
| 30 | + })); |
| 31 | + |
| 32 | + beforeEach(() => { |
| 33 | + fixture = TestBed.createComponent(ItemVersionHistoryComponent); |
| 34 | + component = fixture.componentInstance; |
| 35 | + fixture.detectChanges(); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should initialize the itemRD$ from the route\'s data', (done) => { |
| 39 | + component.itemRD$.subscribe((itemRD) => { |
| 40 | + expect(itemRD.payload).toBe(item); |
| 41 | + done(); |
| 42 | + }); |
| 43 | + }); |
| 44 | +}); |
0 commit comments