Skip to content

Commit

Permalink
test(request): updated tests with query limit param
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelyali committed Dec 12, 2019
1 parent af6c635 commit 45dc02b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
"peerDependencies": {},
"optionalDependencies": {},
"dependencies": {
"@nestjs/common": "^6.10.10",
"@nestjs/core": "^6.10.10",
"@nestjs/platform-express": "^6.10.10",
"@nestjs/swagger": "4",
"@nestjs/testing": "^6.10.10",
"@nestjs/typeorm": "^6.2.0",
"@nestjs/common": "6.10.10",
"@nestjs/core": "6.10.10",
"@nestjs/platform-express": "6.10.10",
"@nestjs/swagger": "4.0.9",
"@nestjs/testing": "6.10.10",
"@nestjs/typeorm": "6.2.0",
"@nuxtjs/opencollective": "0.2.2",
"@types/jest": "24.0.18",
"@types/node": "12.7.5",
Expand All @@ -71,7 +71,7 @@
"cz-conventional-changelog": "3.0.2",
"husky": "3.0.5",
"jest": "24.9.0",
"jest-extended": "^0.11.2",
"jest-extended": "0.11.2",
"lerna": "3.16.4",
"nodemon": "1.19.2",
"npm-check": "5.9.0",
Expand All @@ -89,7 +89,7 @@
"swagger-ui-express": "4.1.0",
"ts-jest": "24.1.0",
"ts-node": "8.3.0",
"tsconfig-extends": "^1.0.1",
"tsconfig-extends": "1.0.1",
"tsconfig-paths": "3.9.0",
"tslint": "5.20.0",
"tslint-config-prettier": "1.18.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/crud-request/test/request-query.builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ describe('#request-query', () => {
describe('#setLimit', () => {
it('should not throw', () => {
(qb as any).setLimit();
expect(qb.queryObject.per_page).toBeUndefined();
expect(qb.queryObject.limit).toBeUndefined();
});
it('should throw an error', () => {
expect((qb.setLimit as any).bind(qb, {})).toThrowError(RequestQueryException);
});
it('should set limit', () => {
const expected = 10;
qb.setLimit(expected);
expect(qb.queryObject.per_page).toBe(expected);
expect(qb.queryObject.limit).toBe(expected);
});
});

Expand Down Expand Up @@ -337,7 +337,7 @@ describe('#request-query', () => {
.resetCache()
.query(false);
const expected =
'fields=foo,bar&filter[0]=is||notnull&or[0]=ok||ne||false&join[0]=voo||h,data&per_page=1&offset=2&page=3&sort[0]=foo,DESC&cache=0';
'fields=foo,bar&filter[0]=is||notnull&or[0]=ok||ne||false&join[0]=voo||h,data&limit=1&offset=2&page=3&sort[0]=foo,DESC&cache=0';
expect(test).toBe(expected);
});
});
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('#request-query', () => {
resetCache: true,
}).query(false);
const expected =
'fields=foo,bar&filter[0]=is||notnull&or[0]=ok||ne||false&join[0]=voo||h,data&per_page=1&offset=2&page=3&sort[0]=foo,DESC&cache=0';
'fields=foo,bar&filter[0]=is||notnull&or[0]=ok||ne||false&join[0]=voo||h,data&limit=1&offset=2&page=3&sort[0]=foo,DESC&cache=0';
expect(test).toBe(expected);
});
it('should return a valid query string, 2', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/crud-typeorm/test/c.basic-crud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ describe('#crud-typeorm', () => {
return request(server)
.get('/companies')
.end((_, res) => {
console.log(res.body);

expect(res.status).toBe(200);
expect(res.body.length).toBe(10);
done();
Expand Down
2 changes: 1 addition & 1 deletion packages/crud/src/crud/swagger.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Swagger {
page,
cache,
} = Swagger.getQueryParamsNames();
const oldVersion = Swagger.getSwaggerVersion() === 3;
const oldVersion = Swagger.getSwaggerVersion() < 4;
const docsLink = (a: string) =>
`<a href="https://github.com/nestjsx/crud/wiki/Requests#${a}" target="_blank">Docs</a>`;

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@nestjs/common@^6.10.10":
"@nestjs/[email protected]":
version "6.10.10"
resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-6.10.10.tgz#8489b1d32e6e63b82dc8e275fd341431b8eef7af"
integrity sha512-QOPcRLrw5Ra/wRoWYJRnN+Je9xUMGeXGQqyefK0hnKBIne8VMui7N3Vn0HBwijgT/od8TbQ0CGY6iiwKtWqFCQ==
Expand All @@ -1085,7 +1085,7 @@
cli-color "2.0.0"
uuid "3.3.3"

"@nestjs/core@^6.10.10":
"@nestjs/[email protected]":
version "6.10.10"
resolved "https://registry.yarnpkg.com/@nestjs/core/-/core-6.10.10.tgz#7bd586e007d5d17f85cd977d10470152a0663870"
integrity sha512-VCXrYG+ggvJehoUo9QM7ad34Bn/p4PQGN6e/kZuea9NqcYC14U4L/+WThJ1q3OJHssQAMXKjReiEdIbCau6ZwA==
Expand All @@ -1096,7 +1096,7 @@
object-hash "2.0.1"
uuid "3.3.3"

"@nestjs/platform-express@^6.10.10":
"@nestjs/[email protected]":
version "6.10.10"
resolved "https://registry.yarnpkg.com/@nestjs/platform-express/-/platform-express-6.10.10.tgz#17b300697761622d3d67f635f4ca55d0ab6934f3"
integrity sha512-UcHMrFwWfdq15ZW2u6q0oda/XI3oR79GEdCvYWfl4anjLxxOc01AH9hjjdcADkHyKrxbwCSjr/H31c04Cvl9FQ==
Expand All @@ -1106,22 +1106,22 @@
express "4.17.1"
multer "1.4.2"

"@nestjs/swagger@4":
"@nestjs/swagger@4.0.9":
version "4.0.9"
resolved "https://registry.yarnpkg.com/@nestjs/swagger/-/swagger-4.0.9.tgz#dfa2105568515bea837b9119d0b94a8763a7e616"
integrity sha512-qVPprSzbgxGlODNC0KOnqa8lUdcIsrT/oqljzxDRd1j2Jj2ZqFQN84+n91+Ynukl3MRc+16e/pu9qp6z9041OA==
dependencies:
lodash "4.17.15"
path-to-regexp "6.1.0"

"@nestjs/testing@^6.10.10":
"@nestjs/[email protected]":
version "6.10.10"
resolved "https://registry.yarnpkg.com/@nestjs/testing/-/testing-6.10.10.tgz#f16f13bd2c904cd374db58c981ab94bee0d286fe"
integrity sha512-dusjypkEyiqaQiA4zReb3dE9SGDjkgtOozJXVG12MyUHtKwDkD/ok5dAzynqgbhVIiykIzozUwUPOjauMstTxA==
dependencies:
optional "0.1.4"

"@nestjs/typeorm@^6.2.0":
"@nestjs/[email protected]":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@nestjs/typeorm/-/typeorm-6.2.0.tgz#6b8e3d80e3fbd9dc5e0a9d1ebf3028f7adb1ace9"
integrity sha512-CRDYV3oxTUa6mTDJfdW+RPLtVUpGx0RpigQdLlvMFLM56v+bYnrTuuy4vurKDgLNFC+AttL9JLZOgRhW8fGdgQ==
Expand Down Expand Up @@ -4877,7 +4877,7 @@ jest-environment-node@^24.9.0:
jest-mock "^24.9.0"
jest-util "^24.9.0"

jest-extended@^0.11.2:
[email protected]:
version "0.11.2"
resolved "https://registry.yarnpkg.com/jest-extended/-/jest-extended-0.11.2.tgz#924f4a6b4c946133faf9ec8fba865de9790f4116"
integrity sha512-gwNMXrAPN0IY5L7VXWfSlC2aGo0KHIsGGcW+lTHYpedt5SJksEvBgMxs29iNikiNOz+cqAZY1s/+kYK0jlj4Jw==
Expand Down Expand Up @@ -8558,7 +8558,7 @@ [email protected]:
source-map-support "^0.5.6"
yn "^3.0.0"

tsconfig-extends@^1.0.1:
[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tsconfig-extends/-/tsconfig-extends-1.0.1.tgz#f5e5a4c3520a284c5642a7fb57713cbb7ae42f0f"
integrity sha1-9eWkw1IKKExWQqf7V3E8u3rkLw8=
Expand Down

0 comments on commit 45dc02b

Please sign in to comment.