File size: 890 Bytes
46252cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { BadRequestException } from '@nestjs/common';
import { InvalidInviteCodeError } from './invalid-invite-code.error';

// Joining via an invalid/expired/revoked invite code is a client error, not a server fault:
// InvalidInviteCodeError extends BadRequestException so NestJS maps it to 400 through the built-in
// handler (no global filter) — same mapping discipline as CallNotFoundError.
describe('InvalidInviteCodeError', () => {
  it('is a BadRequestException -> HTTP 400 without a custom global filter', () => {
    const err = new InvalidInviteCodeError();
    expect(err).toBeInstanceOf(BadRequestException);
    expect(err.getStatus()).toBe(400);
  });

  it('states the possible causes in the message', () => {
    expect(new InvalidInviteCodeError().message).toBe(
      'could not join the group — the invite code may be invalid, expired, or revoked',
    );
  });
});