-
Notifications
You must be signed in to change notification settings - Fork 368
/
activity.service.integration.test.ts
44 lines (36 loc) · 1.63 KB
/
activity.service.integration.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { expect, describe, it, beforeAll } from 'vitest';
import db, { multipleMigrations } from '../../db/database.js';
import * as ActivityService from './activity.service.js';
import type { ActivityLog } from '../../models/Activity.js';
describe('Activity service integration tests', () => {
beforeAll(async () => {
await multipleMigrations();
});
it('Should not create an activity without an environment id', async () => {
const log: ActivityLog = {} as ActivityLog;
const logId = await ActivityService.createActivityLog(log);
expect(logId).toBeNull();
});
it('Should create an activity log and retrieve its ID', async () => {
const result = await db.knex.select('*').from('_nango_environments');
const log: ActivityLog = {
environment_id: result[0].id
} as ActivityLog;
const logId = await ActivityService.createActivityLog(log);
expect(logId).not.toBeNull();
});
it('Should update provider for a given activity log ID', async () => {
const result = await db.knex.select('*').from('_nango_environments');
const log: ActivityLog = {
environment_id: result[0].id
} as ActivityLog;
const createdLog = await ActivityService.createActivityLog(log);
const provider = 'newProvider';
await ActivityService.updateProvider(createdLog as number, provider);
const updatedLog = await db.knex
.from<ActivityLog>('_nango_activity_logs')
.where({ id: createdLog as number })
.first();
expect(updatedLog.provider).toEqual(provider);
});
});