|
| 1 | +import { TestBed } from '@angular/core/testing'; |
| 2 | + |
| 3 | +import * as models from '@models'; |
| 4 | +import { productFactory } from '@testing/product-factory'; |
| 5 | +import { beforeEach, describe, expect, it } from 'vitest'; |
| 6 | + |
| 7 | +import { DatasetForProductService } from './dataset-for-product.service'; |
| 8 | + |
| 9 | +describe('DatasetForProductService', () => { |
| 10 | + let service: DatasetForProductService; |
| 11 | + |
| 12 | + beforeEach(() => { |
| 13 | + TestBed.configureTestingModule({}); |
| 14 | + service = TestBed.inject(DatasetForProductService); |
| 15 | + }); |
| 16 | + |
| 17 | + describe('match()', () => { |
| 18 | + it('returns alos for ALOS dataset without AVNIR-2 instrument', () => { |
| 19 | + const product = productFactory |
| 20 | + .withBasicInfo('test-scene') |
| 21 | + .withDataset('ALOS') |
| 22 | + .build(); |
| 23 | + expect(service.match(product)).toBe(models.alos); |
| 24 | + }); |
| 25 | + |
| 26 | + it('returns avnir for ALOS dataset with AVNIR-2 instrument', () => { |
| 27 | + const product = productFactory |
| 28 | + .withBasicInfo('test-scene') |
| 29 | + .withDataset('ALOS') |
| 30 | + .withInstrument('AVNIR-2') |
| 31 | + .build(); |
| 32 | + expect(service.match(product)).toBe(models.avnir); |
| 33 | + }); |
| 34 | + |
| 35 | + it('returns sentinel_1_bursts for BURST product type', () => { |
| 36 | + const product = productFactory |
| 37 | + .withBasicInfo('test-scene') |
| 38 | + .withProductType('BURST') |
| 39 | + .build(); |
| 40 | + expect(service.match(product)).toBe(models.sentinel_1_bursts); |
| 41 | + }); |
| 42 | + |
| 43 | + it('returns tropo for TROPO-ZENITH product type', () => { |
| 44 | + const product = productFactory |
| 45 | + .withBasicInfo('test-scene') |
| 46 | + .withProductType('TROPO-ZENITH') |
| 47 | + .build(); |
| 48 | + expect(service.match(product)).toBe(models.tropo); |
| 49 | + }); |
| 50 | + |
| 51 | + it('returns tropo for ECMWF_TROPO product type', () => { |
| 52 | + const product = productFactory |
| 53 | + .withBasicInfo('test-scene') |
| 54 | + .withProductType('ECMWF_TROPO') |
| 55 | + .build(); |
| 56 | + expect(service.match(product)).toBe(models.tropo); |
| 57 | + }); |
| 58 | + |
| 59 | + it('returns opera_s1 for OPERA product id', () => { |
| 60 | + const product = productFactory |
| 61 | + .withBasicInfo('test-scene') |
| 62 | + .withId('OPERA_L2_RTC-S1_T001') |
| 63 | + .build(); |
| 64 | + expect(service.match(product)).toBe(models.opera_s1); |
| 65 | + }); |
| 66 | + |
| 67 | + it('returns SENTINEL-1 INTERFEROGRAM (BETA) for S1-GUNW name', () => { |
| 68 | + const product = productFactory |
| 69 | + .withBasicInfo('test-scene') |
| 70 | + .withName('S1-GUNW-D-N-123456-123456-HH-R-N-0001') |
| 71 | + .build(); |
| 72 | + expect(service.match(product)).toBe( |
| 73 | + models.datasets['SENTINEL-1 INTERFEROGRAM (BETA)'], |
| 74 | + ); |
| 75 | + }); |
| 76 | + |
| 77 | + it('returns sentinel-1 dataset for exact SENTINEL-1 dataset match', () => { |
| 78 | + const product = productFactory.withBasicInfo('test-scene').build(); |
| 79 | + expect(service.match(product)).toBe(models.datasets['SENTINEL-1']); |
| 80 | + }); |
| 81 | + |
| 82 | + it('returns sentinel-1 dataset for Sentinel-1A via partial match', () => { |
| 83 | + const product = productFactory |
| 84 | + .withBasicInfo('test-scene') |
| 85 | + .withDataset('Sentinel-1A') |
| 86 | + .build(); |
| 87 | + expect(service.match(product)).toBe(models.datasets['SENTINEL-1']); |
| 88 | + }); |
| 89 | + // TODO: Change this to default to SENTINEL-1 again? |
| 90 | + it('returns NISAR for non matching dataset', () => { |
| 91 | + const product = productFactory |
| 92 | + .withBasicInfo('test-scene') |
| 93 | + .withDataset('') |
| 94 | + .build(); |
| 95 | + expect(service.match(product)).toBe(models.datasets.NISAR); |
| 96 | + }); |
| 97 | + }); |
| 98 | +}); |
0 commit comments