mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Add locality delete test
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user