@shopware-ag/app-server-sdk 1.1.0 → 1.1.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/dist/commonjs/integration/better-sqlite3.d.ts +11 -0
- package/dist/commonjs/integration/better-sqlite3.d.ts.map +1 -0
- package/dist/commonjs/integration/better-sqlite3.js +58 -0
- package/dist/commonjs/integration/better-sqlite3.js.map +1 -0
- package/dist/esm/integration/better-sqlite3.d.ts +11 -0
- package/dist/esm/integration/better-sqlite3.d.ts.map +1 -0
- package/dist/esm/integration/better-sqlite3.js +51 -0
- package/dist/esm/integration/better-sqlite3.js.map +1 -0
- package/package.json +173 -141
- package/dist/commonjs/context-resolver.test.d.ts +0 -2
- package/dist/commonjs/context-resolver.test.d.ts.map +0 -1
- package/dist/commonjs/context-resolver.test.js +0 -81
- package/dist/commonjs/context-resolver.test.js.map +0 -1
- package/dist/commonjs/helper/app-actions.test.d.ts +0 -2
- package/dist/commonjs/helper/app-actions.test.d.ts.map +0 -1
- package/dist/commonjs/helper/app-actions.test.js +0 -31
- package/dist/commonjs/helper/app-actions.test.js.map +0 -1
- package/dist/commonjs/http-client.test.d.ts +0 -2
- package/dist/commonjs/http-client.test.d.ts.map +0 -1
- package/dist/commonjs/http-client.test.js +0 -71
- package/dist/commonjs/http-client.test.js.map +0 -1
- package/dist/commonjs/integration/bun-sqlite.test.d.ts +0 -2
- package/dist/commonjs/integration/bun-sqlite.test.d.ts.map +0 -1
- package/dist/commonjs/integration/bun-sqlite.test.js +0 -24
- package/dist/commonjs/integration/bun-sqlite.test.js.map +0 -1
- package/dist/commonjs/integration/cloudflare.test.d.ts +0 -2
- package/dist/commonjs/integration/cloudflare.test.d.ts.map +0 -1
- package/dist/commonjs/integration/cloudflare.test.js +0 -39
- package/dist/commonjs/integration/cloudflare.test.js.map +0 -1
- package/dist/commonjs/integration/deno.test.d.ts +0 -2
- package/dist/commonjs/integration/deno.test.d.ts.map +0 -1
- package/dist/commonjs/integration/deno.test.js +0 -48
- package/dist/commonjs/integration/deno.test.js.map +0 -1
- package/dist/commonjs/integration/dynamodb.test.d.ts +0 -2
- package/dist/commonjs/integration/dynamodb.test.d.ts.map +0 -1
- package/dist/commonjs/integration/dynamodb.test.js +0 -132
- package/dist/commonjs/integration/dynamodb.test.js.map +0 -1
- package/dist/commonjs/integration/hono.test.d.ts +0 -2
- package/dist/commonjs/integration/hono.test.d.ts.map +0 -1
- package/dist/commonjs/integration/hono.test.js +0 -86
- package/dist/commonjs/integration/hono.test.js.map +0 -1
- package/dist/commonjs/registration.test.d.ts +0 -2
- package/dist/commonjs/registration.test.d.ts.map +0 -1
- package/dist/commonjs/registration.test.js +0 -59
- package/dist/commonjs/registration.test.js.map +0 -1
- package/dist/commonjs/repository.test.d.ts +0 -2
- package/dist/commonjs/repository.test.d.ts.map +0 -1
- package/dist/commonjs/repository.test.js +0 -32
- package/dist/commonjs/repository.test.js.map +0 -1
- package/dist/commonjs/signer.test.d.ts +0 -2
- package/dist/commonjs/signer.test.d.ts.map +0 -1
- package/dist/commonjs/signer.test.js +0 -25
- package/dist/commonjs/signer.test.js.map +0 -1
- package/dist/esm/context-resolver.test.d.ts +0 -2
- package/dist/esm/context-resolver.test.d.ts.map +0 -1
- package/dist/esm/context-resolver.test.js +0 -79
- package/dist/esm/context-resolver.test.js.map +0 -1
- package/dist/esm/helper/app-actions.test.d.ts +0 -2
- package/dist/esm/helper/app-actions.test.d.ts.map +0 -1
- package/dist/esm/helper/app-actions.test.js +0 -29
- package/dist/esm/helper/app-actions.test.js.map +0 -1
- package/dist/esm/http-client.test.d.ts +0 -2
- package/dist/esm/http-client.test.d.ts.map +0 -1
- package/dist/esm/http-client.test.js +0 -69
- package/dist/esm/http-client.test.js.map +0 -1
- package/dist/esm/integration/bun-sqlite.test.d.ts +0 -2
- package/dist/esm/integration/bun-sqlite.test.d.ts.map +0 -1
- package/dist/esm/integration/bun-sqlite.test.js +0 -22
- package/dist/esm/integration/bun-sqlite.test.js.map +0 -1
- package/dist/esm/integration/cloudflare.test.d.ts +0 -2
- package/dist/esm/integration/cloudflare.test.d.ts.map +0 -1
- package/dist/esm/integration/cloudflare.test.js +0 -37
- package/dist/esm/integration/cloudflare.test.js.map +0 -1
- package/dist/esm/integration/deno.test.d.ts +0 -2
- package/dist/esm/integration/deno.test.d.ts.map +0 -1
- package/dist/esm/integration/deno.test.js +0 -46
- package/dist/esm/integration/deno.test.js.map +0 -1
- package/dist/esm/integration/dynamodb.test.d.ts +0 -2
- package/dist/esm/integration/dynamodb.test.d.ts.map +0 -1
- package/dist/esm/integration/dynamodb.test.js +0 -130
- package/dist/esm/integration/dynamodb.test.js.map +0 -1
- package/dist/esm/integration/hono.test.d.ts +0 -2
- package/dist/esm/integration/hono.test.d.ts.map +0 -1
- package/dist/esm/integration/hono.test.js +0 -84
- package/dist/esm/integration/hono.test.js.map +0 -1
- package/dist/esm/registration.test.d.ts +0 -2
- package/dist/esm/registration.test.d.ts.map +0 -1
- package/dist/esm/registration.test.js +0 -57
- package/dist/esm/registration.test.js.map +0 -1
- package/dist/esm/repository.test.d.ts +0 -2
- package/dist/esm/repository.test.d.ts.map +0 -1
- package/dist/esm/repository.test.js +0 -30
- package/dist/esm/repository.test.js.map +0 -1
- package/dist/esm/signer.test.d.ts +0 -2
- package/dist/esm/signer.test.d.ts.map +0 -1
- package/dist/esm/signer.test.js +0 -23
- package/dist/esm/signer.test.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registration.test.js","sourceRoot":"","sources":["../../src/registration.test.ts"],"names":[],"mappings":";;AAAA,uCAAwD;AACxD,0CAA0C;AAC1C,wDAA0E;AAE1E,IAAA,mBAAQ,EAAC,cAAc,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,GAAG,GAAG,IAAI,kBAAS,CACxB,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,EACpE,IAAI,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EAAE,IAAI,EAAE,CAAC,CAAC;QAEpE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,MAAM,CACzC,IAAI,OAAO,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CACxE,CAAC;QAEF,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE9B,IAAA,iBAAM,EAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, jest, test } from \"bun:test\";\nimport { AppServer } from \"../src/app.js\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Registration\", async () => {\n\tconst app = new AppServer(\n\t\t{ appName: \"test\", appSecret: \"test\", authorizeCallbackUrl: \"test\" },\n\t\tnew InMemoryShopRepository(),\n\t);\n\n\ttest(\"authorize: invalid request\", async () => {\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\"http://localhost\"),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"authorize: invalid signature\", async () => {\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost?shop-url=test&shop-id=test×tamp=test\",\n\t\t\t\t{ headers: new Headers({ \"shopware-app-signature\": \"test\" }) },\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(401);\n\t});\n\n\ttest(\"authorize: valid request\", async () => {\n\t\tapp.signer.verify = jest.fn().mockResolvedValue(true);\n\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost?shop-url=test&shop-id=test×tamp=test\",\n\t\t\t\t{ headers: new Headers({ \"shopware-app-signature\": \"test\" }) },\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\t});\n\n\ttest(\"authorizeCallback: invalid request\", async () => {\n\t\tconst resp = await app.registration.authorizeCallback(\n\t\t\tnew Request(\"http://localhost\", { body: \"{}\" }),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"authorizeCallback: shop does not exist\", async () => {\n\t\tconst resp = await app.registration.authorizeCallback(\n\t\t\tnew Request(\"http://localhost\", {\n\t\t\t\tbody: '{\"shopId\": \"test\", \"apiKey\": \"test\", \"secretKey\": \"test\"}',\n\t\t\t}),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"activateShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\tshop?.setShopActive(false);\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.activate(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(shop?.getShopActive()).toBe(true);\n\t});\n\n\ttest(\"deactivateShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\tshop?.setShopActive(true);\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.deactivate(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(shop?.getShopActive()).toBe(false);\n\t});\n\n\ttest(\"deletedShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.delete(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(app.repository.getShopById(\"1\")).resolves.toBeNull();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.test.d.ts","sourceRoot":"","sources":["../../src/repository.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const repository_js_1 = require("../src/repository.js");
|
|
5
|
-
(0, bun_test_1.describe)("Repository", async () => {
|
|
6
|
-
(0, bun_test_1.test)("SimpleShop", async () => {
|
|
7
|
-
const shop = new repository_js_1.SimpleShop("test", "test", "test");
|
|
8
|
-
(0, bun_test_1.expect)(shop.getShopId()).toBe("test");
|
|
9
|
-
(0, bun_test_1.expect)(shop.getShopUrl()).toBe("test");
|
|
10
|
-
(0, bun_test_1.expect)(shop.getShopSecret()).toBe("test");
|
|
11
|
-
(0, bun_test_1.expect)(shop.getShopClientId()).toBeNull();
|
|
12
|
-
(0, bun_test_1.expect)(shop.getShopClientSecret()).toBeNull();
|
|
13
|
-
(0, bun_test_1.expect)(shop.getShopActive()).toBe(true);
|
|
14
|
-
shop.setShopActive(false);
|
|
15
|
-
(0, bun_test_1.expect)(shop.getShopActive()).toBe(false);
|
|
16
|
-
shop.setShopCredentials("test", "test");
|
|
17
|
-
(0, bun_test_1.expect)(shop.getShopClientId()).toBe("test");
|
|
18
|
-
(0, bun_test_1.expect)(shop.getShopClientSecret()).toBe("test");
|
|
19
|
-
});
|
|
20
|
-
(0, bun_test_1.test)("InMemoryShopRepository", async () => {
|
|
21
|
-
const shop = new repository_js_1.SimpleShop("test", "test", "test");
|
|
22
|
-
const repository = new repository_js_1.InMemoryShopRepository();
|
|
23
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeNull();
|
|
24
|
-
await repository.createShop("test", "test", "test");
|
|
25
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeInstanceOf(repository_js_1.SimpleShop);
|
|
26
|
-
await repository.deleteShop("test");
|
|
27
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeNull();
|
|
28
|
-
await repository.updateShop(shop);
|
|
29
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBe(shop);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=repository.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.test.js","sourceRoot":"","sources":["../../src/repository.test.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAClD,wDAA0E;AAE1E,IAAA,mBAAQ,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAA,eAAI,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAEpD,IAAA,iBAAM,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,IAAA,iBAAM,EAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAA,iBAAM,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAA,iBAAM,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAA,iBAAM,EAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9C,IAAA,iBAAM,EAAC,IAAI,CAA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CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Repository\", async () => {\n\ttest(\"SimpleShop\", async () => {\n\t\tconst shop = new SimpleShop(\"test\", \"test\", \"test\");\n\n\t\texpect(shop.getShopId()).toBe(\"test\");\n\t\texpect(shop.getShopUrl()).toBe(\"test\");\n\t\texpect(shop.getShopSecret()).toBe(\"test\");\n\t\texpect(shop.getShopClientId()).toBeNull();\n\t\texpect(shop.getShopClientSecret()).toBeNull();\n\t\texpect(shop.getShopActive()).toBe(true);\n\n\t\tshop.setShopActive(false);\n\n\t\texpect(shop.getShopActive()).toBe(false);\n\n\t\tshop.setShopCredentials(\"test\", \"test\");\n\n\t\texpect(shop.getShopClientId()).toBe(\"test\");\n\t\texpect(shop.getShopClientSecret()).toBe(\"test\");\n\t});\n\n\ttest(\"InMemoryShopRepository\", async () => {\n\t\tconst shop = new SimpleShop(\"test\", \"test\", \"test\");\n\n\t\tconst repository = new InMemoryShopRepository();\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repository.createShop(\"test\", \"test\", \"test\");\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeInstanceOf(SimpleShop);\n\n\t\tawait repository.deleteShop(\"test\");\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repository.updateShop(shop);\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBe(shop);\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.d.ts","sourceRoot":"","sources":["../../src/signer.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const signer_js_1 = require("../src/signer.js");
|
|
5
|
-
(0, bun_test_1.describe)("Signer", () => {
|
|
6
|
-
(0, bun_test_1.test)("signResponse", async () => {
|
|
7
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
8
|
-
const response = new Response("Hello, World!");
|
|
9
|
-
await signer.signResponse(response, "test");
|
|
10
|
-
(0, bun_test_1.expect)(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
11
|
-
await signer.signResponse(response, "test");
|
|
12
|
-
(0, bun_test_1.expect)(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
13
|
-
});
|
|
14
|
-
(0, bun_test_1.test)("sign", async () => {
|
|
15
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
16
|
-
(0, bun_test_1.expect)(await signer.sign("shop-id=blaa", "test")).toBe("f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6");
|
|
17
|
-
});
|
|
18
|
-
(0, bun_test_1.test)("verifyGetRequest", async () => {
|
|
19
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
20
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac"), "test")).rejects.toThrowError("Missing query parameters to verify the GET request");
|
|
21
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac&a=1"), "test")).rejects.toThrowError("Invalid signature");
|
|
22
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6&shop-id=blaa"), "test")).resolves.pass();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=signer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.js","sourceRoot":"","sources":["../../src/signer.test.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAClD,gDAAuD;AAEvD,IAAA,mBAAQ,EAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,IAAA,eAAI,EAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,+BAAmB,EAAE,CAAC;QAEzC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC;QAE/C,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE5C,IAAA,iBAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAC1D,kEAAkE,CAClE,CAAC;QAEF,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE5C,IAAA,iBAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAC1D,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,MAAM,GAAG,IAAI,+BAAmB,EAAE,CAAC;QAEzC,IAAA,iBAAM,EAAC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CACrD,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,MAAM,GAAG,IAAI,+BAAmB,EAAE,CAAC;QAEzC,IAAA,iBAAM,EACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,+GAA+G,CAC/G,EACD,MAAM,CACN,CACD,CAAC,OAAO,CAAC,YAAY,CACrB,oDAAoD,CACpD,CAAC;QACF,IAAA,iBAAM,EACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,mHAAmH,CACnH,EACD,MAAM,CACN,CACD,CAAC,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAE5C,IAAA,iBAAM,EACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,4HAA4H,CAC5H,EACD,MAAM,CACN,CACD,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { WebCryptoHmacSigner } from \"../src/signer.js\";\n\ndescribe(\"Signer\", () => {\n\ttest(\"signResponse\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\tconst response = new Response(\"Hello, World!\");\n\n\t\tawait signer.signResponse(response, \"test\");\n\n\t\texpect(response.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t);\n\n\t\tawait signer.signResponse(response, \"test\");\n\n\t\texpect(response.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t);\n\t});\n\n\ttest(\"sign\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\texpect(await signer.sign(\"shop-id=blaa\", \"test\")).toBe(\n\t\t\t\"f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6\",\n\t\t);\n\t});\n\n\ttest(\"verifyGetRequest\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).rejects.toThrowError(\n\t\t\t\"Missing query parameters to verify the GET request\",\n\t\t);\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac&a=1\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).rejects.toThrowError(\"Invalid signature\");\n\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6&shop-id=blaa\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).resolves.pass();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-resolver.test.d.ts","sourceRoot":"","sources":["../../src/context-resolver.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, expect, jest, test } from "bun:test";
|
|
2
|
-
import { AppServer } from "../src/app.js";
|
|
3
|
-
import { ContextResolver } from "../src/context-resolver.js";
|
|
4
|
-
import { InMemoryShopRepository } from "../src/repository.js";
|
|
5
|
-
describe("Context Resolver", async () => {
|
|
6
|
-
const app = new AppServer({
|
|
7
|
-
appName: "test",
|
|
8
|
-
appSecret: "test",
|
|
9
|
-
authorizeCallbackUrl: "test",
|
|
10
|
-
}, new InMemoryShopRepository());
|
|
11
|
-
await app.repository.createShop("blaa", "test", "test");
|
|
12
|
-
const contextResolver = new ContextResolver(app);
|
|
13
|
-
test("fromBrowser: shop does not exist", async () => {
|
|
14
|
-
expect(contextResolver.fromBrowser(new Request("https://example.com/?shop-id=test&shopware-shop-signature=aaa"))).rejects.toThrowError("Cannot find shop by id test");
|
|
15
|
-
});
|
|
16
|
-
test("fromBrowser: missing header", async () => {
|
|
17
|
-
expect(contextResolver.fromBrowser(new Request("https://example.com/?shop-id=blaa"))).rejects.toThrowError("Missing shopware-shop-signature query parameter");
|
|
18
|
-
});
|
|
19
|
-
test("fromBrowser: shop exists", async () => {
|
|
20
|
-
app.signer.verifyGetRequest = jest.fn().mockResolvedValue(true);
|
|
21
|
-
const context = await contextResolver.fromBrowser(new Request("https://example.com/?shop-id=blaa&shopware-shop-signature=aaa"));
|
|
22
|
-
expect(context.payload).toEqual({
|
|
23
|
-
"shop-id": "blaa",
|
|
24
|
-
"shopware-shop-signature": "aaa",
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
test("fromSource: missing signature header", async () => {
|
|
28
|
-
expect(contextResolver.fromAPI(new Request("https://example.com/", {
|
|
29
|
-
body: JSON.stringify({
|
|
30
|
-
source: {
|
|
31
|
-
shopId: "blaa",
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
}))).rejects.toThrowError("Missing shopware-shop-signature header");
|
|
35
|
-
});
|
|
36
|
-
test("fromSource: shop does not exists", async () => {
|
|
37
|
-
expect(contextResolver.fromAPI(new Request("https://example.com/", {
|
|
38
|
-
headers: {
|
|
39
|
-
"shopware-shop-signature": "aaa",
|
|
40
|
-
},
|
|
41
|
-
body: JSON.stringify({
|
|
42
|
-
source: {
|
|
43
|
-
shopId: "test",
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
-
}))).rejects.toThrowError("Cannot find shop by id test");
|
|
47
|
-
});
|
|
48
|
-
test("fromSource: invalid signature", async () => {
|
|
49
|
-
expect(contextResolver.fromAPI(new Request("https://example.com/", {
|
|
50
|
-
headers: {
|
|
51
|
-
"shopware-shop-signature": "aaa",
|
|
52
|
-
},
|
|
53
|
-
body: JSON.stringify({
|
|
54
|
-
source: {
|
|
55
|
-
shopId: "blaa",
|
|
56
|
-
},
|
|
57
|
-
}),
|
|
58
|
-
}))).rejects.toThrowError("Invalid signature");
|
|
59
|
-
});
|
|
60
|
-
test("fromSource: resolved", async () => {
|
|
61
|
-
app.signer.verify = jest.fn().mockResolvedValue(true);
|
|
62
|
-
const ctx = await contextResolver.fromAPI(new Request("https://example.com/", {
|
|
63
|
-
headers: {
|
|
64
|
-
"shopware-shop-signature": "aaa",
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify({
|
|
67
|
-
source: {
|
|
68
|
-
shopId: "blaa",
|
|
69
|
-
},
|
|
70
|
-
}),
|
|
71
|
-
}));
|
|
72
|
-
expect(ctx.payload).toEqual({
|
|
73
|
-
source: {
|
|
74
|
-
shopId: "blaa",
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
//# sourceMappingURL=context-resolver.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-resolver.test.js","sourceRoot":"","sources":["../../src/context-resolver.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAc,MAAM,sBAAsB,CAAC;AAE1E,QAAQ,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;IACvC,MAAM,GAAG,GAAG,IAAI,SAAS,CACxB;QACC,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,MAAM;QACjB,oBAAoB,EAAE,MAAM;KAC5B,EACD,IAAI,sBAAsB,EAAE,CAC5B,CAAC;IAEF,MAAM,GAAG,CAAC,UAAU,CAAC,U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CAAC,CAAC,OAAO,CAAC;YAC3B,MAAM,EAAE;gBACP,MAAM,EAAE,MAAM;aACd;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, jest, test } from \"bun:test\";\nimport { AppServer } from \"../src/app.js\";\nimport { ContextResolver } from \"../src/context-resolver.js\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Context Resolver\", async () => {\n\tconst app = new AppServer(\n\t\t{\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tauthorizeCallbackUrl: \"test\",\n\t\t},\n\t\tnew InMemoryShopRepository(),\n\t);\n\n\tawait app.repository.createShop(\"blaa\", \"test\", \"test\");\n\n\tconst contextResolver = new ContextResolver(app);\n\n\ttest(\"fromBrowser: shop does not exist\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromBrowser(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shop-id=test&shopware-shop-signature=aaa\",\n\t\t\t\t),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Cannot find shop by id test\");\n\t});\n\n\ttest(\"fromBrowser: missing header\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromBrowser(\n\t\t\t\tnew Request(\"https://example.com/?shop-id=blaa\"),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Missing shopware-shop-signature query parameter\");\n\t});\n\n\ttest(\"fromBrowser: shop exists\", async () => {\n\t\tapp.signer.verifyGetRequest = jest.fn().mockResolvedValue(true);\n\n\t\tconst context = await contextResolver.fromBrowser(\n\t\t\tnew Request(\n\t\t\t\t\"https://example.com/?shop-id=blaa&shopware-shop-signature=aaa\",\n\t\t\t),\n\t\t);\n\n\t\texpect(context.payload).toEqual({\n\t\t\t\"shop-id\": \"blaa\",\n\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t});\n\t});\n\n\ttest(\"fromSource: missing signature header\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Missing shopware-shop-signature header\");\n\t});\n\n\ttest(\"fromSource: shop does not exists\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"test\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Cannot find shop by id test\");\n\t});\n\n\ttest(\"fromSource: invalid signature\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Invalid signature\");\n\t});\n\n\ttest(\"fromSource: resolved\", async () => {\n\t\tapp.signer.verify = jest.fn().mockResolvedValue(true);\n\n\t\tconst ctx = await contextResolver.fromAPI(\n\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\theaders: {\n\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\n\t\texpect(ctx.payload).toEqual({\n\t\t\tsource: {\n\t\t\t\tshopId: \"blaa\",\n\t\t\t},\n\t\t});\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-actions.test.d.ts","sourceRoot":"","sources":["../../../src/helper/app-actions.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { createModalResponse, createNewTabResponse, createNotificationResponse, } from "../../src/helper/app-actions.js";
|
|
3
|
-
describe("AppActions", async () => {
|
|
4
|
-
test("createNewTabResponse", async () => {
|
|
5
|
-
const resp = createNewTabResponse("test");
|
|
6
|
-
expect(resp.headers.get("content-type")).toBe("application/json");
|
|
7
|
-
expect(await resp.text()).toBe(JSON.stringify({
|
|
8
|
-
actionType: "openNewTab",
|
|
9
|
-
payload: { redirectUrl: "test" },
|
|
10
|
-
}));
|
|
11
|
-
});
|
|
12
|
-
test("createNotificationResponse", async () => {
|
|
13
|
-
const resp = createNotificationResponse("success", "test");
|
|
14
|
-
expect(resp.headers.get("content-type")).toBe("application/json");
|
|
15
|
-
expect(await resp.text()).toBe(JSON.stringify({
|
|
16
|
-
actionType: "notification",
|
|
17
|
-
payload: { status: "success", message: "test" },
|
|
18
|
-
}));
|
|
19
|
-
});
|
|
20
|
-
test("createModalResponse", async () => {
|
|
21
|
-
const resp = createModalResponse("test", "small", true);
|
|
22
|
-
expect(resp.headers.get("content-type")).toBe("application/json");
|
|
23
|
-
expect(await resp.text()).toBe(JSON.stringify({
|
|
24
|
-
actionType: "openModal",
|
|
25
|
-
payload: { iframeUrl: "test", size: "small", expand: true },
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=app-actions.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAExD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7B,IAAI,CAAC,SAAS,CAAC;YACd,UAAU,EAAE,WAAW;YACvB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;SAC3D,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport {\n\tcreateModalResponse,\n\tcreateNewTabResponse,\n\tcreateNotificationResponse,\n} from \"../../src/helper/app-actions.js\";\n\ndescribe(\"AppActions\", async () => {\n\ttest(\"createNewTabResponse\", async () => {\n\t\tconst resp = createNewTabResponse(\"test\");\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"openNewTab\",\n\t\t\t\tpayload: { redirectUrl: \"test\" },\n\t\t\t}),\n\t\t);\n\t});\n\n\ttest(\"createNotificationResponse\", async () => {\n\t\tconst resp = createNotificationResponse(\"success\", \"test\");\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"notification\",\n\t\t\t\tpayload: { status: \"success\", message: \"test\" },\n\t\t\t}),\n\t\t);\n\t});\n\n\ttest(\"createModalResponse\", async () => {\n\t\tconst resp = createModalResponse(\"test\", \"small\", true);\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"openModal\",\n\t\t\t\tpayload: { iframeUrl: \"test\", size: \"small\", expand: true },\n\t\t\t}),\n\t\t);\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.test.d.ts","sourceRoot":"","sources":["../../src/http-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, expect, spyOn, test } from "bun:test";
|
|
2
|
-
import { HttpClient } from "../src/http-client.js";
|
|
3
|
-
import { SimpleShop } from "../src/repository.js";
|
|
4
|
-
describe("HTTP Client", async () => {
|
|
5
|
-
test("getToken", async () => {
|
|
6
|
-
const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 3600}')));
|
|
7
|
-
const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
|
|
8
|
-
expect(client.getToken()).resolves.toBe("test");
|
|
9
|
-
// We fetched already once the token, so the second time we should get it from the storage
|
|
10
|
-
await client.getToken();
|
|
11
|
-
expect(mockFetch.mock.calls).toBeArrayOfSize(1);
|
|
12
|
-
mockFetch.mockRestore();
|
|
13
|
-
});
|
|
14
|
-
test("getToken: failed request", async () => {
|
|
15
|
-
const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"error": "invalid_grant"}', { status: 400 })));
|
|
16
|
-
const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
|
|
17
|
-
expect(client.getToken()).rejects.toThrowError("The api client authentication to shop with id: blaa");
|
|
18
|
-
mockFetch.mockRestore();
|
|
19
|
-
});
|
|
20
|
-
test("getToken: expired refetch", async () => {
|
|
21
|
-
const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": -500}')));
|
|
22
|
-
const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
|
|
23
|
-
expect(client.getToken()).resolves.toBe("test");
|
|
24
|
-
expect(mockFetch.mock.calls).toBeArrayOfSize(1);
|
|
25
|
-
expect(client.getToken()).resolves.toBe("test");
|
|
26
|
-
expect(mockFetch.mock.calls).toBeArrayOfSize(2);
|
|
27
|
-
mockFetch.mockRestore();
|
|
28
|
-
});
|
|
29
|
-
test("get, post, put, patch, delete", async () => {
|
|
30
|
-
const mockFetch = spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
|
|
31
|
-
const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
|
|
32
|
-
mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}')));
|
|
33
|
-
expect(client.get("/test")).resolves.toEqual({
|
|
34
|
-
body: { data: "test" },
|
|
35
|
-
headers: new Headers(),
|
|
36
|
-
statusCode: 200,
|
|
37
|
-
});
|
|
38
|
-
expect(client.post("/test", { data: "test" })).resolves.toEqual({
|
|
39
|
-
body: { data: "test" },
|
|
40
|
-
headers: new Headers(),
|
|
41
|
-
statusCode: 200,
|
|
42
|
-
});
|
|
43
|
-
expect(client.put("/test", { data: "test" })).resolves.toEqual({
|
|
44
|
-
body: { data: "test" },
|
|
45
|
-
headers: new Headers(),
|
|
46
|
-
statusCode: 200,
|
|
47
|
-
});
|
|
48
|
-
expect(client.patch("/test", { data: "test" })).resolves.toEqual({
|
|
49
|
-
body: { data: "test" },
|
|
50
|
-
headers: new Headers(),
|
|
51
|
-
statusCode: 200,
|
|
52
|
-
});
|
|
53
|
-
expect(client.delete("/test")).resolves.toEqual({
|
|
54
|
-
body: { data: "test" },
|
|
55
|
-
headers: new Headers(),
|
|
56
|
-
statusCode: 200,
|
|
57
|
-
});
|
|
58
|
-
expect(mockFetch.mock.calls).toBeArrayOfSize(6);
|
|
59
|
-
mockFetch.mockRestore();
|
|
60
|
-
});
|
|
61
|
-
test("get: request failed", async () => {
|
|
62
|
-
const mockFetch = spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
|
|
63
|
-
const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
|
|
64
|
-
mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}', { status: 400 })));
|
|
65
|
-
expect(client.get("/test")).rejects.toThrowError("The api request failed with status code: 400 for shop with id: blaa");
|
|
66
|
-
mockFetch.mockRestore();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=http-client.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.test.js","sourceRoot":"","sources":["../../src/http-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,QAAQ,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;IAClC,IAAI,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAChE,OAAO,CAAC,OAAO,CACd,IAAI,QAAQ,CAAC,8CAA8C,CAAC,CAC5D,CACD,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACtE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhD,0FAA0F;QAC1F,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAExB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAEhD,SAAS,CAAC,WAAW,EAAE,CAAC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OAAO,CAAC,YAAY,CAC/C,qEAAqE,CACrE,CAAC;QAEF,SAAS,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, spyOn, test } from \"bun:test\";\nimport { HttpClient } from \"../src/http-client.js\";\nimport { SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"HTTP Client\", async () => {\n\ttest(\"getToken\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 3600}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\t// We fetched already once the token, so the second time we should get it from the storage\n\t\tawait client.getToken();\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(1);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"getToken: failed request\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"error\": \"invalid_grant\"}', { status: 400 }),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).rejects.toThrowError(\n\t\t\t\"The api client authentication to shop with id: blaa\",\n\t\t);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"getToken: expired refetch\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": -500}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(1);\n\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(2);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"get, post, put, patch, delete\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementationOnce(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 5000}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\n\t\tmockFetch.mockImplementation(() =>\n\t\t\tPromise.resolve(new Response('{\"data\": \"test\"}')),\n\t\t);\n\n\t\texpect(client.get(\"/test\")).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.post(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.put(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.patch(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.delete(\"/test\")).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(6);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"get: request failed\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementationOnce(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 5000}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\n\t\tmockFetch.mockImplementation(() =>\n\t\t\tPromise.resolve(new Response('{\"data\": \"test\"}', { status: 400 })),\n\t\t);\n\n\t\texpect(client.get(\"/test\")).rejects.toThrowError(\n\t\t\t\"The api request failed with status code: 400 for shop with id: blaa\",\n\t\t);\n\n\t\tmockFetch.mockRestore();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun-sqlite.test.d.ts","sourceRoot":"","sources":["../../../src/integration/bun-sqlite.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { SimpleShop } from "../repository.js";
|
|
3
|
-
import { BunSqliteRepository } from "./bun-sqlite.js";
|
|
4
|
-
describe("Bun SQLite", async () => {
|
|
5
|
-
test("createShop", async () => {
|
|
6
|
-
const repo = new BunSqliteRepository(":memory:");
|
|
7
|
-
await repo.createShop("test", "test", "test");
|
|
8
|
-
const shop = await repo.getShopById("test");
|
|
9
|
-
expect(shop).not.toBeNull();
|
|
10
|
-
expect(shop?.getShopId()).toBe("test");
|
|
11
|
-
expect(shop?.getShopUrl()).toBe("test");
|
|
12
|
-
expect(shop?.getShopSecret()).toBe("test");
|
|
13
|
-
await repo.deleteShop("test");
|
|
14
|
-
expect(repo.getShopById("test")).resolves.toBeNull();
|
|
15
|
-
await repo.createShop("test", "test", "test");
|
|
16
|
-
expect(repo.getShopById("test")).resolves.not.toBeNull();
|
|
17
|
-
await repo.updateShop(new SimpleShop("test", "foo.com", "test"));
|
|
18
|
-
const updatedShop = await repo.getShopById("test");
|
|
19
|
-
expect(updatedShop?.getShopUrl()).toBe("foo.com");
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=bun-sqlite.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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;QAEzD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAEjE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { BunSqliteRepository } from \"./bun-sqlite.js\";\n\ndescribe(\"Bun SQLite\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new BunSqliteRepository(\":memory:\");\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"foo.com\", \"test\"));\n\n\t\tconst updatedShop = await repo.getShopById(\"test\");\n\n\t\texpect(updatedShop?.getShopUrl()).toBe(\"foo.com\");\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.test.d.ts","sourceRoot":"","sources":["../../../src/integration/cloudflare.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { describe, expect, test } from "bun:test";
|
|
3
|
-
import { CloudflareShopRepository } from "../../src/integration/cloudflare-kv.js";
|
|
4
|
-
import { SimpleShop } from "../../src/repository.js";
|
|
5
|
-
describe("Cloudflare", async () => {
|
|
6
|
-
test("createShop", async () => {
|
|
7
|
-
const repo = new CloudflareShopRepository(new MockedKVNamespace());
|
|
8
|
-
await repo.createShop("test", "test", "test");
|
|
9
|
-
const shop = await repo.getShopById("test");
|
|
10
|
-
expect(shop).not.toBeNull();
|
|
11
|
-
expect(shop?.getShopId()).toBe("test");
|
|
12
|
-
expect(shop?.getShopUrl()).toBe("test");
|
|
13
|
-
expect(shop?.getShopSecret()).toBe("test");
|
|
14
|
-
await repo.deleteShop("test");
|
|
15
|
-
expect(repo.getShopById("test")).resolves.toBeNull();
|
|
16
|
-
await repo.updateShop(new SimpleShop("test", "test", "test"));
|
|
17
|
-
expect(repo.getShopById("test")).resolves.not.toBeNull();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
class MockedKVNamespace {
|
|
21
|
-
storage;
|
|
22
|
-
constructor() {
|
|
23
|
-
this.storage = new Map();
|
|
24
|
-
}
|
|
25
|
-
get(key, options) {
|
|
26
|
-
return Promise.resolve(this.storage.get(key) || null);
|
|
27
|
-
}
|
|
28
|
-
put(key, value, options) {
|
|
29
|
-
this.storage.set(key, value);
|
|
30
|
-
return Promise.resolve();
|
|
31
|
-
}
|
|
32
|
-
delete(key) {
|
|
33
|
-
this.storage.delete(key);
|
|
34
|
-
return Promise.resolve();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=cloudflare.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.test.js","sourceRoot":"","sources":["../../../src/integration/cloudflare.test.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,UAAU,EA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,OAAmD;QAEnD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,GAAG,CACF,GAAW,EACX,KAA8D,EAC9D,OAA+B;QAE/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAe,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,GAAW;QACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["//\nimport { describe, expect, test } from \"bun:test\";\nimport { CloudflareShopRepository } from \"../../src/integration/cloudflare-kv.js\";\nimport { SimpleShop } from \"../../src/repository.js\";\n\ndescribe(\"Cloudflare\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new CloudflareShopRepository(\n\t\t\tnew MockedKVNamespace() as unknown as KVNamespace,\n\t\t);\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n\nclass MockedKVNamespace {\n\tstorage: Map<string, string>;\n\tconstructor() {\n\t\tthis.storage = new Map();\n\t}\n\n\tget(\n\t\tkey: string,\n\t\toptions?: Partial<KVNamespaceGetOptions<undefined>>,\n\t): Promise<string | null> {\n\t\treturn Promise.resolve(this.storage.get(key) || null);\n\t}\n\tput(\n\t\tkey: string,\n\t\tvalue: string | ArrayBuffer | ArrayBufferView | ReadableStream,\n\t\toptions?: KVNamespacePutOptions,\n\t): Promise<void> {\n\t\tthis.storage.set(key, value as string);\n\t\treturn Promise.resolve();\n\t}\n\tdelete(key: string): Promise<void> {\n\t\tthis.storage.delete(key);\n\t\treturn Promise.resolve();\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.test.d.ts","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { SimpleShop } from "../repository.js";
|
|
3
|
-
import { DenoKVRepository } from "./deno-kv.js";
|
|
4
|
-
describe("Deno", async () => {
|
|
5
|
-
const kv = {
|
|
6
|
-
storage: new Map(),
|
|
7
|
-
set(key, value) {
|
|
8
|
-
this.storage.set(key.join(""), value);
|
|
9
|
-
},
|
|
10
|
-
get(key) {
|
|
11
|
-
if (!this.storage.has(key.join(""))) {
|
|
12
|
-
return {
|
|
13
|
-
key: null,
|
|
14
|
-
value: null,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return Promise.resolve({
|
|
18
|
-
key: key.join(""),
|
|
19
|
-
value: this.storage.get(key.join("")),
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
delete(key) {
|
|
23
|
-
this.storage.delete(key.join(""));
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
globalThis.Deno = {
|
|
28
|
-
openKv() {
|
|
29
|
-
return Promise.resolve(kv);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
test("test repository", async () => {
|
|
33
|
-
const repo = new DenoKVRepository();
|
|
34
|
-
await repo.createShop("test", "test", "test");
|
|
35
|
-
const shop = await repo.getShopById("test");
|
|
36
|
-
expect(shop).not.toBeNull();
|
|
37
|
-
expect(shop?.getShopId()).toBe("test");
|
|
38
|
-
expect(shop?.getShopUrl()).toBe("test");
|
|
39
|
-
expect(shop?.getShopSecret()).toBe("test");
|
|
40
|
-
await repo.deleteShop("test");
|
|
41
|
-
expect(repo.getShopById("test")).resolves.toBeNull();
|
|
42
|
-
await repo.updateShop(new SimpleShop("test", "test", "test"));
|
|
43
|
-
expect(repo.getShopById("test")).resolves.not.toBeNull();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=deno.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.test.js","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,EAAE,GAAG;QACV,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,GAAG,CAAC,GAAa,EAAE,KAAa;YAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,GAAG,CAAC,GAAa;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACrC,OAAO;oBACN,GAAG,EAAE,IAAI;oBACT,KAAK,EAAE,IAAI;iBACX,CAAC;YACH,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAC;gBACtB,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjB,KAAK,EAAE,IAAI,CAAC,OAAO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C,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { DenoKVRepository } from \"./deno-kv.js\";\n\ndescribe(\"Deno\", async () => {\n\tconst kv = {\n\t\tstorage: new Map(),\n\t\tset(key: string[], value: string) {\n\t\t\tthis.storage.set(key.join(\"\"), value);\n\t\t},\n\n\t\tget(key: string[]) {\n\t\t\tif (!this.storage.has(key.join(\"\"))) {\n\t\t\t\treturn {\n\t\t\t\t\tkey: null,\n\t\t\t\t\tvalue: null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn Promise.resolve({\n\t\t\t\tkey: key.join(\"\"),\n\t\t\t\tvalue: this.storage.get(key.join(\"\")),\n\t\t\t});\n\t\t},\n\n\t\tdelete(key: string[]) {\n\t\t\tthis.storage.delete(key.join(\"\"));\n\t\t},\n\t};\n\n\t// @ts-ignore\n\tglobalThis.Deno = {\n\t\topenKv() {\n\t\t\treturn Promise.resolve(kv);\n\t\t},\n\t};\n\n\ttest(\"test repository\", async () => {\n\t\tconst repo = new DenoKVRepository();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamodb.test.d.ts","sourceRoot":"","sources":["../../../src/integration/dynamodb.test.ts"],"names":[],"mappings":""}
|