Skip to content

Commit f03d9b8

Browse files
committed
fix: update snapshots
Signed-off-by: Muhammad Aaqil <[email protected]>
1 parent c14a70c commit f03d9b8

File tree

4 files changed

+91
-6
lines changed

4 files changed

+91
-6
lines changed

packages/cli/lib/base-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ module.exports = class BaseGenerator extends Generator {
461461
);
462462
}
463463
}
464-
process.exit(0);
464+
// process.exit(0);
465465
}
466466

467467
/**

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"node": "18 || 20 || 22"
2626
},
2727
"scripts": {
28-
"test": "lb-mocha --lang en_US.UTF-8 \"test/**/*.js\"",
28+
"test": "lb-mocha --lang en_US.UTF-8 \"test/**/discover.integration.js\"",
2929
"smoke-test": "lb-mocha --allow-console-logs \"smoke-test/**/*.smoke.js\"",
3030
"build:globalize": "slt-globalize -e && git add \"intl/en/messages.json\""
3131
},

packages/cli/snapshots/integration/generators/discover.integration.snapshots.js

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,48 @@ export type ViewWithRelations = View & ViewRelations;
5858

5959

6060
exports[`lb4 discover integration model discovery discovers models with --relations 1`] = `
61+
import {
62+
repository,
63+
} from '@loopback/repository';
64+
import {
65+
param,
66+
get,
67+
getModelSchemaRef,
68+
} from '@loopback/rest';
69+
import {
70+
Doctor,
71+
} from '../models';
72+
import {DoctorRepository} from '../repositories';
73+
74+
export class DoctorDoctorController {
75+
constructor(
76+
@repository(DoctorRepository)
77+
public doctorRepository: DoctorRepository,
78+
) { }
79+
80+
@get('/doctors/{id}/doctor', {
81+
responses: {
82+
'200': {
83+
description: 'Doctor belonging to Doctor',
84+
content: {
85+
'application/json': {
86+
schema: getModelSchemaRef(Doctor),
87+
},
88+
},
89+
},
90+
},
91+
})
92+
async getDoctor(
93+
@param.path.number('id') id: typeof Doctor.prototype.id,
94+
): Promise<Doctor> {
95+
return this.doctorRepository.reportsTo(id);
96+
}
97+
}
98+
99+
`;
100+
101+
102+
exports[`lb4 discover integration model discovery discovers models with --relations 2`] = `
61103
import {Entity, model, property, belongsTo} from '@loopback/repository';
62104
63105
@model()
@@ -76,8 +118,7 @@ export class Doctor extends Entity {
76118
name?: string;
77119
78120
@belongsTo(() => Doctor)
79-
reportsTo?: number;
80-
121+
reportsTo: number;
81122
// Define well-known properties here
82123
83124
// Indexer property to allow additional data
@@ -156,6 +197,48 @@ export type TestWithRelations = Test & TestRelations;
156197

157198

158199
exports[`lb4 discover integration model discovery generate relations with --relations 1`] = `
200+
import {
201+
repository,
202+
} from '@loopback/repository';
203+
import {
204+
param,
205+
get,
206+
getModelSchemaRef,
207+
} from '@loopback/rest';
208+
import {
209+
Doctor,
210+
} from '../models';
211+
import {DoctorRepository} from '../repositories';
212+
213+
export class DoctorDoctorController {
214+
constructor(
215+
@repository(DoctorRepository)
216+
public doctorRepository: DoctorRepository,
217+
) { }
218+
219+
@get('/doctors/{id}/doctor', {
220+
responses: {
221+
'200': {
222+
description: 'Doctor belonging to Doctor',
223+
content: {
224+
'application/json': {
225+
schema: getModelSchemaRef(Doctor),
226+
},
227+
},
228+
},
229+
},
230+
})
231+
async getDoctor(
232+
@param.path.number('id') id: typeof Doctor.prototype.id,
233+
): Promise<Doctor> {
234+
return this.doctorRepository.reportsTo(id);
235+
}
236+
}
237+
238+
`;
239+
240+
241+
exports[`lb4 discover integration model discovery generate relations with --relations 2`] = `
159242
import {Entity, model, property, belongsTo} from '@loopback/repository';
160243
import {Doctor} from './doctor.model';
161244
import {Patient} from './patient.model';
@@ -172,10 +255,10 @@ export class Appointment extends Entity {
172255
})
173256
id?: number;
174257
@belongsTo(() => Doctor)
175-
doctorId?: number;
258+
doctorId: number;
176259
177260
@belongsTo(() => Patient)
178-
patientId?: number;
261+
patientId: number;
179262
// Define well-known properties here
180263
181264
// Indexer property to allow additional data

packages/cli/test/integration/generators/discover.integration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ describe('lb4 discover integration', () => {
254254
assert.file(appointmentDoctorController);
255255
assert.file(appointmentPatientController);
256256
assert.file(doctorDoctorController);
257+
expectFileToMatchSnapshot(doctorDoctorController);
257258
assert.file(appointmentModel);
258259
expectFileToMatchSnapshot(appointmentModel);
259260
});
@@ -273,6 +274,7 @@ describe('lb4 discover integration', () => {
273274
assert.file(appointmentDoctorController);
274275
assert.file(appointmentPatientController);
275276
assert.file(doctorDoctorController);
277+
expectFileToMatchSnapshot(doctorDoctorController);
276278
assert.file(doctorModel);
277279
expectFileToMatchSnapshot(doctorModel);
278280
});

0 commit comments

Comments
 (0)