mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
added format command and added trailing commas to reduce conflicts
This commit is contained in:
@@ -26,7 +26,7 @@ class ReturnEvent extends Event<{ foo: string }, string> {
|
||||
}
|
||||
|
||||
return this.clone({
|
||||
foo: [this.params.foo, value].join("-")
|
||||
foo: [this.params.foo, value].join("-"),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ describe("EventManager", async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
delayed();
|
||||
},
|
||||
"sync"
|
||||
"sync",
|
||||
);
|
||||
|
||||
// don't allow unknown
|
||||
@@ -83,8 +83,8 @@ describe("EventManager", async () => {
|
||||
const emgr = new EventManager(
|
||||
{ InformationalEvent },
|
||||
{
|
||||
asyncExecutor
|
||||
}
|
||||
asyncExecutor,
|
||||
},
|
||||
);
|
||||
|
||||
emgr.onEvent(InformationalEvent, async () => {});
|
||||
@@ -98,8 +98,8 @@ describe("EventManager", async () => {
|
||||
const emgr = new EventManager(
|
||||
{ ReturnEvent, InformationalEvent },
|
||||
{
|
||||
onInvalidReturn
|
||||
}
|
||||
onInvalidReturn,
|
||||
},
|
||||
);
|
||||
|
||||
// @ts-expect-error InformationalEvent has no return value
|
||||
@@ -140,7 +140,7 @@ describe("EventManager", async () => {
|
||||
expect(slug).toBe("informational-event");
|
||||
call();
|
||||
},
|
||||
{ mode: "sync", once: true }
|
||||
{ mode: "sync", once: true },
|
||||
);
|
||||
|
||||
expect(emgr.getListeners().length).toBe(1);
|
||||
|
||||
@@ -30,8 +30,8 @@ describe("Registry", () => {
|
||||
first: {
|
||||
cls: What,
|
||||
schema: Type.Object({ type: Type.String(), what: Type.String() }),
|
||||
enabled: true
|
||||
}
|
||||
enabled: true,
|
||||
},
|
||||
} satisfies Record<string, Test1>);
|
||||
|
||||
const item = registry.get("first");
|
||||
@@ -42,7 +42,7 @@ describe("Registry", () => {
|
||||
registry.add("second", {
|
||||
cls: What2,
|
||||
schema: second,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
});
|
||||
// @ts-ignore
|
||||
expect(registry.get("second").schema).toEqual(second);
|
||||
@@ -52,7 +52,7 @@ describe("Registry", () => {
|
||||
// @ts-expect-error
|
||||
cls: NotAllowed,
|
||||
schema: third,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
});
|
||||
// @ts-ignore
|
||||
expect(registry.get("third").schema).toEqual(third);
|
||||
@@ -62,7 +62,7 @@ describe("Registry", () => {
|
||||
cls: What,
|
||||
// @ts-expect-error
|
||||
schema: fourth,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
});
|
||||
// @ts-ignore
|
||||
expect(registry.get("fourth").schema).toEqual(fourth);
|
||||
@@ -75,7 +75,7 @@ describe("Registry", () => {
|
||||
return {
|
||||
cls: a,
|
||||
schema: a.prototype.getType(),
|
||||
enabled: true
|
||||
enabled: true,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { after, beforeEach, describe, test } from "node:test";
|
||||
import { Miniflare } from "miniflare";
|
||||
import {
|
||||
CloudflareKVCacheItem,
|
||||
CloudflareKVCachePool
|
||||
CloudflareKVCachePool,
|
||||
} from "../../../src/core/cache/adapters/CloudflareKvCache";
|
||||
import { runTests } from "./cache-test-suite";
|
||||
|
||||
@@ -26,7 +26,7 @@ describe("CloudflareKv", async () => {
|
||||
mf = new Miniflare({
|
||||
modules: true,
|
||||
script: "export default { async fetch() { return new Response(null); } }",
|
||||
kvNamespaces: ["TEST"]
|
||||
kvNamespaces: ["TEST"],
|
||||
});
|
||||
const kv = await mf.getKVNamespace("TEST");
|
||||
return new CloudflareKVCachePool(kv as any);
|
||||
@@ -45,10 +45,10 @@ describe("CloudflareKv", async () => {
|
||||
},
|
||||
toBeUndefined() {
|
||||
assert.equal(actual, undefined);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
||||
4
app/__test__/core/cache/MemoryCache.spec.ts
vendored
4
app/__test__/core/cache/MemoryCache.spec.ts
vendored
@@ -9,7 +9,7 @@ describe("MemoryCache", () => {
|
||||
tester: {
|
||||
test,
|
||||
beforeEach,
|
||||
expect
|
||||
}
|
||||
expect,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { checksum, hash } from "../../src/core/utils";
|
||||
describe("crypto", async () => {
|
||||
test("sha256", async () => {
|
||||
expect(await hash.sha256("test")).toBe(
|
||||
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
|
||||
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
|
||||
);
|
||||
});
|
||||
test("sha1", async () => {
|
||||
|
||||
@@ -8,8 +8,8 @@ describe("SchemaObject", async () => {
|
||||
Type.Object({ a: Type.String({ default: "b" }) }),
|
||||
{ a: "test" },
|
||||
{
|
||||
forceParse: true
|
||||
}
|
||||
forceParse: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(m.get()).toEqual({ a: "test" });
|
||||
@@ -30,14 +30,14 @@ describe("SchemaObject", async () => {
|
||||
b: Type.Object(
|
||||
{
|
||||
c: Type.String({ default: "d" }),
|
||||
e: Type.String({ default: "f" })
|
||||
e: Type.String({ default: "f" }),
|
||||
},
|
||||
{ default: {} }
|
||||
)
|
||||
{ default: {} },
|
||||
),
|
||||
},
|
||||
{ default: {}, additionalProperties: false }
|
||||
)
|
||||
})
|
||||
{ default: {}, additionalProperties: false },
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(m.get()).toEqual({ s: { a: "b", b: { c: "d", e: "f" } } });
|
||||
|
||||
@@ -59,8 +59,8 @@ describe("SchemaObject", async () => {
|
||||
test("patch array", async () => {
|
||||
const m = new SchemaObject(
|
||||
Type.Object({
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] })
|
||||
})
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] }),
|
||||
}),
|
||||
);
|
||||
expect(m.get()).toEqual({ methods: ["GET", "PATCH"] });
|
||||
|
||||
@@ -81,14 +81,14 @@ describe("SchemaObject", async () => {
|
||||
a: Type.String({ default: "b" }),
|
||||
b: Type.Object(
|
||||
{
|
||||
c: Type.String({ default: "d" })
|
||||
c: Type.String({ default: "d" }),
|
||||
},
|
||||
{ default: {} }
|
||||
)
|
||||
{ default: {} },
|
||||
),
|
||||
},
|
||||
{ default: {} }
|
||||
)
|
||||
})
|
||||
{ default: {} },
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(m.get()).toEqual({ s: { a: "b", b: { c: "d" } } });
|
||||
|
||||
@@ -108,8 +108,8 @@ describe("SchemaObject", async () => {
|
||||
test("set", async () => {
|
||||
const m = new SchemaObject(
|
||||
Type.Object({
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] })
|
||||
})
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] }),
|
||||
}),
|
||||
);
|
||||
expect(m.get()).toEqual({ methods: ["GET", "PATCH"] });
|
||||
|
||||
@@ -125,7 +125,7 @@ describe("SchemaObject", async () => {
|
||||
let result: any;
|
||||
const m = new SchemaObject(
|
||||
Type.Object({
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] })
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] }),
|
||||
}),
|
||||
undefined,
|
||||
{
|
||||
@@ -133,8 +133,8 @@ describe("SchemaObject", async () => {
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
called = true;
|
||||
result = config;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await m.set({ methods: ["GET", "POST"] });
|
||||
@@ -146,7 +146,7 @@ describe("SchemaObject", async () => {
|
||||
let called = false;
|
||||
const m = new SchemaObject(
|
||||
Type.Object({
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] })
|
||||
methods: Type.Array(Type.String(), { default: ["GET", "PATCH"] }),
|
||||
}),
|
||||
undefined,
|
||||
{
|
||||
@@ -155,8 +155,8 @@ describe("SchemaObject", async () => {
|
||||
called = true;
|
||||
to.methods.push("OPTIONS");
|
||||
return to;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const result = await m.set({ methods: ["GET", "POST"] });
|
||||
@@ -168,7 +168,7 @@ describe("SchemaObject", async () => {
|
||||
|
||||
test("throwIfRestricted", async () => {
|
||||
const m = new SchemaObject(Type.Object({}), undefined, {
|
||||
restrictPaths: ["a.b"]
|
||||
restrictPaths: ["a.b"],
|
||||
});
|
||||
|
||||
expect(() => m.throwIfRestricted("a.b")).toThrow();
|
||||
@@ -185,18 +185,18 @@ describe("SchemaObject", async () => {
|
||||
a: Type.String({ default: "b" }),
|
||||
b: Type.Object(
|
||||
{
|
||||
c: Type.String({ default: "d" })
|
||||
c: Type.String({ default: "d" }),
|
||||
},
|
||||
{ default: {} }
|
||||
)
|
||||
{ default: {} },
|
||||
),
|
||||
},
|
||||
{ default: {} }
|
||||
)
|
||||
{ default: {} },
|
||||
),
|
||||
}),
|
||||
undefined,
|
||||
{
|
||||
restrictPaths: ["s.b"]
|
||||
}
|
||||
restrictPaths: ["s.b"],
|
||||
},
|
||||
);
|
||||
|
||||
expect(m.patch("s.b.c", "e")).rejects.toThrow();
|
||||
@@ -217,33 +217,33 @@ describe("SchemaObject", async () => {
|
||||
additionalProperties: Type.Object({
|
||||
type: Type.String(),
|
||||
config: Type.Optional(
|
||||
Type.Object({}, { additionalProperties: Type.String() })
|
||||
)
|
||||
})
|
||||
}
|
||||
Type.Object({}, { additionalProperties: Type.String() }),
|
||||
),
|
||||
}),
|
||||
},
|
||||
),
|
||||
config: Type.Optional(Type.Object({}, { additionalProperties: Type.String() }))
|
||||
})
|
||||
}
|
||||
)
|
||||
config: Type.Optional(Type.Object({}, { additionalProperties: Type.String() })),
|
||||
}),
|
||||
},
|
||||
),
|
||||
},
|
||||
{
|
||||
additionalProperties: false
|
||||
}
|
||||
additionalProperties: false,
|
||||
},
|
||||
);
|
||||
test("patch safe object, overwrite", async () => {
|
||||
const data = {
|
||||
entities: {
|
||||
some: {
|
||||
fields: {
|
||||
a: { type: "string", config: { some: "thing" } }
|
||||
}
|
||||
}
|
||||
}
|
||||
a: { type: "string", config: { some: "thing" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const m = new SchemaObject(dataEntitiesSchema, data, {
|
||||
forceParse: true,
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config/]
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config/],
|
||||
});
|
||||
|
||||
await m.patch("entities.some.fields.a", { type: "string", config: { another: "one" } });
|
||||
@@ -252,10 +252,10 @@ describe("SchemaObject", async () => {
|
||||
entities: {
|
||||
some: {
|
||||
fields: {
|
||||
a: { type: "string", config: { another: "one" } }
|
||||
}
|
||||
}
|
||||
}
|
||||
a: { type: "string", config: { another: "one" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -265,22 +265,22 @@ describe("SchemaObject", async () => {
|
||||
users: {
|
||||
fields: {
|
||||
email: { type: "string" },
|
||||
password: { type: "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
password: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const m = new SchemaObject(dataEntitiesSchema, data, {
|
||||
forceParse: true,
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config\.html_config$/]
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config\.html_config$/],
|
||||
});
|
||||
|
||||
await m.patch("entities.test", {
|
||||
fields: {
|
||||
content: {
|
||||
type: "text"
|
||||
}
|
||||
}
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(m.get()).toEqual({
|
||||
@@ -288,17 +288,17 @@ describe("SchemaObject", async () => {
|
||||
users: {
|
||||
fields: {
|
||||
email: { type: "string" },
|
||||
password: { type: "string" }
|
||||
}
|
||||
password: { type: "string" },
|
||||
},
|
||||
},
|
||||
test: {
|
||||
fields: {
|
||||
content: {
|
||||
type: "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -308,14 +308,14 @@ describe("SchemaObject", async () => {
|
||||
users: {
|
||||
fields: {
|
||||
email: { type: "string" },
|
||||
password: { type: "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
password: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const m = new SchemaObject(dataEntitiesSchema, data, {
|
||||
forceParse: true,
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config\.html_config$/]
|
||||
overwritePaths: [/^entities\..*\.fields\..*\.config\.html_config$/],
|
||||
});
|
||||
|
||||
expect(m.patch("desc", "entities.users.config.sort_dir")).rejects.toThrow();
|
||||
@@ -323,13 +323,13 @@ describe("SchemaObject", async () => {
|
||||
await m.patch("entities.test", {
|
||||
fields: {
|
||||
content: {
|
||||
type: "text"
|
||||
}
|
||||
}
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await m.patch("entities.users.config", {
|
||||
sort_dir: "desc"
|
||||
sort_dir: "desc",
|
||||
});
|
||||
|
||||
expect(m.get()).toEqual({
|
||||
@@ -337,20 +337,20 @@ describe("SchemaObject", async () => {
|
||||
users: {
|
||||
fields: {
|
||||
email: { type: "string" },
|
||||
password: { type: "string" }
|
||||
password: { type: "string" },
|
||||
},
|
||||
config: {
|
||||
sort_dir: "desc"
|
||||
}
|
||||
sort_dir: "desc",
|
||||
},
|
||||
},
|
||||
test: {
|
||||
fields: {
|
||||
content: {
|
||||
type: "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@ describe("diff", () => {
|
||||
t: "a",
|
||||
p: ["b"],
|
||||
o: undefined,
|
||||
n: 2
|
||||
}
|
||||
n: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -35,8 +35,8 @@ describe("diff", () => {
|
||||
t: "r",
|
||||
p: ["b"],
|
||||
o: 2,
|
||||
n: undefined
|
||||
}
|
||||
n: undefined,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -57,8 +57,8 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a"],
|
||||
o: 1,
|
||||
n: 2
|
||||
}
|
||||
n: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -79,8 +79,8 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a", "b"],
|
||||
o: 1,
|
||||
n: 2
|
||||
}
|
||||
n: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -101,14 +101,14 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a", 1],
|
||||
o: 2,
|
||||
n: 4
|
||||
n: 4,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["a", 3],
|
||||
o: undefined,
|
||||
n: 5
|
||||
}
|
||||
n: 5,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -129,20 +129,20 @@ describe("diff", () => {
|
||||
t: "a",
|
||||
p: ["a", 0],
|
||||
o: undefined,
|
||||
n: 1
|
||||
n: 1,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["a", 1],
|
||||
o: undefined,
|
||||
n: 2
|
||||
n: 2,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["a", 2],
|
||||
o: undefined,
|
||||
n: 3
|
||||
}
|
||||
n: 3,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -163,14 +163,14 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a", 1],
|
||||
o: 2,
|
||||
n: 3
|
||||
n: 3,
|
||||
},
|
||||
{
|
||||
t: "r",
|
||||
p: ["a", 2],
|
||||
o: 3,
|
||||
n: undefined
|
||||
}
|
||||
n: undefined,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -183,14 +183,14 @@ describe("diff", () => {
|
||||
it("should handle complex nested changes", () => {
|
||||
const oldObj = {
|
||||
a: {
|
||||
b: [1, 2, { c: 3 }]
|
||||
}
|
||||
b: [1, 2, { c: 3 }],
|
||||
},
|
||||
};
|
||||
|
||||
const newObj = {
|
||||
a: {
|
||||
b: [1, 2, { c: 4 }, 5]
|
||||
}
|
||||
b: [1, 2, { c: 4 }, 5],
|
||||
},
|
||||
};
|
||||
|
||||
const diffs = diff(oldObj, newObj);
|
||||
@@ -200,14 +200,14 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a", "b", 2, "c"],
|
||||
o: 3,
|
||||
n: 4
|
||||
n: 4,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["a", "b", 3],
|
||||
o: undefined,
|
||||
n: 5
|
||||
}
|
||||
n: 5,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -228,14 +228,14 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a"],
|
||||
o: undefined,
|
||||
n: null
|
||||
n: null,
|
||||
},
|
||||
{
|
||||
t: "e",
|
||||
p: ["b"],
|
||||
o: null,
|
||||
n: undefined
|
||||
}
|
||||
n: undefined,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -256,8 +256,8 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a"],
|
||||
o: 1,
|
||||
n: "1"
|
||||
}
|
||||
n: "1",
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -278,14 +278,14 @@ describe("diff", () => {
|
||||
t: "r",
|
||||
p: ["b"],
|
||||
o: 2,
|
||||
n: undefined
|
||||
n: undefined,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["c"],
|
||||
o: undefined,
|
||||
n: 3
|
||||
}
|
||||
n: 3,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -306,8 +306,8 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a"],
|
||||
o: [1, 2, 3],
|
||||
n: { b: 4 }
|
||||
}
|
||||
n: { b: 4 },
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -328,8 +328,8 @@ describe("diff", () => {
|
||||
t: "e",
|
||||
p: ["a"],
|
||||
o: { b: 1 },
|
||||
n: 2
|
||||
}
|
||||
n: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -350,14 +350,14 @@ describe("diff", () => {
|
||||
t: "r",
|
||||
p: ["a"],
|
||||
o: 1,
|
||||
n: undefined
|
||||
n: undefined,
|
||||
},
|
||||
{
|
||||
t: "a",
|
||||
p: ["b"],
|
||||
o: undefined,
|
||||
n: 2
|
||||
}
|
||||
n: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -408,8 +408,8 @@ describe("diff", () => {
|
||||
t: "a",
|
||||
p: ["a"],
|
||||
o: undefined,
|
||||
n: 1
|
||||
}
|
||||
n: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
@@ -430,8 +430,8 @@ describe("diff", () => {
|
||||
t: "r",
|
||||
p: ["a"],
|
||||
o: 1,
|
||||
n: undefined
|
||||
}
|
||||
n: undefined,
|
||||
},
|
||||
]);
|
||||
|
||||
const appliedObj = apply(oldObj, diffs);
|
||||
|
||||
@@ -9,7 +9,7 @@ describe("object-query", () => {
|
||||
|
||||
test("validates", async () => {
|
||||
const converted = convert({
|
||||
name: { $eq: "ch" }
|
||||
name: { $eq: "ch" },
|
||||
});
|
||||
validate(converted, { name: "Michael" });
|
||||
});
|
||||
@@ -31,7 +31,7 @@ describe("object-query", () => {
|
||||
[{ val: { $notnull: 1 } }, { val: null }, false],
|
||||
[{ val: { $regex: ".*" } }, { val: "test" }, true],
|
||||
[{ val: { $regex: /^t.*/ } }, { val: "test" }, true],
|
||||
[{ val: { $regex: /^b.*/ } }, { val: "test" }, false]
|
||||
[{ val: { $regex: /^b.*/ } }, { val: "test" }, false],
|
||||
];
|
||||
|
||||
for (const [query, object, expected] of tests) {
|
||||
@@ -55,10 +55,10 @@ describe("object-query", () => {
|
||||
[
|
||||
{ $or: { val1: { $eq: "foo" }, val2: { $eq: "bar" } } },
|
||||
{ val1: "foo", val2: "bar" },
|
||||
true
|
||||
true,
|
||||
],
|
||||
[{ val1: { $eq: 1 }, $or: { val1: { $eq: 2 } } }, { val1: 1 }, true],
|
||||
[{ val1: { $eq: 1 }, $or: { val1: { $eq: 2 } } }, { val1: 3 }, false]
|
||||
[{ val1: { $eq: 1 }, $or: { val1: { $eq: 2 } } }, { val1: 3 }, false],
|
||||
];
|
||||
|
||||
for (const [query, object, expected] of tests) {
|
||||
|
||||
@@ -16,7 +16,7 @@ describe("Core Utils", async () => {
|
||||
expect(result).toEqual([
|
||||
{ key: "a", value: 1 },
|
||||
{ key: "b", value: 2 },
|
||||
{ key: "c", value: 3 }
|
||||
{ key: "c", value: 3 },
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ describe("Core Utils", async () => {
|
||||
const obj = utils.headersToObject(headers);
|
||||
expect(obj).toEqual({
|
||||
"content-type": "application/json",
|
||||
authorization: "Bearer 123"
|
||||
authorization: "Bearer 123",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -82,7 +82,7 @@ describe("Core Utils", async () => {
|
||||
file: new File([""], "file.txt"),
|
||||
stream: new ReadableStream(),
|
||||
arrayBuffer: new ArrayBuffer(10),
|
||||
arrayBufferView: new Uint8Array(new ArrayBuffer(10))
|
||||
arrayBufferView: new Uint8Array(new ArrayBuffer(10)),
|
||||
};
|
||||
|
||||
const fns = [
|
||||
@@ -90,7 +90,7 @@ describe("Core Utils", async () => {
|
||||
[utils.isBlob, "blob", ["stream", "arrayBuffer", "arrayBufferView"]],
|
||||
[utils.isFile, "file", ["stream", "arrayBuffer", "arrayBufferView"]],
|
||||
[utils.isArrayBuffer, "arrayBuffer"],
|
||||
[utils.isArrayBufferView, "arrayBufferView"]
|
||||
[utils.isArrayBufferView, "arrayBufferView"],
|
||||
] as const;
|
||||
|
||||
const additional = [0, 0.0, "", null, undefined, {}, []];
|
||||
@@ -116,10 +116,10 @@ describe("Core Utils", async () => {
|
||||
const name = "test.json";
|
||||
const text = "attachment; filename=" + name;
|
||||
const headers = new Headers({
|
||||
"Content-Disposition": text
|
||||
"Content-Disposition": text,
|
||||
});
|
||||
const request = new Request("http://example.com", {
|
||||
headers
|
||||
headers,
|
||||
});
|
||||
|
||||
expect(utils.getContentName(text)).toBe(name);
|
||||
@@ -166,7 +166,7 @@ describe("Core Utils", async () => {
|
||||
[{ a: 1, b: 2, c: 3 }, ["b"], { a: 1, c: 3 }],
|
||||
[{ a: 1, b: 2, c: 3 }, ["c"], { a: 1, b: 2 }],
|
||||
[{ a: 1, b: 2, c: 3 }, ["a", "b"], { c: 3 }],
|
||||
[{ a: 1, b: 2, c: 3 }, ["a", "b", "c"], {}]
|
||||
[{ a: 1, b: 2, c: 3 }, ["a", "b", "c"], {}],
|
||||
] as [object, string[], object][];
|
||||
|
||||
for (const [obj, keys, expected] of objects) {
|
||||
@@ -197,9 +197,9 @@ describe("Core Utils", async () => {
|
||||
new Map([["a", 1]]),
|
||||
new Map([
|
||||
["a", 1],
|
||||
["b", 2]
|
||||
["b", 2],
|
||||
]),
|
||||
false
|
||||
false,
|
||||
],
|
||||
[{ a: 1 }, { a: 1 }, true],
|
||||
[{ a: 1 }, { a: 2 }, false],
|
||||
@@ -220,7 +220,7 @@ describe("Core Utils", async () => {
|
||||
[[1, 2, 3], [1, 2, 3, 4], false],
|
||||
[[{ a: 1 }], [{ a: 1 }], true],
|
||||
[[{ a: 1 }], [{ a: 2 }], false],
|
||||
[[{ a: 1 }], [{ b: 1 }], false]
|
||||
[[{ a: 1 }], [{ b: 1 }], false],
|
||||
] as [any, any, boolean][];
|
||||
|
||||
for (const [a, b, expected] of objects) {
|
||||
@@ -236,7 +236,7 @@ describe("Core Utils", async () => {
|
||||
[{ a: { b: 1 } }, "a.b", 1],
|
||||
[{ a: { b: 1 } }, "a.b.c", null, null],
|
||||
[{ a: { b: 1 } }, "a.b.c", 1, 1],
|
||||
[[[1]], "0.0", 1]
|
||||
[[[1]], "0.0", 1],
|
||||
] as [object, string, any, any][];
|
||||
|
||||
for (const [obj, path, expected, defaultValue] of tests) {
|
||||
|
||||
Reference in New Issue
Block a user