test(api): add unit tests for admin, leads, and reviews modules

Add missing test coverage:
- reject-listing handler spec
- user-deactivated listener spec
- lead-score value object spec
- rating value object spec

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-11 01:38:45 +07:00
parent 8265130477
commit 97c7d58f5e
4 changed files with 290 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import { LeadScore } from '../value-objects/lead-score.vo';
describe('LeadScore Value Object', () => {
it('should create a valid lead score', () => {
const result = LeadScore.create(75);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(75);
});
it('should accept minimum score of 0', () => {
const result = LeadScore.create(0);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(0);
});
it('should accept maximum score of 100', () => {
const result = LeadScore.create(100);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(100);
});
it('should reject negative score', () => {
const result = LeadScore.create(-1);
expect(result.isErr).toBe(true);
expect(result.unwrapErr()).toBe('Điểm lead phải từ 0 đến 100');
});
it('should reject score above 100', () => {
const result = LeadScore.create(101);
expect(result.isErr).toBe(true);
expect(result.unwrapErr()).toBe('Điểm lead phải từ 0 đến 100');
});
it('should accept decimal scores', () => {
const result = LeadScore.create(50.5);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(50.5);
});
it('should accept boundary score of 1', () => {
const result = LeadScore.create(1);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(1);
});
it('should accept boundary score of 99', () => {
const result = LeadScore.create(99);
expect(result.isOk).toBe(true);
expect(result.unwrap().value).toBe(99);
});
});