Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(type): avueCrudOption add "[key: string]: any" #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@
"serve": "tsc --watch"
},
"devDependencies": {
"@nestjs/common": "^7.6.13",
"@nestjs/core": "^7.6.13",
"@nestjs/platform-express": "^7.6.13",
"@nestjs/swagger": "^4.7.15",
"@nestjs/testing": "^7.6.13",
"@nestjs/common": "8.2.6",
"@nestjs/core": "8.2.6",
"@nestjs/platform-express": "8.2.6",
"@nestjs/swagger": "5.2.0",
"@nestjs/testing": "8.2.6",
"@types/express": "^4.17.11",
"@types/jest": "^26.0.20",
"@types/jest": "27.4.0",
"@types/lodash": "^4.14.168",
"@types/supertest": "^2.0.10",
"class-transformer": "^0.4.0",
"class-transformer": "0.5.1",
"class-validator": "^0.13.1",
"jest": "^26.4.2",
"jest": "27.4.7",
"lodash": "^4.17.21",
"mongoose": "^5.11.18",
"mongoose": "6.1.8",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.6.6",
"rxjs": "7.5.2",
"supertest": "^6.1.3",
"ts-jest": "^26.5.2",
"ts-jest": "27.1.3",
"typescript": "^4.2.2"
},
"peerDependencies": {},
"dependencies": {}
}
}
30 changes: 20 additions & 10 deletions src/crud.controller.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import * as request from "supertest";
import { Crud } from "./crud.decorator";

const DB =
process.env.DB || "mongodb://localhost/nestjs-mongoose-crud-test-e2e";
mongoose.connect(DB, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
});
process.env.DB || "mongodb://localhost/test";

const UserModel = mongoose.model(
"User",
Expand Down Expand Up @@ -43,6 +37,22 @@ describe("CrudController e2e", () => {
let totalUsers = 15;

beforeAll(async () => {
await mongoose.connect(DB, {
// useNewUrlParser: true,
// useUnifiedTopology: true,
// useCreateIndex: true,
// useFindAndModify: false,
auth: {
username: 'admin',
password: '123456'
}
}).then(m => {
console.log('连接成功!')
}).catch(error => {
console.error('连接失败!')
console.error(error)
})

await UserModel.deleteMany({});
const lastNames = `阿赵钱孙李周吴郑王`;
const users = Array(totalUsers)
Expand All @@ -64,13 +74,13 @@ describe("CrudController e2e", () => {
mongoose.disconnect();
});
describe("create", () => {

it("should create a user", async () => {
return request(server)
.post("/users")
.send({ username: `test1` })
.expect((res) => expect(res.body).toHaveProperty("_id"));
});
}, 30000);
it("should sort chinese name", async () => {
return request(server)
.get(`/users?query={"limit":8,"sort":"name","collation":{"locale":"zh"}}`)
Expand All @@ -79,7 +89,7 @@ describe("CrudController e2e", () => {
expect(res.body.data).toHaveLength(8)
expect(res.body.data[1]).toMatchObject({ name: "阿" });
});
});
}, 30000);
// end of it()
});
});
1 change: 1 addition & 0 deletions src/crud.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface AvueCrudOption {
width?: number
column?: Field[]
group?: Field[]
[key: string]: any
}

export interface AvueCrudConfig {
Expand Down
Loading