|
| 1 | +import {SimpleChange, SimpleChanges} from '@angular/core'; |
| 2 | +import {AgmPolylinePoint} from './polyline-point'; |
| 3 | + |
| 4 | +describe('AgmPolylinePoint', () => { |
| 5 | + describe('ngOnChanges', () => { |
| 6 | + it('should emit positionChanged on latitude change', () => { |
| 7 | + const polylinePoint = new AgmPolylinePoint(); |
| 8 | + polylinePoint.latitude = 50; |
| 9 | + polylinePoint.longitude = -50; |
| 10 | + polylinePoint.positionChanged.emit = jest.fn(); |
| 11 | + |
| 12 | + const positionChanges: |
| 13 | + SimpleChanges = {'latitude': new SimpleChange('previousLat', 'newLat', false)}; |
| 14 | + |
| 15 | + polylinePoint.ngOnChanges(positionChanges); |
| 16 | + |
| 17 | + expect(polylinePoint.positionChanged.emit).toHaveBeenCalledWith({lat: 'newLat', lng: -50}); |
| 18 | + }); |
| 19 | + it('should emit positionChanged on longitude change', () => { |
| 20 | + const polylinePoint = new AgmPolylinePoint(); |
| 21 | + polylinePoint.latitude = 50; |
| 22 | + polylinePoint.longitude = -50; |
| 23 | + polylinePoint.positionChanged.emit = jest.fn(); |
| 24 | + |
| 25 | + const positionChanges: |
| 26 | + SimpleChanges = {'longitude': new SimpleChange('previousLng', 'newLng', false)}; |
| 27 | + |
| 28 | + polylinePoint.ngOnChanges(positionChanges); |
| 29 | + |
| 30 | + expect(polylinePoint.positionChanged.emit).toHaveBeenCalledWith({lat: 50, lng: 'newLng'}); |
| 31 | + }); |
| 32 | + it('should emit positionChanged on latitude and longitude change', () => { |
| 33 | + const polylinePoint = new AgmPolylinePoint(); |
| 34 | + polylinePoint.latitude = 50; |
| 35 | + polylinePoint.longitude = -50; |
| 36 | + polylinePoint.positionChanged.emit = jest.fn(); |
| 37 | + |
| 38 | + const positionChanges: SimpleChanges = { |
| 39 | + 'latitude': new SimpleChange('previousLat', 'newLat', false), |
| 40 | + 'longitude': new SimpleChange('previousLng', 'newLng', false) |
| 41 | + }; |
| 42 | + |
| 43 | + polylinePoint.ngOnChanges(positionChanges); |
| 44 | + |
| 45 | + expect(polylinePoint.positionChanged.emit) |
| 46 | + .toHaveBeenCalledWith({lat: 'newLat', lng: 'newLng'}); |
| 47 | + }); |
| 48 | + }); |
| 49 | +}); |
0 commit comments