|
| 1 | +import { ComponentFixture, TestBed } from '@angular/core/testing'; |
| 2 | +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 3 | +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; |
| 4 | +import { LayoutField } from '../../../../../../../core/layout/models/box.model'; |
| 5 | +import { Item } from '../../../../../../../core/shared/item.model'; |
| 6 | +import { MetadataValue } from '../../../../../../../core/shared/metadata.models'; |
| 7 | +import { TranslateLoaderMock } from '../../../../../../../shared/mocks/translate-loader.mock'; |
| 8 | +import { OsmapComponent } from './osmap.component'; |
| 9 | + |
| 10 | +describe('OsmapComponent', () => { |
| 11 | + let component: OsmapComponent; |
| 12 | + let fixture: ComponentFixture<OsmapComponent>; |
| 13 | + |
| 14 | + const metadataValue = Object.assign(new MetadataValue(), { |
| 15 | + 'value': '@42.1334,56.7654', |
| 16 | + 'language': null, |
| 17 | + 'authority': null, |
| 18 | + 'confidence': -1, |
| 19 | + 'place': 0 |
| 20 | + }); |
| 21 | + |
| 22 | + const testItem = Object.assign(new Item(), |
| 23 | + { |
| 24 | + type: 'item', |
| 25 | + metadata: { |
| 26 | + 'organization.address.addressLocality': [metadataValue] |
| 27 | + }, |
| 28 | + uuid: 'test-item-uuid', |
| 29 | + } |
| 30 | + ); |
| 31 | + |
| 32 | + const mockField: LayoutField = { |
| 33 | + 'metadata': 'organization.address.addressLocality', |
| 34 | + 'label': 'Preferred name', |
| 35 | + 'rendering': 'OSMAP', |
| 36 | + 'fieldType': 'METADATA', |
| 37 | + 'style': null, |
| 38 | + 'styleLabel': 'test-style-label', |
| 39 | + 'styleValue': 'test-style-value', |
| 40 | + 'labelAsHeading': false, |
| 41 | + 'valuesInline': true |
| 42 | + }; |
| 43 | + |
| 44 | + beforeEach(async () => { |
| 45 | + await TestBed.configureTestingModule({ |
| 46 | + imports: [TranslateModule.forRoot({ |
| 47 | + loader: { |
| 48 | + provide: TranslateLoader, |
| 49 | + useClass: TranslateLoaderMock |
| 50 | + } |
| 51 | + }), BrowserAnimationsModule], |
| 52 | + providers: [ |
| 53 | + { provide: 'fieldProvider', useValue: mockField }, |
| 54 | + { provide: 'itemProvider', useValue: testItem }, |
| 55 | + { provide: 'metadataValueProvider', useValue: metadataValue }, |
| 56 | + { provide: 'renderingSubTypeProvider', useValue: '' }, |
| 57 | + ], |
| 58 | + declarations: [ OsmapComponent ] |
| 59 | + }) |
| 60 | + .compileComponents(); |
| 61 | + }); |
| 62 | + |
| 63 | + beforeEach(() => { |
| 64 | + fixture = TestBed.createComponent(OsmapComponent); |
| 65 | + component = fixture.componentInstance; |
| 66 | + fixture.detectChanges(); |
| 67 | + }); |
| 68 | + |
| 69 | + it('should create', () => { |
| 70 | + expect(component).toBeTruthy(); |
| 71 | + }); |
| 72 | + |
| 73 | +// it('should rendered google map.',() => { |
| 74 | +// component.coordinates = '@42.1334,56.7654'; |
| 75 | +// fixture.detectChanges(); |
| 76 | +// const container = fixture.debugElement.query(By.css('#googlemap')); |
| 77 | +// expect(container).toBeTruthy(); |
| 78 | +// }); |
| 79 | + |
| 80 | +// it('should not rendered google map.',() => { |
| 81 | +// component.coordinates = undefined; |
| 82 | +// fixture.detectChanges(); |
| 83 | +// const container = fixture.debugElement.query(By.css('#googlemap')); |
| 84 | +// expect(container).toBeFalsy(); |
| 85 | +// }); |
| 86 | + |
| 87 | +}); |
0 commit comments