refactor(invites): thread tx through resolveCreatorUsername + tighten test assertions
Inside patchInvite/revokeInvite txn bodies, all reads now go through the tx proxy. Pre-Task-7 hygiene: locks in the consistent pattern that reinstateInvite (Task 7) and redeemInvite (Task 8) will copy. Createinvite test failures now pin to InviteValidationError, catching regressions where the wrong error class would otherwise pass silently.
This commit is contained in:
@@ -135,23 +135,23 @@ describe('createInvite', () => {
|
||||
|
||||
it('rejects empty name', () => {
|
||||
const adminId = seedAdmin();
|
||||
expect(() => createInvite({ name: '', maxUses: null, expiresAt: null }, adminId)).toThrow();
|
||||
expect(() => createInvite({ name: '', maxUses: null, expiresAt: null }, adminId)).toThrow(InviteValidationError);
|
||||
});
|
||||
|
||||
it('rejects name longer than 64 chars', () => {
|
||||
const adminId = seedAdmin();
|
||||
expect(() => createInvite({ name: 'x'.repeat(65), maxUses: null, expiresAt: null }, adminId)).toThrow();
|
||||
expect(() => createInvite({ name: 'x'.repeat(65), maxUses: null, expiresAt: null }, adminId)).toThrow(InviteValidationError);
|
||||
});
|
||||
|
||||
it('rejects non-positive maxUses', () => {
|
||||
const adminId = seedAdmin();
|
||||
expect(() => createInvite({ name: 'a', maxUses: 0, expiresAt: null }, adminId)).toThrow();
|
||||
expect(() => createInvite({ name: 'a', maxUses: -1, expiresAt: null }, adminId)).toThrow();
|
||||
expect(() => createInvite({ name: 'a', maxUses: 0, expiresAt: null }, adminId)).toThrow(InviteValidationError);
|
||||
expect(() => createInvite({ name: 'a', maxUses: -1, expiresAt: null }, adminId)).toThrow(InviteValidationError);
|
||||
});
|
||||
|
||||
it('rejects past expiresAt', () => {
|
||||
const adminId = seedAdmin();
|
||||
expect(() => createInvite({ name: 'a', maxUses: null, expiresAt: Date.now() - 1000 }, adminId)).toThrow();
|
||||
expect(() => createInvite({ name: 'a', maxUses: null, expiresAt: Date.now() - 1000 }, adminId)).toThrow(InviteValidationError);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user