@mx-space/api-client 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/esm/adaptors/axios.d.ts +4 -0
- package/esm/adaptors/axios.js +37 -0
- package/esm/adaptors/axios.js.map +1 -0
- package/esm/adaptors/ky.d.ts +23 -0
- package/esm/adaptors/ky.js +62 -0
- package/esm/adaptors/ky.js.map +1 -0
- package/esm/adaptors/umi-request.d.ts +4 -0
- package/esm/adaptors/umi-request.js +31 -0
- package/esm/adaptors/umi-request.js.map +1 -0
- package/esm/controllers/aggregate.d.ts +64 -0
- package/esm/controllers/aggregate.js +42 -0
- package/esm/controllers/aggregate.js.map +1 -0
- package/esm/controllers/base.d.ts +43 -0
- package/esm/controllers/base.js +27 -0
- package/esm/controllers/base.js.map +1 -0
- package/esm/controllers/category.d.ts +114 -0
- package/esm/controllers/category.js +68 -0
- package/esm/controllers/category.js.map +1 -0
- package/esm/controllers/comment.d.ts +81 -0
- package/esm/controllers/comment.js +47 -0
- package/esm/controllers/comment.js.map +1 -0
- package/esm/controllers/index.d.ts +18 -0
- package/esm/controllers/index.js +55 -0
- package/esm/controllers/index.js.map +1 -0
- package/esm/controllers/link.d.ts +20 -0
- package/esm/controllers/link.js +21 -0
- package/esm/controllers/link.js.map +1 -0
- package/esm/controllers/note.d.ts +123 -0
- package/esm/controllers/note.js +68 -0
- package/esm/controllers/note.js.map +1 -0
- package/esm/controllers/page.d.ts +59 -0
- package/esm/controllers/page.js +42 -0
- package/esm/controllers/page.js.map +1 -0
- package/esm/controllers/post.d.ts +72 -0
- package/esm/controllers/post.js +52 -0
- package/esm/controllers/post.js.map +1 -0
- package/esm/controllers/project.d.ts +15 -0
- package/esm/controllers/project.js +12 -0
- package/esm/controllers/project.js.map +1 -0
- package/esm/controllers/recently.d.ts +61 -0
- package/esm/controllers/recently.js +31 -0
- package/esm/controllers/recently.js.map +1 -0
- package/esm/controllers/say.d.ts +37 -0
- package/esm/controllers/say.js +21 -0
- package/esm/controllers/say.js.map +1 -0
- package/esm/controllers/search.d.ts +247 -0
- package/esm/controllers/search.js +28 -0
- package/esm/controllers/search.js.map +1 -0
- package/esm/controllers/severless.d.ts +24 -0
- package/esm/controllers/severless.js +16 -0
- package/esm/controllers/severless.js.map +1 -0
- package/esm/controllers/snippet.d.ts +24 -0
- package/esm/controllers/snippet.js +19 -0
- package/esm/controllers/snippet.js.map +1 -0
- package/esm/controllers/topic.d.ts +26 -0
- package/esm/controllers/topic.js +18 -0
- package/esm/controllers/topic.js.map +1 -0
- package/esm/controllers/user.d.ts +70 -0
- package/esm/controllers/user.js +40 -0
- package/esm/controllers/user.js.map +1 -0
- package/esm/core/attach-request.d.ts +2 -0
- package/esm/core/attach-request.js +36 -0
- package/esm/core/attach-request.js.map +1 -0
- package/esm/core/client.d.ts +29 -0
- package/esm/core/client.js +186 -0
- package/esm/core/client.js.map +1 -0
- package/esm/core/error.d.ts +6 -0
- package/esm/core/error.js +9 -0
- package/esm/core/error.js.map +1 -0
- package/esm/core/index.d.ts +2 -0
- package/esm/core/index.js +3 -0
- package/esm/core/index.js.map +1 -0
- package/esm/dtos/comment.d.ts +6 -0
- package/esm/dtos/comment.js +3 -0
- package/esm/dtos/comment.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +8 -0
- package/esm/index.js.map +1 -0
- package/esm/interfaces/adapter.d.ts +14 -0
- package/esm/interfaces/adapter.js +2 -0
- package/esm/interfaces/adapter.js.map +1 -0
- package/esm/interfaces/client.d.ts +13 -0
- package/esm/interfaces/client.js +2 -0
- package/esm/interfaces/client.js.map +1 -0
- package/esm/interfaces/controller.d.ts +4 -0
- package/esm/interfaces/controller.js +2 -0
- package/esm/interfaces/controller.js.map +1 -0
- package/esm/interfaces/instance.d.ts +7 -0
- package/esm/interfaces/instance.js +2 -0
- package/esm/interfaces/instance.js.map +1 -0
- package/esm/interfaces/options.d.ts +1 -0
- package/esm/interfaces/options.js +2 -0
- package/esm/interfaces/options.js.map +1 -0
- package/esm/interfaces/params.d.ts +4 -0
- package/esm/interfaces/params.js +2 -0
- package/esm/interfaces/params.js.map +1 -0
- package/esm/interfaces/request.d.ts +43 -0
- package/esm/interfaces/request.js +2 -0
- package/esm/interfaces/request.js.map +1 -0
- package/esm/interfaces/types.d.ts +2 -0
- package/esm/interfaces/types.js +2 -0
- package/esm/interfaces/types.js.map +1 -0
- package/esm/models/aggregate.d.ts +53 -0
- package/esm/models/aggregate.js +6 -0
- package/esm/models/aggregate.js.map +1 -0
- package/esm/models/base.d.ts +41 -0
- package/esm/models/base.js +2 -0
- package/esm/models/base.js.map +1 -0
- package/esm/models/category.d.ts +22 -0
- package/esm/models/category.js +6 -0
- package/esm/models/category.js.map +1 -0
- package/esm/models/comment.d.ts +37 -0
- package/esm/models/comment.js +13 -0
- package/esm/models/comment.js.map +1 -0
- package/esm/models/index.d.ts +14 -0
- package/esm/models/index.js +15 -0
- package/esm/models/index.js.map +1 -0
- package/esm/models/link.d.ts +22 -0
- package/esm/models/link.js +14 -0
- package/esm/models/link.js.map +1 -0
- package/esm/models/note.d.ts +38 -0
- package/esm/models/note.js +2 -0
- package/esm/models/note.js.map +1 -0
- package/esm/models/page.d.ts +14 -0
- package/esm/models/page.js +7 -0
- package/esm/models/page.js.map +1 -0
- package/esm/models/post.d.ts +17 -0
- package/esm/models/post.js +2 -0
- package/esm/models/post.js.map +1 -0
- package/esm/models/project.d.ts +11 -0
- package/esm/models/project.js +2 -0
- package/esm/models/project.js.map +1 -0
- package/esm/models/recently.d.ts +20 -0
- package/esm/models/recently.js +7 -0
- package/esm/models/recently.js.map +1 -0
- package/esm/models/say.d.ts +6 -0
- package/esm/models/say.js +2 -0
- package/esm/models/say.js.map +1 -0
- package/esm/models/setting.d.ts +66 -0
- package/esm/models/setting.js +2 -0
- package/esm/models/setting.js.map +1 -0
- package/esm/models/snippet.d.ts +18 -0
- package/esm/models/snippet.js +8 -0
- package/esm/models/snippet.js.map +1 -0
- package/esm/models/topic.d.ts +8 -0
- package/esm/models/topic.js +2 -0
- package/esm/models/topic.js.map +1 -0
- package/esm/models/user.d.ts +21 -0
- package/esm/models/user.js +2 -0
- package/esm/models/user.js.map +1 -0
- package/esm/utils/auto-bind.d.ts +4 -0
- package/esm/utils/auto-bind.js +36 -0
- package/esm/utils/auto-bind.js.map +1 -0
- package/esm/utils/camelcase-keys.d.ts +6 -0
- package/esm/utils/camelcase-keys.js +23 -0
- package/esm/utils/camelcase-keys.js.map +1 -0
- package/esm/utils/index.d.ts +5 -0
- package/esm/utils/index.js +43 -0
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/path.d.ts +1 -0
- package/esm/utils/path.js +7 -0
- package/esm/utils/path.js.map +1 -0
- package/esm/vitest.config.d.ts +2 -0
- package/esm/vitest.config.js +12 -0
- package/esm/vitest.config.js.map +1 -0
- package/lib/adaptors/axios.d.ts +4 -0
- package/lib/adaptors/axios.js +43 -0
- package/lib/adaptors/axios.js.map +1 -0
- package/lib/adaptors/ky.d.ts +23 -0
- package/lib/adaptors/ky.js +69 -0
- package/lib/adaptors/ky.js.map +1 -0
- package/lib/adaptors/umi-request.d.ts +4 -0
- package/lib/adaptors/umi-request.js +34 -0
- package/lib/adaptors/umi-request.js.map +1 -0
- package/lib/controllers/aggregate.d.ts +64 -0
- package/lib/controllers/aggregate.js +46 -0
- package/lib/controllers/aggregate.js.map +1 -0
- package/lib/controllers/base.d.ts +43 -0
- package/lib/controllers/base.js +31 -0
- package/lib/controllers/base.js.map +1 -0
- package/lib/controllers/category.d.ts +114 -0
- package/lib/controllers/category.js +72 -0
- package/lib/controllers/category.js.map +1 -0
- package/lib/controllers/comment.d.ts +81 -0
- package/lib/controllers/comment.js +51 -0
- package/lib/controllers/comment.js.map +1 -0
- package/lib/controllers/index.d.ts +18 -0
- package/lib/controllers/index.js +72 -0
- package/lib/controllers/index.js.map +1 -0
- package/lib/controllers/link.d.ts +20 -0
- package/lib/controllers/link.js +25 -0
- package/lib/controllers/link.js.map +1 -0
- package/lib/controllers/note.d.ts +123 -0
- package/lib/controllers/note.js +72 -0
- package/lib/controllers/note.js.map +1 -0
- package/lib/controllers/page.d.ts +59 -0
- package/lib/controllers/page.js +46 -0
- package/lib/controllers/page.js.map +1 -0
- package/lib/controllers/post.d.ts +72 -0
- package/lib/controllers/post.js +56 -0
- package/lib/controllers/post.js.map +1 -0
- package/lib/controllers/project.d.ts +15 -0
- package/lib/controllers/project.js +16 -0
- package/lib/controllers/project.js.map +1 -0
- package/lib/controllers/recently.d.ts +61 -0
- package/lib/controllers/recently.js +35 -0
- package/lib/controllers/recently.js.map +1 -0
- package/lib/controllers/say.d.ts +37 -0
- package/lib/controllers/say.js +25 -0
- package/lib/controllers/say.js.map +1 -0
- package/lib/controllers/search.d.ts +247 -0
- package/lib/controllers/search.js +32 -0
- package/lib/controllers/search.js.map +1 -0
- package/lib/controllers/severless.d.ts +24 -0
- package/lib/controllers/severless.js +20 -0
- package/lib/controllers/severless.js.map +1 -0
- package/lib/controllers/snippet.d.ts +24 -0
- package/lib/controllers/snippet.js +23 -0
- package/lib/controllers/snippet.js.map +1 -0
- package/lib/controllers/topic.d.ts +26 -0
- package/lib/controllers/topic.js +22 -0
- package/lib/controllers/topic.js.map +1 -0
- package/lib/controllers/user.d.ts +70 -0
- package/lib/controllers/user.js +44 -0
- package/lib/controllers/user.js.map +1 -0
- package/lib/core/attach-request.d.ts +2 -0
- package/lib/core/attach-request.js +40 -0
- package/lib/core/attach-request.js.map +1 -0
- package/lib/core/client.d.ts +29 -0
- package/lib/core/client.js +190 -0
- package/lib/core/client.js.map +1 -0
- package/lib/core/error.d.ts +6 -0
- package/lib/core/error.js +13 -0
- package/lib/core/error.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +19 -0
- package/lib/core/index.js.map +1 -0
- package/lib/dtos/comment.d.ts +6 -0
- package/lib/dtos/comment.js +7 -0
- package/lib/dtos/comment.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/adapter.d.ts +14 -0
- package/lib/interfaces/adapter.js +3 -0
- package/lib/interfaces/adapter.js.map +1 -0
- package/lib/interfaces/client.d.ts +13 -0
- package/lib/interfaces/client.js +3 -0
- package/lib/interfaces/client.js.map +1 -0
- package/lib/interfaces/controller.d.ts +4 -0
- package/lib/interfaces/controller.js +3 -0
- package/lib/interfaces/controller.js.map +1 -0
- package/lib/interfaces/instance.d.ts +7 -0
- package/lib/interfaces/instance.js +3 -0
- package/lib/interfaces/instance.js.map +1 -0
- package/lib/interfaces/options.d.ts +1 -0
- package/lib/interfaces/options.js +3 -0
- package/lib/interfaces/options.js.map +1 -0
- package/lib/interfaces/params.d.ts +4 -0
- package/lib/interfaces/params.js +3 -0
- package/lib/interfaces/params.js.map +1 -0
- package/lib/interfaces/request.d.ts +43 -0
- package/lib/interfaces/request.js +3 -0
- package/lib/interfaces/request.js.map +1 -0
- package/lib/interfaces/types.d.ts +2 -0
- package/lib/interfaces/types.js +3 -0
- package/lib/interfaces/types.js.map +1 -0
- package/lib/models/aggregate.d.ts +53 -0
- package/lib/models/aggregate.js +9 -0
- package/lib/models/aggregate.js.map +1 -0
- package/lib/models/base.d.ts +41 -0
- package/lib/models/base.js +3 -0
- package/lib/models/base.js.map +1 -0
- package/lib/models/category.d.ts +22 -0
- package/lib/models/category.js +9 -0
- package/lib/models/category.js.map +1 -0
- package/lib/models/comment.d.ts +37 -0
- package/lib/models/comment.js +16 -0
- package/lib/models/comment.js.map +1 -0
- package/lib/models/index.d.ts +14 -0
- package/lib/models/index.js +31 -0
- package/lib/models/index.js.map +1 -0
- package/lib/models/link.d.ts +22 -0
- package/lib/models/link.js +17 -0
- package/lib/models/link.js.map +1 -0
- package/lib/models/note.d.ts +38 -0
- package/lib/models/note.js +3 -0
- package/lib/models/note.js.map +1 -0
- package/lib/models/page.d.ts +14 -0
- package/lib/models/page.js +10 -0
- package/lib/models/page.js.map +1 -0
- package/lib/models/post.d.ts +17 -0
- package/lib/models/post.js +3 -0
- package/lib/models/post.js.map +1 -0
- package/lib/models/project.d.ts +11 -0
- package/lib/models/project.js +3 -0
- package/lib/models/project.js.map +1 -0
- package/lib/models/recently.d.ts +20 -0
- package/lib/models/recently.js +10 -0
- package/lib/models/recently.js.map +1 -0
- package/lib/models/say.d.ts +6 -0
- package/lib/models/say.js +3 -0
- package/lib/models/say.js.map +1 -0
- package/lib/models/setting.d.ts +66 -0
- package/lib/models/setting.js +3 -0
- package/lib/models/setting.js.map +1 -0
- package/lib/models/snippet.d.ts +18 -0
- package/lib/models/snippet.js +11 -0
- package/lib/models/snippet.js.map +1 -0
- package/lib/models/topic.d.ts +8 -0
- package/lib/models/topic.js +3 -0
- package/lib/models/topic.js.map +1 -0
- package/lib/models/user.d.ts +21 -0
- package/lib/models/user.js +3 -0
- package/lib/models/user.js.map +1 -0
- package/lib/utils/auto-bind.d.ts +4 -0
- package/lib/utils/auto-bind.js +40 -0
- package/lib/utils/auto-bind.js.map +1 -0
- package/lib/utils/camelcase-keys.d.ts +6 -0
- package/lib/utils/camelcase-keys.js +28 -0
- package/lib/utils/camelcase-keys.js.map +1 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +50 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.js +11 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/vitest.config.d.ts +2 -0
- package/lib/vitest.config.js +17 -0
- package/lib/vitest.config.js.map +1 -0
- package/package.json +25 -12
- package/types/adaptors/axios.d.ts +4 -0
- package/types/adaptors/ky.d.ts +23 -0
- package/types/adaptors/umi-request.d.ts +4 -0
- package/types/controllers/aggregate.d.ts +64 -0
- package/types/controllers/base.d.ts +43 -0
- package/types/controllers/category.d.ts +114 -0
- package/types/controllers/comment.d.ts +81 -0
- package/types/controllers/index.d.ts +18 -0
- package/types/controllers/link.d.ts +20 -0
- package/types/controllers/note.d.ts +123 -0
- package/types/controllers/page.d.ts +59 -0
- package/types/controllers/post.d.ts +72 -0
- package/types/controllers/project.d.ts +15 -0
- package/types/controllers/recently.d.ts +61 -0
- package/types/controllers/say.d.ts +37 -0
- package/types/controllers/search.d.ts +247 -0
- package/types/controllers/severless.d.ts +24 -0
- package/types/controllers/snippet.d.ts +24 -0
- package/types/controllers/topic.d.ts +26 -0
- package/types/controllers/user.d.ts +70 -0
- package/types/core/attach-request.d.ts +2 -0
- package/types/core/client.d.ts +29 -0
- package/types/core/error.d.ts +6 -0
- package/types/core/index.d.ts +2 -0
- package/types/dtos/comment.d.ts +6 -0
- package/types/index.d.ts +7 -0
- package/types/interfaces/adapter.d.ts +14 -0
- package/types/interfaces/client.d.ts +13 -0
- package/types/interfaces/controller.d.ts +4 -0
- package/types/interfaces/instance.d.ts +7 -0
- package/types/interfaces/options.d.ts +1 -0
- package/types/interfaces/params.d.ts +4 -0
- package/types/interfaces/request.d.ts +43 -0
- package/types/interfaces/types.d.ts +2 -0
- package/types/models/aggregate.d.ts +53 -0
- package/types/models/base.d.ts +41 -0
- package/types/models/category.d.ts +22 -0
- package/types/models/comment.d.ts +37 -0
- package/types/models/index.d.ts +14 -0
- package/types/models/link.d.ts +22 -0
- package/types/models/note.d.ts +38 -0
- package/types/models/page.d.ts +14 -0
- package/types/models/post.d.ts +17 -0
- package/types/models/project.d.ts +11 -0
- package/types/models/recently.d.ts +20 -0
- package/types/models/say.d.ts +6 -0
- package/types/models/setting.d.ts +66 -0
- package/types/models/snippet.d.ts +18 -0
- package/types/models/topic.d.ts +8 -0
- package/types/models/user.d.ts +21 -0
- package/types/utils/auto-bind.d.ts +4 -0
- package/types/utils/camelcase-keys.d.ts +6 -0
- package/types/utils/index.d.ts +5 -0
- package/types/utils/path.d.ts +1 -0
- package/types/vitest.config.d.ts +2 -0
- package/__tests__/adaptors/axios.spec.ts +0 -7
- package/__tests__/adaptors/ky.spec.ts +0 -9
- package/__tests__/adaptors/umi-request.spec.ts +0 -7
- package/__tests__/contronllers/aggregate.test.ts +0 -389
- package/__tests__/contronllers/category.test.ts +0 -284
- package/__tests__/contronllers/comment.test.ts +0 -113
- package/__tests__/contronllers/link.test.ts +0 -95
- package/__tests__/contronllers/note.test.ts +0 -120
- package/__tests__/contronllers/page.test.ts +0 -49
- package/__tests__/contronllers/post.test.ts +0 -77
- package/__tests__/contronllers/recently.test.ts +0 -49
- package/__tests__/contronllers/say.test.ts +0 -106
- package/__tests__/contronllers/search.test.ts +0 -81
- package/__tests__/contronllers/serverless.test.ts +0 -19
- package/__tests__/contronllers/snippet.test.ts +0 -38
- package/__tests__/contronllers/topic.test.ts +0 -17
- package/__tests__/contronllers/user.test.ts +0 -59
- package/__tests__/core/client.test.ts +0 -293
- package/__tests__/helpers/adaptor-test.ts +0 -108
- package/__tests__/helpers/e2e-mock-server.ts +0 -22
- package/__tests__/helpers/global-fetch.ts +0 -39
- package/__tests__/helpers/instance.ts +0 -11
- package/__tests__/helpers/response.ts +0 -76
- package/__tests__/mock/algolia.json +0 -446
- package/__tests__/utils/auto-bind.spec.ts +0 -27
- package/__tests__/utils/camelcase-keys.spec.ts +0 -86
- package/__tests__/utils/index.test.ts +0 -33
- package/__tests__/utils/path.spec.ts +0 -8
- package/adaptors/axios.ts +0 -44
- package/adaptors/ky.ts +0 -76
- package/adaptors/umi-request.ts +0 -38
- package/core/attach-request.ts +0 -43
- package/core/client.ts +0 -252
- package/core/error.ts +0 -10
- package/core/index.ts +0 -2
- package/coverage/lcov-report/__tests__/helpers/adaptor-test.ts.html +0 -405
- package/coverage/lcov-report/__tests__/helpers/e2e-mock-server.ts.html +0 -150
- package/coverage/lcov-report/__tests__/helpers/index.html +0 -236
- package/coverage/lcov-report/__tests__/helpers/instance.ts.html +0 -120
- package/coverage/lcov-report/__tests__/helpers/response.ts.html +0 -231
- package/rollup.config.js +0 -150
- package/utils/auto-bind.ts +0 -48
- package/utils/camelcase-keys.ts +0 -26
- package/utils/index.ts +0 -53
- package/utils/path.ts +0 -6
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import camelcaseKeys from 'camelcase-keys'
|
|
2
|
-
|
|
3
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
4
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
5
|
-
import { CommentController } from '~/controllers/comment'
|
|
6
|
-
|
|
7
|
-
describe('test note client', () => {
|
|
8
|
-
const client = mockRequestInstance(CommentController)
|
|
9
|
-
|
|
10
|
-
test('get comment by id', async () => {
|
|
11
|
-
mockResponse('/comments/11111', {
|
|
12
|
-
ref_type: 'Page',
|
|
13
|
-
state: 1,
|
|
14
|
-
children: [],
|
|
15
|
-
comments_index: 1,
|
|
16
|
-
id: '6188b80b6290547080c9e1f3',
|
|
17
|
-
author: 'yss',
|
|
18
|
-
text: '做的框架模板不错. (•౪• ) ',
|
|
19
|
-
url: 'https://gitee.com/kmyss/',
|
|
20
|
-
key: '#26',
|
|
21
|
-
ref: '5e0318319332d06503619337',
|
|
22
|
-
created: '2021-11-08T05:39:23.010Z',
|
|
23
|
-
avatar:
|
|
24
|
-
'https://sdn.geekzu.org/avatar/8675fa376c044b0d93a23374549c4248?d=retro',
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const data = await client.comment.getById('11111')
|
|
28
|
-
expect(data.children).toEqual([])
|
|
29
|
-
expect(data.text).toBeDefined()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('get comment by ref id', async () => {
|
|
33
|
-
const comments = [
|
|
34
|
-
{
|
|
35
|
-
ref_type: 'Page',
|
|
36
|
-
state: 1,
|
|
37
|
-
children: [],
|
|
38
|
-
comments_index: 1,
|
|
39
|
-
id: '6188b80b6290547080c9e1f3',
|
|
40
|
-
author: 'yss',
|
|
41
|
-
text: '做的框架模板不错. (•౪• ) ',
|
|
42
|
-
url: 'https://gitee.com/kmyss/',
|
|
43
|
-
key: '#26',
|
|
44
|
-
ref: '5e0318319332d06503619337',
|
|
45
|
-
created: '2021-11-08T05:39:23.010Z',
|
|
46
|
-
avatar:
|
|
47
|
-
'https://sdn.geekzu.org/avatar/8675fa376c044b0d93a23374549c4248?d=retro',
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
mockResponse(
|
|
51
|
-
'/comments/ref/5e0318319332d06503619337',
|
|
52
|
-
{
|
|
53
|
-
data: comments,
|
|
54
|
-
pagination: {
|
|
55
|
-
total: 23,
|
|
56
|
-
current_page: 1,
|
|
57
|
-
total_page: 3,
|
|
58
|
-
size: 10,
|
|
59
|
-
has_next_page: true,
|
|
60
|
-
has_prev_page: false,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
'get',
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const data = await client.comment.getByRefId('5e0318319332d06503619337')
|
|
67
|
-
|
|
68
|
-
expect(data.data).toEqual(camelcaseKeys(comments, { deep: true }))
|
|
69
|
-
expect(data.pagination.total).toEqual(23)
|
|
70
|
-
expect(data.pagination.hasNextPage).toEqual(true)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('should comment successfully', async () => {
|
|
74
|
-
mockResponse(
|
|
75
|
-
'/comments/1',
|
|
76
|
-
{
|
|
77
|
-
id: '1',
|
|
78
|
-
text: 'bar',
|
|
79
|
-
},
|
|
80
|
-
'post',
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
const data = await client.comment.comment('1', {
|
|
84
|
-
author: 'foo',
|
|
85
|
-
text: 'bar',
|
|
86
|
-
mail: 'xx@aa.com',
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
expect(data).toEqual({
|
|
90
|
-
id: '1',
|
|
91
|
-
text: 'bar',
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should reply comment successfully', async () => {
|
|
96
|
-
mockResponse(
|
|
97
|
-
'/comments/reply/1',
|
|
98
|
-
{
|
|
99
|
-
id: '1',
|
|
100
|
-
text: 'bar',
|
|
101
|
-
},
|
|
102
|
-
'post',
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
const data = await client.comment.reply('1', {
|
|
106
|
-
author: 'f',
|
|
107
|
-
text: 'bar',
|
|
108
|
-
mail: 'a@q.com',
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
expect(data).toEqual({ id: '1', text: 'bar' })
|
|
112
|
-
})
|
|
113
|
-
})
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import camelcaseKeys from 'camelcase-keys'
|
|
2
|
-
|
|
3
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
4
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
5
|
-
import { LinkController } from '~/controllers'
|
|
6
|
-
|
|
7
|
-
describe('test link client, /links', () => {
|
|
8
|
-
const client = mockRequestInstance(LinkController)
|
|
9
|
-
|
|
10
|
-
test('GET /', async () => {
|
|
11
|
-
const mocked = mockResponse('/links?size=10&page=1', {
|
|
12
|
-
data: [
|
|
13
|
-
{
|
|
14
|
-
type: 0,
|
|
15
|
-
state: 0,
|
|
16
|
-
id: '615c191ed5db15a1000e3ca6',
|
|
17
|
-
url: 'https://barry-flynn.github.io/',
|
|
18
|
-
avatar: 'https://i.loli.net/2021/09/09/5belKgmrkjN8ZQ7.jpg',
|
|
19
|
-
description: '星河滚烫,无问西东。',
|
|
20
|
-
name: '百里飞洋の博客',
|
|
21
|
-
created: '2021-10-05T09:21:34.257Z',
|
|
22
|
-
hide: false,
|
|
23
|
-
},
|
|
24
|
-
// ...
|
|
25
|
-
],
|
|
26
|
-
pagination: {
|
|
27
|
-
total: 43,
|
|
28
|
-
current_page: 1,
|
|
29
|
-
total_page: 5,
|
|
30
|
-
size: 10,
|
|
31
|
-
has_next_page: true,
|
|
32
|
-
has_prev_page: false,
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const data = await client.link.getAllPaginated(1, 10)
|
|
37
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
38
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should `friend` == `link`', () => {
|
|
42
|
-
expect(client.link).toEqual(client.friend)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('GET /all', async () => {
|
|
46
|
-
const mocked = mockResponse('/links/all', {
|
|
47
|
-
data: [],
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const data = await client.link.getAll()
|
|
51
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
52
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('GET /:id', async () => {
|
|
56
|
-
const mocked = mockResponse('/links/5eaabe10cd5bca719652179d', {
|
|
57
|
-
id: '5eaabe10cd5bca719652179d',
|
|
58
|
-
name: '静かな森',
|
|
59
|
-
url: 'https://innei.ren',
|
|
60
|
-
avatar: 'https://cdn.innei.ren/avatar.png',
|
|
61
|
-
created: '2020-04-30T12:01:20.738Z',
|
|
62
|
-
type: 0,
|
|
63
|
-
description: '致虚极,守静笃。',
|
|
64
|
-
state: 0,
|
|
65
|
-
})
|
|
66
|
-
const data = await client.link.getById('5eaabe10cd5bca719652179d')
|
|
67
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
68
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
test('GET /audit', async () => {
|
|
72
|
-
const mocked = mockResponse('/links/audit', {
|
|
73
|
-
can: true,
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
const allowed = await client.link.canApplyLink()
|
|
77
|
-
|
|
78
|
-
expect(allowed).toEqual(mocked.can)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test('POST /audit', async () => {
|
|
82
|
-
const payload = {
|
|
83
|
-
author: '',
|
|
84
|
-
avatar: '',
|
|
85
|
-
name: '',
|
|
86
|
-
url: '',
|
|
87
|
-
description: '',
|
|
88
|
-
email: '',
|
|
89
|
-
}
|
|
90
|
-
mockResponse('/links/audit', 'OK', 'post', payload)
|
|
91
|
-
const res = await client.link.applyLink(payload)
|
|
92
|
-
|
|
93
|
-
expect(res).toEqual('OK')
|
|
94
|
-
})
|
|
95
|
-
})
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
4
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
5
|
-
import { axiosAdaptor } from '~/adaptors/axios'
|
|
6
|
-
import { NoteController } from '~/controllers'
|
|
7
|
-
import { RequestError } from '~/core'
|
|
8
|
-
|
|
9
|
-
const { spyOn } = vi
|
|
10
|
-
|
|
11
|
-
describe('test note client', () => {
|
|
12
|
-
const client = mockRequestInstance(NoteController)
|
|
13
|
-
|
|
14
|
-
it('should get note list', async () => {
|
|
15
|
-
mockResponse('/notes', {
|
|
16
|
-
data: [],
|
|
17
|
-
pagination: {},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const data = await client.note.getList()
|
|
21
|
-
expect(data).toEqual({ data: [], pagination: {} })
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('should get post list filter filed', async () => {
|
|
25
|
-
const mocked = mockResponse('/notes?page=1&size=1&select=created+title', {
|
|
26
|
-
data: [{}],
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const data = await client.note.getList(1, 1, {
|
|
30
|
-
select: ['created', 'title'],
|
|
31
|
-
})
|
|
32
|
-
expect(data).toEqual(mocked)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('should get latest note', async () => {
|
|
36
|
-
mockResponse('/notes/latest', { data: { title: '1' } })
|
|
37
|
-
const data = await client.note.getLatest()
|
|
38
|
-
expect(data.data.title).toBe('1')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should get middle list of note', async () => {
|
|
42
|
-
mockResponse('/notes/list/1', {
|
|
43
|
-
data: [
|
|
44
|
-
{
|
|
45
|
-
id: '1',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: '2',
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
size: 2,
|
|
52
|
-
})
|
|
53
|
-
const data = await client.note.getMiddleList('1')
|
|
54
|
-
expect(data).toEqual({
|
|
55
|
-
data: [
|
|
56
|
-
{
|
|
57
|
-
id: '1',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: '2',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
size: 2,
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('should get single note', async () => {
|
|
68
|
-
mockResponse('/notes/1', { title: '1' })
|
|
69
|
-
|
|
70
|
-
const data = await client.note.getNoteById('1')
|
|
71
|
-
|
|
72
|
-
expect(data).toStrictEqual({ title: '1' })
|
|
73
|
-
expect(data.$raw).toBeDefined()
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('should get note by nid', async () => {
|
|
77
|
-
mockResponse('/notes/nid/1', { data: { title: '1' } })
|
|
78
|
-
|
|
79
|
-
const data = await client.note.getNoteById(1)
|
|
80
|
-
expect(data.data.title).toBe('1')
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
it('should get note by nid query single result', async () => {
|
|
84
|
-
mockResponse('/notes/nid/1', { title: '1' })
|
|
85
|
-
|
|
86
|
-
const data = await client.note.getNoteById(1, undefined, true)
|
|
87
|
-
expect(data.title).toBe('1')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('should like note', async () => {
|
|
91
|
-
mockResponse('/notes/like/1', null)
|
|
92
|
-
|
|
93
|
-
const data = await client.note.likeIt('1')
|
|
94
|
-
|
|
95
|
-
expect(data).toBeNull()
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('should forbidden if no password provide', async () => {
|
|
99
|
-
spyOn(axiosAdaptor, 'get').mockRejectedValue({
|
|
100
|
-
response: {
|
|
101
|
-
data: {
|
|
102
|
-
message: 'password required',
|
|
103
|
-
},
|
|
104
|
-
status: 403,
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
await expect(client.note.getNoteById('1')).rejects.toThrowError(
|
|
109
|
-
RequestError,
|
|
110
|
-
)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test('GET /notes/topics/:id', async () => {
|
|
114
|
-
mockResponse('/notes/topics/11111111', { data: [], pagination: {} })
|
|
115
|
-
|
|
116
|
-
const data = await client.note.getNoteByTopicId('11111111')
|
|
117
|
-
|
|
118
|
-
expect(data).toEqual({ data: [], pagination: {} })
|
|
119
|
-
})
|
|
120
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
2
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
3
|
-
import { PageController } from '~/controllers/page'
|
|
4
|
-
|
|
5
|
-
describe('test page client', () => {
|
|
6
|
-
const client = mockRequestInstance(PageController)
|
|
7
|
-
|
|
8
|
-
it('should get page list', async () => {
|
|
9
|
-
mockResponse('/pages?size=10&page=1', {
|
|
10
|
-
data: [],
|
|
11
|
-
pagination: {},
|
|
12
|
-
})
|
|
13
|
-
const data = await client.page.getList()
|
|
14
|
-
expect(data).toEqual({ data: [], pagination: {} })
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('should get post list filter filed', async () => {
|
|
18
|
-
const mocked = mockResponse('/pages?page=1&size=1&select=created+title', {
|
|
19
|
-
data: [{}],
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const data = await client.page.getList(1, 1, {
|
|
23
|
-
select: ['created', 'title'],
|
|
24
|
-
})
|
|
25
|
-
expect(data).toEqual(mocked)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('should get single page', async () => {
|
|
29
|
-
mockResponse('/pages/1', {
|
|
30
|
-
title: '1',
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const data = await client.page.getById('1')
|
|
34
|
-
|
|
35
|
-
expect(data).toStrictEqual({ title: '1' })
|
|
36
|
-
expect(data.$raw).toBeDefined()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should get by slug', async () => {
|
|
40
|
-
mockResponse('/pages/slug/about', {
|
|
41
|
-
title: 'about',
|
|
42
|
-
text: 'about!',
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const data = await client.page.getBySlug('about')
|
|
46
|
-
expect(data.title).toBe('about')
|
|
47
|
-
expect(data.text).toBe('about!')
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
2
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
3
|
-
import { PostController } from '~/controllers'
|
|
4
|
-
|
|
5
|
-
describe('test post client', () => {
|
|
6
|
-
const client = mockRequestInstance(PostController)
|
|
7
|
-
|
|
8
|
-
it('should get post list', async () => {
|
|
9
|
-
mockResponse('/posts', { data: [] })
|
|
10
|
-
|
|
11
|
-
const data = await client.post.getList()
|
|
12
|
-
expect(data).toEqual({ data: [] })
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('should get post list filter filed', async () => {
|
|
16
|
-
const mocked = mockResponse('/posts?page=1&size=1&select=created+title', {
|
|
17
|
-
data: [
|
|
18
|
-
{
|
|
19
|
-
id: '61586f7e769f07b6852f3da0',
|
|
20
|
-
title: '终于可以使用 Docker 托管整个 Mix Space 了',
|
|
21
|
-
created: '2021-10-02T14:41:02.742Z',
|
|
22
|
-
category: null,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: '614c539cfdf566c5d93a383f',
|
|
26
|
-
title: '再遇 Docker,容器化 Node 应用',
|
|
27
|
-
created: '2021-09-23T10:14:52.491Z',
|
|
28
|
-
category: null,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const data = await client.post.getList(1, 1, {
|
|
34
|
-
select: ['created', 'title'],
|
|
35
|
-
})
|
|
36
|
-
expect(data).toEqual(mocked)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should get latest post', async () => {
|
|
40
|
-
mockResponse('/posts/latest', { title: '1' })
|
|
41
|
-
const data = await client.post.getLatest()
|
|
42
|
-
expect(data.title).toBe('1')
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should get single post by id', async () => {
|
|
46
|
-
mockResponse('/posts/613c91d0326cfffc61923ea2', {
|
|
47
|
-
title: '1',
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const data = await client.post.getPost('613c91d0326cfffc61923ea2')
|
|
51
|
-
|
|
52
|
-
expect(data).toStrictEqual({ title: '1' })
|
|
53
|
-
expect(data.$raw).toBeDefined()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('should get single post by slug and category', async () => {
|
|
57
|
-
mockResponse('/posts/website/host-an-entire-Mix-Space-using-Docker', {
|
|
58
|
-
title: '1',
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const data = await client.post.getPost(
|
|
62
|
-
'website',
|
|
63
|
-
'host-an-entire-Mix-Space-using-Docker',
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
expect(data).toStrictEqual({ title: '1' })
|
|
67
|
-
expect(data.$raw).toBeDefined()
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should thumbs-up post', async () => {
|
|
71
|
-
mockResponse('/posts/_thumbs-up?id=1', null)
|
|
72
|
-
|
|
73
|
-
const data = await client.post.thumbsUp('1')
|
|
74
|
-
|
|
75
|
-
expect(data).toBeNull()
|
|
76
|
-
})
|
|
77
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
2
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
3
|
-
import { RecentlyController } from '~/controllers'
|
|
4
|
-
|
|
5
|
-
describe('test recently client, /recently', () => {
|
|
6
|
-
const client = mockRequestInstance(RecentlyController)
|
|
7
|
-
|
|
8
|
-
test('GET /', async () => {
|
|
9
|
-
const mocked = mockResponse('/recently?before=616182162657089e483aac5c', {
|
|
10
|
-
data: [
|
|
11
|
-
{
|
|
12
|
-
id: '615c58cbf41656a119b1a4a9',
|
|
13
|
-
content: 'x',
|
|
14
|
-
created: '2021-10-05T13:53:15.891Z',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
})
|
|
18
|
-
const data = await client.recently.getList('616182162657089e483aac5c')
|
|
19
|
-
expect(data).toEqual(mocked)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('GET /latest', async () => {
|
|
23
|
-
const mocked = mockResponse('/recently/latest', {
|
|
24
|
-
id: '615c58cbf41656a119b1a4a9',
|
|
25
|
-
content: 'xxx',
|
|
26
|
-
created: '2021-10-05T13:53:15.891Z',
|
|
27
|
-
})
|
|
28
|
-
const data = await client.recently.getLatestOne()
|
|
29
|
-
expect(data).toEqual(mocked)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('GET /all', async () => {
|
|
33
|
-
const mocked = mockResponse('/recently/all', {
|
|
34
|
-
data: [
|
|
35
|
-
{
|
|
36
|
-
id: '615c58cbf41656a119b1a4a9',
|
|
37
|
-
content: 'x',
|
|
38
|
-
created: '2021-10-05T13:53:15.891Z',
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
})
|
|
42
|
-
const data = await client.recently.getAll()
|
|
43
|
-
expect(data).toEqual(mocked)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should `recently` == `shorthand`', () => {
|
|
47
|
-
expect(client.recently).toEqual(client.shorthand)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import camelcaseKeys from 'camelcase-keys'
|
|
2
|
-
|
|
3
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
4
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
5
|
-
import { SayController } from '~/controllers/say'
|
|
6
|
-
|
|
7
|
-
describe('test say client', () => {
|
|
8
|
-
const client = mockRequestInstance(SayController)
|
|
9
|
-
|
|
10
|
-
test('GET /says/all', async () => {
|
|
11
|
-
const mocked = mockResponse('/says/all', {
|
|
12
|
-
data: [
|
|
13
|
-
{
|
|
14
|
-
id: '5eb52a73505ad56acfd25c94',
|
|
15
|
-
source: '网络',
|
|
16
|
-
text: '找不到路,就自己走一条出来。',
|
|
17
|
-
author: '魅影陌客',
|
|
18
|
-
created: '2020-05-08T09:46:27.694Z',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: '5eb52a94505ad56acfd25c95',
|
|
22
|
-
source: '网络',
|
|
23
|
-
text: '生活中若没有朋友,就像生活中没有阳光一样。',
|
|
24
|
-
author: '能美',
|
|
25
|
-
created: '2020-05-08T09:47:00.436Z',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
})
|
|
29
|
-
const data = await client.say.getAll()
|
|
30
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
31
|
-
expect(data.data).toEqual(mocked.data)
|
|
32
|
-
expect(data.data[0].text).toEqual('找不到路,就自己走一条出来。')
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('GET /says', () => {
|
|
36
|
-
it('should get without page and size', async () => {
|
|
37
|
-
const mocked = mockResponse('/says', {
|
|
38
|
-
data: [
|
|
39
|
-
{
|
|
40
|
-
id: '61397d9892992823d7329bc9',
|
|
41
|
-
text: '每位师傅各有所长,我都会一点点。',
|
|
42
|
-
author: '陆沉',
|
|
43
|
-
source: '',
|
|
44
|
-
created: '2021-09-09T03:20:56.769Z',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: '60853492fbfab397775cc12d',
|
|
48
|
-
text: '我不是一个优秀的人,只是我们观测的角度不同。',
|
|
49
|
-
created: '2021-04-25T09:21:22.115Z',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
pagination: {
|
|
53
|
-
total: 26,
|
|
54
|
-
current_page: 1,
|
|
55
|
-
total_page: 3,
|
|
56
|
-
size: 10,
|
|
57
|
-
has_next_page: true,
|
|
58
|
-
has_prev_page: false,
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const data = await client.say.getAllPaginated()
|
|
63
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
64
|
-
expect(data.data).toEqual(camelcaseKeys(mocked.data, { deep: true }))
|
|
65
|
-
expect(data.data[0].text).toEqual('每位师傅各有所长,我都会一点点。')
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('should with page and size', async () => {
|
|
69
|
-
const mocked = await mockResponse('/says?size=1&page=1', {
|
|
70
|
-
data: [
|
|
71
|
-
{
|
|
72
|
-
id: '61397d9892992823d7329bc9',
|
|
73
|
-
text: '每位师傅各有所长,我都会一点点。',
|
|
74
|
-
author: '陆沉',
|
|
75
|
-
source: '',
|
|
76
|
-
created: '2021-09-09T03:20:56.769Z',
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
pagination: {
|
|
80
|
-
total: 26,
|
|
81
|
-
current_page: 1,
|
|
82
|
-
total_page: 26,
|
|
83
|
-
size: 1,
|
|
84
|
-
has_next_page: true,
|
|
85
|
-
has_prev_page: false,
|
|
86
|
-
},
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const data = await client.say.getAllPaginated(1, 1)
|
|
90
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
test('GET /says/:id', async () => {
|
|
95
|
-
const mocked = mockResponse('/says/61397d9892992823d7329bc9', {
|
|
96
|
-
id: '61397d9892992823d7329bc9',
|
|
97
|
-
text: '每位师傅各有所长,我都会一点点。',
|
|
98
|
-
author: '陆沉',
|
|
99
|
-
source: '',
|
|
100
|
-
created: '2021-09-09T03:20:56.769Z',
|
|
101
|
-
})
|
|
102
|
-
const data = await client.say.getById('61397d9892992823d7329bc9')
|
|
103
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
104
|
-
expect(data.id).toEqual('61397d9892992823d7329bc9')
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import camelcaseKeys from 'camelcase-keys'
|
|
2
|
-
|
|
3
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
4
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
5
|
-
import { SearchController } from '~/controllers'
|
|
6
|
-
|
|
7
|
-
import mockData from '../mock/algolia.json'
|
|
8
|
-
|
|
9
|
-
describe('test search client, /search', () => {
|
|
10
|
-
const client = mockRequestInstance(SearchController)
|
|
11
|
-
|
|
12
|
-
test('GET /search/post', async () => {
|
|
13
|
-
const mocked = mockResponse('/search/post?keyword=1', {
|
|
14
|
-
data: [
|
|
15
|
-
{
|
|
16
|
-
modified: '2020-11-14T16:15:36.162Z',
|
|
17
|
-
id: '5eb2c62a613a5ab0642f1f80',
|
|
18
|
-
title: '打印沙漏(C#实现)',
|
|
19
|
-
slug: 'acm-test',
|
|
20
|
-
created: '2019-01-31T13:02:00.000Z',
|
|
21
|
-
category: {
|
|
22
|
-
type: 0,
|
|
23
|
-
id: '5eb2c62a613a5ab0642f1f7a',
|
|
24
|
-
count: 56,
|
|
25
|
-
name: '编程',
|
|
26
|
-
slug: 'programming',
|
|
27
|
-
created: '2020-05-06T14:14:02.339Z',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
pagination: {
|
|
32
|
-
total: 86,
|
|
33
|
-
current_page: 1,
|
|
34
|
-
total_page: 9,
|
|
35
|
-
size: 10,
|
|
36
|
-
has_next_page: true,
|
|
37
|
-
has_prev_page: false,
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const data = await client.search.search('post', '1')
|
|
42
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
43
|
-
expect(data.data[0].id).toEqual('5eb2c62a613a5ab0642f1f80')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test('GET /search/note', async () => {
|
|
47
|
-
const mocked = mockResponse('/search/note?keyword=1', {
|
|
48
|
-
data: [
|
|
49
|
-
{
|
|
50
|
-
modified: '2020-11-15T09:43:33.199Z',
|
|
51
|
-
id: '5eb35d6f5ae43bbd0c90b8c0',
|
|
52
|
-
title: '回顾快要逝去的寒假',
|
|
53
|
-
created: '2019-02-19T11:59:00.000Z',
|
|
54
|
-
nid: 11,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
pagination: {
|
|
58
|
-
total: 86,
|
|
59
|
-
current_page: 1,
|
|
60
|
-
total_page: 9,
|
|
61
|
-
size: 10,
|
|
62
|
-
has_next_page: true,
|
|
63
|
-
has_prev_page: false,
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
const data = await client.search.search('note', '1')
|
|
68
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
69
|
-
expect(data.data[0].id).toEqual('5eb35d6f5ae43bbd0c90b8c0')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('GET /search/algolia', async () => {
|
|
73
|
-
mockResponse('/search/algolia', mockData)
|
|
74
|
-
const data = await client.search.searchByAlgolia('algolia')
|
|
75
|
-
|
|
76
|
-
expect(data.data[0].id).toEqual('5fe97d1d5b11408f99ada0fd')
|
|
77
|
-
expect(data.raw).toBeDefined()
|
|
78
|
-
|
|
79
|
-
expect(data.$raw.data).toEqual(mockData)
|
|
80
|
-
})
|
|
81
|
-
})
|