|
| 1 | +import { config } from 'dotenv'; |
| 2 | +import { describe, expect, it, beforeEach } from 'vitest'; |
| 3 | +import { BaseModel } from '../src/dtos/BaseModel'; |
| 4 | +import { DataService } from '../src'; |
| 5 | +import { AirtableDeletion, AirtableResult } from '../src/dtos'; |
| 6 | + |
| 7 | +config(); |
| 8 | + |
| 9 | +const token = process.env.AIRTABLE_API ?? ''; |
| 10 | +const baseId = 'appYytqUfVu81cjXn'; |
| 11 | + |
| 12 | +describe('DataService', () => { |
| 13 | + let service: DataService; |
| 14 | + let countyResult: BaseModel[] = []; |
| 15 | + |
| 16 | + beforeEach(() => { |
| 17 | + service = new DataService(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('get county', async () => { |
| 21 | + countyResult = await service.getData(token, baseId, 'county'); |
| 22 | + |
| 23 | + expect(countyResult).not.toBeUndefined(); |
| 24 | + expect(countyResult.length).toBeGreaterThan(0); |
| 25 | + }); |
| 26 | + |
| 27 | + it('get distinct with options', async () => { |
| 28 | + const distincts = await service.getData(token, baseId, 'distinct', { |
| 29 | + filterByFormula: `countyCode=${countyResult[0].countyCode}`, |
| 30 | + }); |
| 31 | + |
| 32 | + expect(distincts).not.toBeUndefined(); |
| 33 | + expect(distincts.length).toBeGreaterThan(0); |
| 34 | + }); |
| 35 | +}); |
0 commit comments