test('default root route', (t) => { t.plan(2) const app = build(t) app.inject({ url: '/' }, (err, res) => { t.error(err) t.deepEqual(JSON.parse(res.payload), { root: true }) }) })
test('default root route', async (t) => { const app = build(t) const res = await app.inject({ url: '/' }) t.deepEqual(JSON.parse(res.payload), { root: true }) })
test('find student [GET `/v1/student/:id`]', async () => { const res = await fastify.inject({ method: 'GET', url: '/v1/student/5e456a4628309eb0e1c53d9a', }); expect(res.statusCode).toEqual(HttpStatus.OK); expect(JSON.parse(res.payload)) .toEqual(expect.objectContaining({ _id: '5e456a4628309eb0e1c53d9a', firstName: 'Danish' })); });
test('hello is loaded', async (t) => { const app = build(t) const res = await app.inject({ url: '/hello' }) t.equal(res.payload, 'hello, world!') })
test('example is loaded', (t) => { t.plan(2) const app = build(t) app.inject({ url: '/example' }, (err, res) => { t.error(err) t.equal(res.payload, 'this is an example') }) })
test('create student [POST `/v1/student`]', async () => { const res = await fastify.inject({ method: 'POST', url: '/v1/student', payload: { firstName : "Danish", lastName : "Siddiq", registrationNumber : 313 } }); expect(res.statusCode).toEqual(HttpStatus.CREATED); expect(JSON.parse(res.payload)) .toEqual(expect.objectContaining({ _id: expect.any(String), firstName: expect.any(String), lastName: expect.any(String) })) });
test('update student [PUT `/v1/student/:id`]', async () => { const res = await fastify.inject({ method: 'PUT', url: '/v1/student/5e456a4628309eb0e1c53d9a?firstName=Danish 1&lastName=Siddiq 1', }); expect(res.statusCode).toEqual(HttpStatus.OK); expect(JSON.parse(res.payload)) .toEqual({ status: 'ok' }); });
test('default root route', async (t) => { const app = build(t) const res = await app.inject({ url: '/' }) t.deepEqual(JSON.parse(res.payload), { root: true }) })
test('hello is loaded', async (t) => { const app = build(t) const res = await app.inject({ url: '/hello' }) t.equal(res.payload, 'hello, world!') })