mirror of
https://github.com/hantsy/nestjs-rest-sample.git
synced 2025-12-08 20:36:27 +00:00
chore: fixes mongoose 6.0 upgrade
This commit is contained in:
parent
2cb18ecf9c
commit
bc4c004070
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,6 +5,7 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nestjs-sample",
|
||||
"version": "0.0.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
|
||||
@ -34,10 +34,10 @@ describe('DatabaseConnectionProviders', () => {
|
||||
//expect(conn).toBeDefined();
|
||||
//expect(createConnection).toHaveBeenCalledTimes(1); // it is 2 here. why?
|
||||
expect(createConnection).toHaveBeenCalledWith("mongodb://localhost/blog", {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
// useNewUrlParser: true,
|
||||
// useUnifiedTopology: true,
|
||||
//see: https://mongoosejs.com/docs/deprecations.html#findandmodify
|
||||
useFindAndModify: false
|
||||
// useFindAndModify: false
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@ -8,10 +8,10 @@ export const databaseConnectionProviders = [
|
||||
provide: DATABASE_CONNECTION,
|
||||
useFactory: (dbConfig: ConfigType<typeof mongodbConfig>): Connection => {
|
||||
const conn = createConnection(dbConfig.uri, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
//useNewUrlParser: true,
|
||||
//useUnifiedTopology: true,
|
||||
//see: https://mongoosejs.com/docs/deprecations.html#findandmodify
|
||||
useFindAndModify: false,
|
||||
//useFindAndModify: false,
|
||||
});
|
||||
|
||||
// conn.on('disconnect', () => {
|
||||
|
||||
@ -71,7 +71,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (GET) if none existing should return 404', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer()).get('/posts/' + id);
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
@ -90,7 +90,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (PUT) should return 401', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer())
|
||||
.put('/posts/' + id)
|
||||
.send({ title: 'test title', content: 'test content' });
|
||||
@ -98,7 +98,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (DELETE) should return 401', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer())
|
||||
.delete('/posts/' + id)
|
||||
.send();
|
||||
@ -134,7 +134,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (PUT) if none existing should return 404', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer())
|
||||
.put('/posts/' + id)
|
||||
.set('Authorization', 'Bearer ' + jwttoken)
|
||||
@ -143,7 +143,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (DELETE) if none existing should return 403', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer())
|
||||
.delete('/posts/' + id)
|
||||
.set('Authorization', 'Bearer ' + jwttoken)
|
||||
@ -217,7 +217,7 @@ describe('API endpoints testing (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/posts (DELETE) if none existing should return 404', async () => {
|
||||
const id = mongoose.Types.ObjectId();
|
||||
const id = new mongoose.Types.ObjectId();
|
||||
const res = await request(app.getHttpServer())
|
||||
.delete('/posts/' + id)
|
||||
.set('Authorization', 'Bearer ' + jwttoken)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user