Skip to content

Commit

Permalink
test: finish pin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Jul 23, 2024
1 parent 763ff17 commit 7b7f756
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/unit/pins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import {userForTest, appRequest} from 'tests/unit-utils'

import {action as pinAction} from '~/routes/api.pin'

import {getPrisma} from '~/lib/prisma.server'

describe('Pins', () => {
test('It should pin items', async () => {
const prisma = getPrisma()

const userOne = await userForTest({role: 'reader'})
const userTwo = await userForTest({role: 'reader'})

const pinCount = await prisma.pin.count()

const response = await pinAction({
request: appRequest('/api/pin', {
Expand All @@ -20,5 +25,19 @@ describe('Pins', () => {
})

expect(response.status).toBe(200)
expect(await prisma.pin.count()).toBe(pinCount + 1)

const deleteResponse = await pinAction({
request: appRequest('/api/pin', {
method: 'POST',
body: JSON.stringify({target: 'documents', targetId: 'fake-uuid'}),
headers: await userOne.sessionHeader()
}),
context: {},
params: {}
})

expect(deleteResponse.status).toBe(200)
expect(await prisma.pin.count()).toBe(pinCount)
})
})

0 comments on commit 7b7f756

Please sign in to comment.