Skip to content

Commit

Permalink
test(timeline/service/DeleteListService): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Allianaab2m committed Jul 21, 2024
1 parent 90db81f commit e129a83
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/timeline/service/deleteList.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Result } from '@mikuroxina/mini-fn';
import { describe, expect, it } from 'vitest';
import type { AccountID } from '../../accounts/model/account.js';
import { InMemoryListRepository } from '../adaptor/repository/dummy.js';
import { List, type ListID } from '../model/list.js';
import { DeleteListService } from './deleteList.js';

const testList = List.new({
id: '1' as ListID,
createdAt: new Date(2023, 9, 10, 0, 0),
memberIds: [],
ownerId: '' as AccountID,
publicity: 'PUBLIC',
title: 'Test List',
});

describe('DeleteListService', () => {
const repository = new InMemoryListRepository([testList]);
const service = new DeleteListService(repository);

it('should delete a list', async () => {
const res = await service.handle('1' as ListID);

expect(Result.isOk(res)).toBe(true);
});
it('should be error when try delete not existing list', async () => {
const res = await service.handle('2' as ListID);

expect(Result.isErr(res)).toBe(true);
});
});

0 comments on commit e129a83

Please sign in to comment.