Skip to content

Commit

Permalink
chore(deps): update to [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanium committed Feb 1, 2023
1 parent 0364623 commit cf710e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/x/web_bson@v0.2.5/mod.ts";
export * from "https://deno.land/x/web_bson@v0.3.0/mod.js";
45 changes: 26 additions & 19 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file require-await
import { MongoClient, ObjectId } from "./mod.ts";
import { MongoClient, ObjectId, UUID } from "./mod.ts";
import { assertEquals, deferred } from "./test_deps.ts";

Deno.test("Sample Test", async () => {
Expand All @@ -15,40 +15,47 @@ Deno.test("Sample Test", async () => {
fetchMock.resolve({ url, init });
return {
ok: true,
text: async () => (JSON.stringify({ ok: true })),
text: async () => JSON.stringify({ ok: true }),
};
}) as typeof fetch,
});

const _id = new ObjectId();
client.database("db-name").collection("c-name").insertOne({
_id,
foo: "bar",
});
client
.database("db-name")
.collection("c-name")
.insertOne({
_id,
foo: "bar",
uuid: new UUID("408ebbdc-2651-4aa4-8298-3aef14e78f7e"),
});

const { url, init } = await fetchMock;
assertEquals(
url,
"https://data.mongodb-api.com/app/data-abc/endpoint/data/v1/action/insertOne",
"https://data.mongodb-api.com/app/data-abc/endpoint/data/v1/action/insertOne"
);
assertEquals(init.method, "POST");
assertEquals(
new Headers(init.headers).get("Content-Type"),
"application/ejson",
"application/ejson"
);
assertEquals(new Headers(init.headers).get("api-key"), "API_KEY");
assertEquals(
await new Request(url, init).json(),
{
collection: "c-name",
database: "db-name",
dataSource: "dataSource",
document: {
_id: {
$oid: _id.toHexString(),
assertEquals(await new Request(url, init).json(), {
collection: "c-name",
database: "db-name",
dataSource: "dataSource",
document: {
_id: {
$oid: _id.toHexString(),
},
foo: "bar",
uuid: {
$binary: {
base64: "QI673CZRSqSCmDrvFOePfg==",
subType: "04",
},
foo: "bar",
},
},
);
});
});

0 comments on commit cf710e0

Please sign in to comment.