Skip to content

Commit

Permalink
added test for note deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
e11sy committed Jul 24, 2024
1 parent 125ae8f commit 6d979f1
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/presentation/http/router/note.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2072,4 +2072,46 @@ describe('Note API', () => {
}
});
});

describe('DELETE /note/:noteId', () => {
test('Delete note history on note deletion', async () => {
/**
* Insert test user
*/
const user = await global.db.insertUser();

/**
* Authorization for user
*/
const accessToken = global.auth(user.id);

/**
* Insert test note, note history record will be inserted automatically
*/
const note = await global.db.insertNote({
creatorId: user.id,
});

/**
* Delete note
*/
await global.api?.fakeRequest({
method: 'DELETE',
headers: {
authorization: `Bearer ${accessToken}`,
},
url: `/note/${note.publicId}`,
});

const response = await global.api?.fakeRequest({
method: 'GET',
headers: {
authorization: `Bearer ${accessToken}`,
},
url: `/note/${note.publicId}/history`,
});

expect(response?.json().message).toBe('Note not found');
});
});
});

0 comments on commit 6d979f1

Please sign in to comment.