tests working
This commit is contained in:
parent
b17f3c188a
commit
28afb883bd
|
@ -20,6 +20,7 @@
|
||||||
"@biomejs/biome": "1.5.3",
|
"@biomejs/biome": "1.5.3",
|
||||||
"@changesets/cli": "^2.27.1",
|
"@changesets/cli": "^2.27.1",
|
||||||
"vitest": "^1.2.2",
|
"vitest": "^1.2.2",
|
||||||
"vitest-fetch-mock": "^0.2.2"
|
"vitest-fetch-mock": "^0.2.2",
|
||||||
|
"@vitest/ui": "1.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import createFetchMock from "vitest-fetch-mock";
|
import createFetchMock from "vitest-fetch-mock";
|
||||||
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
import { TSGhostContentAPI } from "../../content-api";
|
import TS_API from "../../content-api";
|
||||||
|
|
||||||
const fetchMocker = createFetchMock(vi);
|
const fetchMocker = createFetchMock(vi);
|
||||||
|
|
||||||
describe("authors api .browse() Args Type-safety", () => {
|
describe("authors api .browse() Args Type-safety", () => {
|
||||||
const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com";
|
const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com";
|
||||||
const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba";
|
const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba";
|
||||||
const api = new TSGhostContentAPI(url, key, "v5.0");
|
const api = new TS_API(url, key, "v5.0");
|
||||||
test(".browse() params shouldnt accept invalid params", () => {
|
test(".browse() params shouldnt accept invalid params", () => {
|
||||||
// @ts-expect-error - shouldnt accept invalid params
|
// @ts-expect-error - shouldnt accept invalid params
|
||||||
const browse = api.authors.browse({ pp: 2 });
|
const browse = api.authors.browse({ pp: 2 });
|
||||||
|
@ -81,10 +81,10 @@ describe("authors api .browse() Args Type-safety", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("authors resource mocked", () => {
|
describe("authors resource mocked", () => {
|
||||||
let api: TSGhostContentAPI;
|
let api: TS_API;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
api = new TSGhostContentAPI("https://my-ghost-blog.com", "59d4bf56c73c04a18c867dc3ba", "v5.0");
|
api = new TS_API("https://my-ghost-blog.com", "59d4bf56c73c04a18c867dc3ba", "v5.0");
|
||||||
fetchMocker.enableMocks();
|
fetchMocker.enableMocks();
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { TSGhostContentAPI } from "../../content-api";
|
import TS_API from "../../content-api";
|
||||||
import type { Post } from "./posts";
|
import type { Post } from "./posts";
|
||||||
|
|
||||||
const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com";
|
const url = process.env.VITE_GHOST_URL || "https://my-ghost-blog.com";
|
||||||
const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba";
|
const key = process.env.VITE_GHOST_CONTENT_API_KEY || "59d4bf56c73c04a18c867dc3ba";
|
||||||
|
|
||||||
describe("posts api .browse() Args Type-safety", () => {
|
describe("posts api .browse() Args Type-safety", () => {
|
||||||
const api = new TSGhostContentAPI(url, key, "v5.0");
|
const api = new TS_API(url, key, "v5.0");
|
||||||
test(".browse() params shouldnt accept invalid params", () => {
|
test(".browse() params shouldnt accept invalid params", () => {
|
||||||
// @ts-expect-error - shouldnt accept invalid params
|
// @ts-expect-error - shouldnt accept invalid params
|
||||||
const browse = api.posts.browse({ pp: 2 });
|
const browse = api.posts.browse({ pp: 2 });
|
||||||
|
|
146
pnpm-lock.yaml
146
pnpm-lock.yaml
|
@ -14,9 +14,12 @@ importers:
|
||||||
'@changesets/cli':
|
'@changesets/cli':
|
||||||
specifier: ^2.27.1
|
specifier: ^2.27.1
|
||||||
version: 2.27.1
|
version: 2.27.1
|
||||||
|
'@vitest/ui':
|
||||||
|
specifier: 1.2.2
|
||||||
|
version: 1.2.2(vitest@1.2.2)
|
||||||
vitest:
|
vitest:
|
||||||
specifier: ^1.2.2
|
specifier: ^1.2.2
|
||||||
version: 1.2.2
|
version: 1.2.2(@vitest/ui@1.2.2)
|
||||||
vitest-fetch-mock:
|
vitest-fetch-mock:
|
||||||
specifier: ^0.2.2
|
specifier: ^0.2.2
|
||||||
version: 0.2.2(vitest@1.2.2)
|
version: 0.2.2(vitest@1.2.2)
|
||||||
|
@ -107,7 +110,7 @@ importers:
|
||||||
version: 5.3.3
|
version: 5.3.3
|
||||||
vitest:
|
vitest:
|
||||||
specifier: ^1.2.2
|
specifier: ^1.2.2
|
||||||
version: 1.2.2(@types/node@20.11.18)
|
version: 1.2.2(@types/node@20.11.18)(@vitest/ui@1.2.2)
|
||||||
vitest-fetch-mock:
|
vitest-fetch-mock:
|
||||||
specifier: ^0.2.2
|
specifier: ^0.2.2
|
||||||
version: 0.2.2(vitest@1.2.2)
|
version: 0.2.2(vitest@1.2.2)
|
||||||
|
@ -297,7 +300,7 @@ importers:
|
||||||
version: 4.3.1(typescript@5.3.3)(vite@5.1.2)
|
version: 4.3.1(typescript@5.3.3)(vite@5.1.2)
|
||||||
vitest:
|
vitest:
|
||||||
specifier: ^1.2.2
|
specifier: ^1.2.2
|
||||||
version: 1.2.2(@types/node@20.11.18)
|
version: 1.2.2(@types/node@20.11.18)(@vitest/ui@1.2.2)
|
||||||
|
|
||||||
packages/tsconfig: {}
|
packages/tsconfig: {}
|
||||||
|
|
||||||
|
@ -2270,6 +2273,21 @@ packages:
|
||||||
tinyspy: 2.2.1
|
tinyspy: 2.2.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@vitest/ui@1.2.2(vitest@1.2.2):
|
||||||
|
resolution: {integrity: sha512-CG+5fa8lyoBr+9i+UZGS31Qw81v33QlD10uecHxN2CLJVN+jLnqx4pGzGvFFeJ7jSnUCT0AlbmVWY6fU6NJZmw==}
|
||||||
|
peerDependencies:
|
||||||
|
vitest: ^1.0.0
|
||||||
|
dependencies:
|
||||||
|
'@vitest/utils': 1.2.2
|
||||||
|
fast-glob: 3.3.2
|
||||||
|
fflate: 0.8.2
|
||||||
|
flatted: 3.2.9
|
||||||
|
pathe: 1.1.2
|
||||||
|
picocolors: 1.0.0
|
||||||
|
sirv: 2.0.4
|
||||||
|
vitest: 1.2.2(@vitest/ui@1.2.2)
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@vitest/utils@1.2.2:
|
/@vitest/utils@1.2.2:
|
||||||
resolution: {integrity: sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==}
|
resolution: {integrity: sha512-WKITBHLsBHlpjnDQahr+XK6RE7MiAsgrIkr0pGhQ9ygoxBfUeG0lUG5iLlzqjmKSlBv3+j5EGsriBzh+C3Tq9g==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4011,6 +4029,10 @@ packages:
|
||||||
resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==}
|
resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/fflate@0.8.2:
|
||||||
|
resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/file-entry-cache@6.0.1:
|
/file-entry-cache@6.0.1:
|
||||||
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
|
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
|
||||||
engines: {node: ^10.12.0 || >=12.0.0}
|
engines: {node: ^10.12.0 || >=12.0.0}
|
||||||
|
@ -7545,68 +7567,12 @@ packages:
|
||||||
vitest: '>=0.16.0'
|
vitest: '>=0.16.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-fetch: 3.1.8
|
cross-fetch: 3.1.8
|
||||||
vitest: 1.2.2
|
vitest: 1.2.2(@vitest/ui@1.2.2)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- encoding
|
- encoding
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vitest@1.2.2:
|
/vitest@1.2.2(@types/node@20.11.18)(@vitest/ui@1.2.2):
|
||||||
resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==}
|
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
'@edge-runtime/vm': '*'
|
|
||||||
'@types/node': ^18.0.0 || >=20.0.0
|
|
||||||
'@vitest/browser': ^1.0.0
|
|
||||||
'@vitest/ui': ^1.0.0
|
|
||||||
happy-dom: '*'
|
|
||||||
jsdom: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
'@edge-runtime/vm':
|
|
||||||
optional: true
|
|
||||||
'@types/node':
|
|
||||||
optional: true
|
|
||||||
'@vitest/browser':
|
|
||||||
optional: true
|
|
||||||
'@vitest/ui':
|
|
||||||
optional: true
|
|
||||||
happy-dom:
|
|
||||||
optional: true
|
|
||||||
jsdom:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
'@vitest/expect': 1.2.2
|
|
||||||
'@vitest/runner': 1.2.2
|
|
||||||
'@vitest/snapshot': 1.2.2
|
|
||||||
'@vitest/spy': 1.2.2
|
|
||||||
'@vitest/utils': 1.2.2
|
|
||||||
acorn-walk: 8.3.2
|
|
||||||
cac: 6.7.14
|
|
||||||
chai: 4.4.1
|
|
||||||
debug: 4.3.4
|
|
||||||
execa: 8.0.1
|
|
||||||
local-pkg: 0.5.0
|
|
||||||
magic-string: 0.30.7
|
|
||||||
pathe: 1.1.2
|
|
||||||
picocolors: 1.0.0
|
|
||||||
std-env: 3.7.0
|
|
||||||
strip-literal: 1.3.0
|
|
||||||
tinybench: 2.6.0
|
|
||||||
tinypool: 0.8.2
|
|
||||||
vite: 5.1.2(sass@1.70.0)
|
|
||||||
vite-node: 1.2.2
|
|
||||||
why-is-node-running: 2.2.2
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- less
|
|
||||||
- lightningcss
|
|
||||||
- sass
|
|
||||||
- stylus
|
|
||||||
- sugarss
|
|
||||||
- supports-color
|
|
||||||
- terser
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/vitest@1.2.2(@types/node@20.11.18):
|
|
||||||
resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==}
|
resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -7636,6 +7602,7 @@ packages:
|
||||||
'@vitest/runner': 1.2.2
|
'@vitest/runner': 1.2.2
|
||||||
'@vitest/snapshot': 1.2.2
|
'@vitest/snapshot': 1.2.2
|
||||||
'@vitest/spy': 1.2.2
|
'@vitest/spy': 1.2.2
|
||||||
|
'@vitest/ui': 1.2.2(vitest@1.2.2)
|
||||||
'@vitest/utils': 1.2.2
|
'@vitest/utils': 1.2.2
|
||||||
acorn-walk: 8.3.2
|
acorn-walk: 8.3.2
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
|
@ -7663,6 +7630,63 @@ packages:
|
||||||
- terser
|
- terser
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vitest@1.2.2(@vitest/ui@1.2.2):
|
||||||
|
resolution: {integrity: sha512-d5Ouvrnms3GD9USIK36KG8OZ5bEvKEkITFtnGv56HFaSlbItJuYr7hv2Lkn903+AvRAgSixiamozUVfORUekjw==}
|
||||||
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@edge-runtime/vm': '*'
|
||||||
|
'@types/node': ^18.0.0 || >=20.0.0
|
||||||
|
'@vitest/browser': ^1.0.0
|
||||||
|
'@vitest/ui': ^1.0.0
|
||||||
|
happy-dom: '*'
|
||||||
|
jsdom: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@edge-runtime/vm':
|
||||||
|
optional: true
|
||||||
|
'@types/node':
|
||||||
|
optional: true
|
||||||
|
'@vitest/browser':
|
||||||
|
optional: true
|
||||||
|
'@vitest/ui':
|
||||||
|
optional: true
|
||||||
|
happy-dom:
|
||||||
|
optional: true
|
||||||
|
jsdom:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@vitest/expect': 1.2.2
|
||||||
|
'@vitest/runner': 1.2.2
|
||||||
|
'@vitest/snapshot': 1.2.2
|
||||||
|
'@vitest/spy': 1.2.2
|
||||||
|
'@vitest/ui': 1.2.2(vitest@1.2.2)
|
||||||
|
'@vitest/utils': 1.2.2
|
||||||
|
acorn-walk: 8.3.2
|
||||||
|
cac: 6.7.14
|
||||||
|
chai: 4.4.1
|
||||||
|
debug: 4.3.4
|
||||||
|
execa: 8.0.1
|
||||||
|
local-pkg: 0.5.0
|
||||||
|
magic-string: 0.30.7
|
||||||
|
pathe: 1.1.2
|
||||||
|
picocolors: 1.0.0
|
||||||
|
std-env: 3.7.0
|
||||||
|
strip-literal: 1.3.0
|
||||||
|
tinybench: 2.6.0
|
||||||
|
tinypool: 0.8.2
|
||||||
|
vite: 5.1.2(sass@1.70.0)
|
||||||
|
vite-node: 1.2.2
|
||||||
|
why-is-node-running: 2.2.2
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- less
|
||||||
|
- lightningcss
|
||||||
|
- sass
|
||||||
|
- stylus
|
||||||
|
- sugarss
|
||||||
|
- supports-color
|
||||||
|
- terser
|
||||||
|
dev: true
|
||||||
|
|
||||||
/volar-service-css@0.0.29(@volar/language-service@2.0.4):
|
/volar-service-css@0.0.29(@volar/language-service@2.0.4):
|
||||||
resolution: {integrity: sha512-2kNdgEYEiLeeer3wkagNBVDPa3Zj7mBDeM7D3iYmBXA0LCwd2tQL3eASzcDW9Gvac1g478UtptK468GxzUAEcA==}
|
resolution: {integrity: sha512-2kNdgEYEiLeeer3wkagNBVDPa3Zj7mBDeM7D3iYmBXA0LCwd2tQL3eASzcDW9Gvac1g478UtptK468GxzUAEcA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[
|
||||||
|
"packages/*"
|
||||||
|
]
|
|
@ -1,3 +0,0 @@
|
||||||
export default [
|
|
||||||
'packages/*/vitest.config.ts'
|
|
||||||
]
|
|
Loading…
Reference in New Issue