@mx-space/api-client 1.0.0 → 1.0.2
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/.eslintcache +1 -1
- package/LICENSE +661 -0
- package/controllers/recently.ts +24 -3
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +18 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- 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 +110 -0
- package/esm/controllers/recently.js +49 -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 +110 -0
- package/lib/controllers/recently.js +53 -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 +26 -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 +110 -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,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
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
2
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
3
|
-
import { ServerlessController } from '~/controllers'
|
|
4
|
-
|
|
5
|
-
describe('test Snippet client', () => {
|
|
6
|
-
const client = mockRequestInstance(ServerlessController)
|
|
7
|
-
|
|
8
|
-
test('GET /:reference/:name', async () => {
|
|
9
|
-
const mocked = mockResponse('/serverless/api/ping', { message: 'pong' })
|
|
10
|
-
|
|
11
|
-
const data = await client.serverless.getByReferenceAndName<{}>(
|
|
12
|
-
'api',
|
|
13
|
-
'ping',
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
expect(data).toEqual(mocked)
|
|
17
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { mockRequestInstance } from '~/__tests__/helpers/instance'
|
|
2
|
-
import { mockResponse } from '~/__tests__/helpers/response'
|
|
3
|
-
import { SnippetController } from '~/controllers'
|
|
4
|
-
|
|
5
|
-
describe('test Snippet client', () => {
|
|
6
|
-
const client = mockRequestInstance(SnippetController)
|
|
7
|
-
|
|
8
|
-
// test('GET /:id', async () => {
|
|
9
|
-
// const mocked = mockResponse('/snippets/61a0cac4b4aefa000fcc1822', {
|
|
10
|
-
// id: '61a0cac4b4aefa000fcc1822',
|
|
11
|
-
// type: 'json',
|
|
12
|
-
// private: true,
|
|
13
|
-
// reference: 'theme',
|
|
14
|
-
// raw: '{}',
|
|
15
|
-
// name: 'config',
|
|
16
|
-
// created: '2021-11-26T11:53:40.863Z',
|
|
17
|
-
// updated: '2021-11-26T11:53:40.863Z',
|
|
18
|
-
// })
|
|
19
|
-
|
|
20
|
-
// const data = await client.snippet.getById('61a0cac4b4aefa000fcc1822')
|
|
21
|
-
|
|
22
|
-
// expect(data).toEqual(mocked)
|
|
23
|
-
// expect(data.$raw.data).toEqual(mocked)
|
|
24
|
-
// expect(data.raw).toEqual('{}')
|
|
25
|
-
// })
|
|
26
|
-
|
|
27
|
-
test('GET /:reference/:name', async () => {
|
|
28
|
-
const mocked = mockResponse('/snippets/theme/config', {})
|
|
29
|
-
|
|
30
|
-
const data = await client.snippet.getByReferenceAndName<{}>(
|
|
31
|
-
'theme',
|
|
32
|
-
'config',
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
expect(data).toEqual(mocked)
|
|
36
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
@@ -1,17 +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 { TopicController } from '~/controllers/topic'
|
|
6
|
-
|
|
7
|
-
describe('test topic client', () => {
|
|
8
|
-
const client = mockRequestInstance(TopicController)
|
|
9
|
-
|
|
10
|
-
test('GET /topics/slug/:slug', async () => {
|
|
11
|
-
const mocked = mockResponse('/topics/slug/111', {
|
|
12
|
-
name: 'name-topic',
|
|
13
|
-
})
|
|
14
|
-
const data = await client.topic.getTopicBySlug('111')
|
|
15
|
-
expect(data).toEqual(camelcaseKeys(mocked))
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,59 +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 { UserController } from '~/controllers'
|
|
6
|
-
|
|
7
|
-
describe('test user client', () => {
|
|
8
|
-
const client = mockRequestInstance(UserController)
|
|
9
|
-
|
|
10
|
-
test('GET /master', async () => {
|
|
11
|
-
const mocked = mockResponse('/master', {
|
|
12
|
-
id: '5ea4fe632507ba128f4c938c',
|
|
13
|
-
introduce: '这是我的小世界呀',
|
|
14
|
-
mail: 'i@innei.ren',
|
|
15
|
-
url: 'https://innei.ren',
|
|
16
|
-
name: 'Innei',
|
|
17
|
-
social_ids: {
|
|
18
|
-
bili_id: 26578164,
|
|
19
|
-
netease_id: 84302804,
|
|
20
|
-
github: 'Innei',
|
|
21
|
-
},
|
|
22
|
-
username: 'Innei',
|
|
23
|
-
created: '2020-04-26T03:22:11.784Z',
|
|
24
|
-
modified: '2020-11-13T09:38:49.014Z',
|
|
25
|
-
last_login_time: '2021-11-17T13:42:48.209Z',
|
|
26
|
-
avatar: 'https://cdn.innei.ren/avatar.png',
|
|
27
|
-
})
|
|
28
|
-
const data = await client.user.getMasterInfo()
|
|
29
|
-
expect(data.id).toEqual(mocked.id)
|
|
30
|
-
expect(data).toEqual(camelcaseKeys(mocked, { deep: true }))
|
|
31
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('POST /login', async () => {
|
|
35
|
-
const mocked = mockResponse(
|
|
36
|
-
'/master/login',
|
|
37
|
-
{
|
|
38
|
-
id: '5ea4fe632507ba128f4c938c',
|
|
39
|
-
},
|
|
40
|
-
'post',
|
|
41
|
-
)
|
|
42
|
-
const data = await client.user.login('test', 'test')
|
|
43
|
-
expect(data.id).toEqual(mocked.id)
|
|
44
|
-
expect(data.$raw.data).toEqual(mocked)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('GET /check_logged', async () => {
|
|
48
|
-
const mocked = mockResponse('/check_logged?token=bearer token', {
|
|
49
|
-
isGuest: true,
|
|
50
|
-
})
|
|
51
|
-
const data = await client.user.checkTokenValid('token')
|
|
52
|
-
expect(data).toEqual(mocked)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should call `master.xx` work', () => {
|
|
56
|
-
expect(client.master.getMasterInfo).toBeInstanceOf(Function)
|
|
57
|
-
expect(client.master).toEqual(client.user)
|
|
58
|
-
})
|
|
59
|
-
})
|