Svelte with Test-Driven Development by Daniel Irvine

Svelte with Test-Driven Development by Daniel Irvine

Author:Daniel Irvine
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2023-06-09T00:00:00+00:00


Update them to use the createBirthday helper, shown here:

await performFormAction( createBirthday('Zeus', '2009-02-02') );

There are a couple of tests where the preceding change isn’t straightforward. In the saves unique ids one each new birthday test, you can save the created birthday in the request object, and then pass that into performFormAction twice, as shown in the following code:

it('saves unique ids onto each new birthday', async () => { const request = createBirthday( 'Zeus', '2009-02-02' ); await performFormAction(request); await performFormAction(request); expect(birthdayStore.getAll()[0].id).not.toEqual( birthdayStore.getAll()[1].id ); });

The updates an entrythat shares the same id test needs a specific id passed into the second invocation. Note how the factory method is structured in such a way that uncommon information needs to be named, such as the id field:

it('updates an entry that shares the same id', async () => { await performFormAction( createBirthday('Zeus', '2009-02-02') ); await performFormAction( createBirthday('Zeus Ex', '2007-02-02', { id: storedId() }) ); expect(birthdayStore.getAll()).toHaveLength(1); expect(birthdayStore.getAll()).toContainEqual({ id, name: 'Zeus Ex', dob: '2007-02-02' }); });

For the final test suite, in src/routes/birthdays/page.test.js, the birthdays array can be updated to use two calls to createBirthday, as shown here: const birthdays = [ createBirthday('Hercules', '1994-02-02', { id: '123' }), createBirthday('Athena', '1989-01-01', { id: '234' }) ];



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.