Skip to content

Commit 2bdb80e

Browse files
committed
update tests
1 parent 9e64e01 commit 2bdb80e

File tree

8 files changed

+26
-307
lines changed

8 files changed

+26
-307
lines changed

src/attachments/attachments.spec.ts

Lines changed: 0 additions & 298 deletions
This file was deleted.

src/broadcasts/broadcasts.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ describe('Broadcasts', () => {
460460
"sent_at": null,
461461
"status": "draft",
462462
"subject": "hello world",
463-
"topic_id": "9f31e56e-3083-46cf-8e96-c6995e0e576a",
464463
"text": "Hello world",
464+
"topic_id": "9f31e56e-3083-46cf-8e96-c6995e0e576a",
465465
},
466466
"error": null,
467467
}

src/contacts/audiences/contact-audiences.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import createFetchMock from 'vitest-fetch-mock';
12
import { Resend } from '../../resend';
23
import { mockSuccessResponse } from '../../test-utils/mock-fetch';
34
import type {
@@ -13,9 +14,12 @@ import type {
1314
RemoveContactAudiencesResponseSuccess,
1415
} from './interfaces/remove-contact-audience.interface';
1516

17+
const fetchMocker = createFetchMock(vi);
18+
fetchMocker.enableMocks();
19+
1620
describe('ContactAudiences', () => {
1721
afterEach(() => fetchMock.resetMocks());
18-
22+
afterAll(() => fetchMocker.disableMocks());
1923
describe('list', () => {
2024
it('gets contact audiences by email', async () => {
2125
const options: ListContactAudiencesOptions = {

src/contacts/contacts.integration.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ describe('Contacts Integration Tests', () => {
4040
expect(removeResult.data?.deleted).toBe(true);
4141
}
4242
});
43-
44-
it('handles validation errors', async () => {
45-
// @ts-expect-error: Testing invalid input
46-
const result = await resend.contacts.create({});
47-
48-
expect(result.error?.name).toBe('validation_error');
49-
});
5043
});
5144

5245
describe('list', () => {

src/contacts/topics/contact-topics.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import createFetchMock from 'vitest-fetch-mock';
12
import { Resend } from '../../resend';
23
import { mockSuccessResponse } from '../../test-utils/mock-fetch';
34
import type {
@@ -9,8 +10,12 @@ import type {
910
UpdateContactTopicsResponseSuccess,
1011
} from './interfaces/update-contact-topics.interface';
1112

13+
const fetchMocker = createFetchMock(vi);
14+
fetchMocker.enableMocks();
15+
1216
describe('ContactTopics', () => {
1317
afterEach(() => fetchMock.resetMocks());
18+
afterAll(() => fetchMocker.disableMocks());
1419

1520
describe('update', () => {
1621
it('updates contact topics with opt_in', async () => {

src/inbound/inbound.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import createFetchMock from 'vitest-fetch-mock';
12
import type { ErrorResponse } from '../interfaces';
23
import { Resend } from '../resend';
34

5+
const fetchMocker = createFetchMock(vi);
6+
fetchMocker.enableMocks();
7+
48
const resend = new Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
59

610
describe('Inbound', () => {
711
afterEach(() => fetchMock.resetMocks());
12+
afterAll(() => fetchMocker.disableMocks());
813

914
describe('get', () => {
1015
describe('when inbound email not found', () => {

src/templates/templates.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { vi } from 'vitest';
2+
import createFetchMock from 'vitest-fetch-mock';
23
import type { ErrorResponse } from '../interfaces';
34
import { Resend } from '../resend';
45
import {
@@ -12,6 +13,9 @@ import type {
1213
import type { GetTemplateResponseSuccess } from './interfaces/get-template.interface';
1314
import type { UpdateTemplateOptions } from './interfaces/update-template.interface';
1415

16+
const fetchMocker = createFetchMock(vi);
17+
fetchMocker.enableMocks();
18+
1519
const mockRenderAsync = vi.fn();
1620
vi.mock('@react-email/render', () => ({
1721
renderAsync: mockRenderAsync,
@@ -23,6 +27,7 @@ describe('Templates', () => {
2327
vi.resetAllMocks();
2428
fetchMock.resetMocks();
2529
});
30+
afterAll(() => fetchMocker.disableMocks());
2631

2732
describe('create', () => {
2833
it('creates a template with minimal required fields', async () => {

0 commit comments

Comments
 (0)