-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7db0be2
commit 219272c
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/app-server/src/modules/notes/e2e/create-and-view-note.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import memoryDriver from 'unstorage/drivers/memory'; | ||
import { createServer } from '../../app/server'; | ||
|
||
describe('e2e', () => { | ||
describe('create and view note', () => { | ||
test('a note can be created and viewed', async () => { | ||
const { app } = createServer({ | ||
storageDriver: memoryDriver(), | ||
}); | ||
|
||
const note = { | ||
content: '<encrypted-content>', | ||
isPasswordProtected: false, | ||
deleteAfterReading: false, | ||
ttlInSeconds: 600, | ||
}; | ||
|
||
const createNoteResponse = await app.request( | ||
'/api/notes', | ||
{ | ||
method: 'POST', | ||
body: JSON.stringify(note), | ||
headers: new Headers({ 'Content-Type': 'application/json' }), | ||
}, | ||
); | ||
|
||
expect(createNoteResponse.status).to.eql(200); | ||
|
||
const { noteId } = await createNoteResponse.json<any>(); | ||
|
||
expect(noteId).toBeDefined(); | ||
expect(noteId).to.be.a('string'); | ||
|
||
const viewNoteResponse = await app.request(`/api/notes/${noteId}`); | ||
|
||
expect(viewNoteResponse.status).to.eql(200); | ||
|
||
const { note: retrievedNote } = await viewNoteResponse.json<any>(); | ||
|
||
expect(retrievedNote).to.eql({ | ||
content: '<encrypted-content>', | ||
isPasswordProtected: false, | ||
deleteAfterReading: false, | ||
}); | ||
}); | ||
}); | ||
}); |