Evolving the repository to allow ID lookup
It’s now time to update our birthday data items to include an id
field.
Let’s start with a new test to check that id
is present.
- Start by adding this test into the
src/routes/birthdays/page.server.test.js
file, within thedescribe
block named/birthdays - default action
. It checks that each birthday has a uniqueid
field associated with it:it('saves unique ids onto each new birthday', async () => { const request = createFormDataRequest({ name: 'Zeus', dob: '2009-02-02' }); await actions.default({ request }); await actions.default({ request }); expect(birthdayRepository.getAll()[0].id).not .toEqual(birthdayRepository.getAll()[1].id); });
- Make that pass in
src/lib/server/birthdayRepository.js
. Start by adding theimport
statement:import { randomUUID } from &apos...