|
| 1 | +import { depots } from '../data/depots.js'; |
| 2 | +import { expect, test } from 'vitest'; |
| 3 | + |
| 4 | +test('each depot has required properties', () => { |
| 5 | + for (const depot in depots) { |
| 6 | + expect(depot).toHaveProperty('id'); |
| 7 | + expect(typeof depot.id).toBe('string'); |
| 8 | + |
| 9 | + expect(depot).toHaveProperty('name'); |
| 10 | + expect(typeof depot.name).toBe('string'); |
| 11 | + |
| 12 | + expect(depot).toHaveProperty('type'); |
| 13 | + expect(['bus', 'tram', 'trolleybus']).toContain(depot.type); |
| 14 | + |
| 15 | + expect(depot).toHaveProperty('inv_number_ranges'); |
| 16 | + if(typeof depot.inv_number_ranges === 'object') { |
| 17 | + expect(Array.isArray(depot.inv_number_ranges)).toBe(true); |
| 18 | + for(const range of depot.inv_number_ranges) { |
| 19 | + if (Array.isArray(range)) { |
| 20 | + expect(range.length).toBe(2); |
| 21 | + expect(typeof range[0]).toBe('number'); |
| 22 | + expect(typeof range[1]).toBe('number'); |
| 23 | + expect(range[0]).toBeLessThanOrEqual(range[1]); |
| 24 | + } |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + expect(depot).toHaveProperty('geometry'); |
| 29 | + expect(Array.isArray(depot.geometry)).toBe(true); |
| 30 | + for(const line of depot.geometry) { |
| 31 | + expect(Array.isArray(line)).toBe(true); |
| 32 | + for(const point of line) { |
| 33 | + expect(Array.isArray(point)).toBe(true); |
| 34 | + expect(point.length).toBe(2); |
| 35 | + expect(typeof point[0]).toBe('number'); |
| 36 | + expect(typeof point[1]).toBe('number'); |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | +}); |
0 commit comments