@@ -3,46 +3,48 @@ import * as request from 'supertest'
33import { Debug } from '@secjs/logger'
44import { AppModule } from 'app/AppModule'
55import { App, Database } from 'test/Utils'
6- import { <%= namePascal %>Seeder } from 'database/seeds /<%= namePascal %>Seeder '
6+ import { <%= namePascal %>Factory } from 'database/factories /<%= namePascal %>Factory '
77
88describe('\n[E2E] <%= namePascal %> 🛠', () => {
99 it('should update one <%= nameCamel %>', async () => {
10- const <%= nameCamel %> = await <%= nameCamel %>Seeder.seedOne ()
10+ const <%= nameCamel %> = await <%= nameCamel %>Factory.create ()
1111
1212 const status = 200
1313 const method = 'PUT'
14- const path = `/<%= namePluralCamel %>/${<%= nameCamel %>.id}`
14+ const path = `/<%= namePluralCamel %>/${<%= nameCamel %>.id}?apiKey=${apiKey} `
1515
16- const updateBlueprint = <%= nameCamel %>Seeder.updateBlueprint()
16+ const payload = {
17+ name: 'test',
18+ }
1719
1820 const { body } = await request(app.server.getHttpServer())
1921 .put(path)
20- .send(updateBlueprint )
22+ .send(payload )
2123 .expect(status)
2224
2325 expect(body.method).toBe(method)
2426 expect(body.status).toBe(status)
2527 expect(body.data.id).toBe(<%= nameCamel %>.id)
28+ expect(body.data.name).toBe(payload.name)
2629 })
2730
2831 it('should throw a not found error when can not find <%= nameCamel %>', async () => {
2932 const status = 404
3033 const method = 'PUT'
31- const path = `/<%= namePluralCamel %>/507f1f77bcf86cd799439011`
32-
33- const updateBlueprint = <%= nameCamel %>Seeder.blueprint()
34+ const path = `/<%= namePluralCamel %>/507f1f77bcf86cd799439011?apiKey=${apiKey}`
3435
3536 const { body } = await request(app.server.getHttpServer())
3637 .put(path)
37- .send(updateBlueprint )
38+ .send({ name: 'test' } )
3839 .expect(status)
3940
4041 expect(body.method).toBe(method)
4142 expect(body.status).toBe(status)
4243 expect(body.error).toEqual({
44+ isSecJsException: true,
4345 name: 'NotFoundException',
4446 message: {
45- error: 'Not Found',
47+ error: 'Not Found Error ',
4648 message: 'NOT_FOUND_<%= nameUp %>',
4749 statusCode: status,
4850 },
@@ -53,7 +55,7 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
5355 // And create tests to validate if the schema validator are working well.
5456
5557 // it('should throw validation errors when trying to update a <%= nameCamel %> with validation errors', async () => {
56- // const status = 400
58+ // const status = 422
5759 // const path = `/<%= namePluralCamel %>/507f1f77bcf86cd799439011`
5860 //
5961 // const { body } = await request(app.server.getHttpServer())
@@ -72,15 +74,15 @@ describe('\n[E2E] <%= namePascal %> 🛠', () => {
7274
7375let app: App
7476let database: Database
75- let <%= nameCamel %>Seeder : <%= namePascal %>Seeder
77+ let <%= nameCamel %>Factory : <%= namePascal %>Factory
7678
7779beforeEach(async () => {
7880 Debug(`Executing ${beforeEach.name}`, 'api:test')
7981
8082 app = await new App([AppModule]).initApp()
8183 database = new Database(app)
8284
83- <%= nameCamel %>Seeder = app.getInstance(<%= namePascal %>Seeder )
85+ <%= nameCamel %>Factory = app.getInstance(<%= namePascal %>Factory )
8486})
8587
8688afterEach(async () => {
@@ -90,4 +92,3 @@ afterEach(async () => {
9092 await database.truncateCache()
9193 await app.closeApp()
9294})
93-
0 commit comments