fixing rescue settings

This commit is contained in:
blaisadmin
2026-04-15 22:57:34 -04:00
parent ce2b7a15bf
commit 765d6c61db
8 changed files with 476 additions and 11 deletions
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createBird, getBirdById, listWeightsForBird } from './birdRepository.js';
import { createBird, getBirdById, listWeightsForBird, transferBirdToWorkspace } from './birdRepository.js';
import { mockDb } from '../test/mockDb.js';
test('getBirdById returns null when the bird does not exist in the workspace', async () => {
@@ -70,3 +70,34 @@ test('listWeightsForBird scopes by bird, workspace, and day window', async () =>
assert.deepEqual(calls[0].params, ['bird-1', 30, 10]);
assert.match(calls[0].text, /FROM weight_records/);
});
test('transferBirdToWorkspace moves the bird to the target workspace', async () => {
const { calls } = mockDb({
rowCount: 1,
rows: [
{
id: 'bird-1',
workspace_id: 22,
name: 'Kiwi',
tag_id: 'A-1',
species: 'Cockatiel',
gender: 'female',
date_of_birth: null,
gotcha_day: null,
chart_color: '#cb3a35',
photo_data_url: null,
notify_on_dob: false,
notify_on_gotcha_day: false,
created_at: '2026-04-14T00:00:00.000Z',
latest_weight_grams: '92',
latest_recorded_on: '2026-04-14',
},
],
});
const bird = await transferBirdToWorkspace('bird-1', 10, 22);
assert.equal(bird?.workspace_id, 22);
assert.deepEqual(calls[0].params, ['bird-1', 10, 22]);
assert.match(calls[0].text, /UPDATE birds/);
});