Add locality delete test

This commit is contained in:
ShootingStar91
2024-08-31 23:01:18 +03:00
parent aff94ae7ac
commit 75b900456e
3 changed files with 21 additions and 0 deletions
@@ -16,7 +16,9 @@ describe('Creating new locality works', () => {
it('Request succeeds and returns valid number id', async () => {
const { body: resultBody } = await send<{ id: number }>('locality', 'PUT', { locality: newLocalityBasis })
const { id: createdId } = resultBody
assert(typeof createdId === 'number', `Invalid result returned on write: ${createdId}`)
const { body } = await send<LocalityDetailsType>(`locality/${createdId}`, 'GET')
createdLocality = body
})
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import assert from 'node:assert/strict'
import { describe, it, before } from 'node:test'
import { login, send } from '../utils'
import { LocalityDetailsType } from '../../../../frontend/src/backendTypes'
describe('Deleting a locality works', async () => {
before(async () => {
await login()
})
await it('Deleting works', async () => {
const deleteResult = await send<{ id: number }>('locality/28518', 'DELETE')
assert(deleteResult.status === 200)
const getResult = await send<LocalityDetailsType>('locality/28518', 'GET')
assert(getResult.status === 404, 'Locality status was not 404 after deletion')
})
})
@@ -15,7 +15,9 @@ describe('Locality write works', () => {
it('Edits name, synonyms and locality species correctly', async () => {
const writeResult = await send<{ id: number }>('locality', 'PUT', { locality: editedLocality })
assert(writeResult.body.id === editedLocality.lid, `Invalid result returned on write: ${writeResult.body.id}`)
const { body } = await send<LocalityDetailsType>(`locality/${editedLocality.lid}`, 'GET')
resultLocality = body
})