Skip to content

Commit

Permalink
Merge pull request #335 from hyper63/twilson63/chg-connect-test-testi…
Browse files Browse the repository at this point in the history
…ng-333

fix index command for connect (#334)
  • Loading branch information
twilson63 authored Sep 28, 2021
2 parents 80c5d17 + 3f1c6a6 commit deda182
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/connect/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const index = (name, fields) =>
.map((req) =>
new Request(req, {
method: "POST",
body: {
index: { fields },
body: JSON.stringify({
fields,
name,
type: "json",
},
}),
})
);

Expand Down
11 changes: 11 additions & 0 deletions packages/connect/mod_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ test("DATA: bulk documents", async () => {
assertEquals(await req.json(), [{ id: "x-1" }, { id: "x-2" }]);
});

test("DATA: index database", async () => {
const req = await hyper.data.index("idx-name", ["type", "title"]);
assertEquals(req.url, "http://localhost:6363/data/test/_index");
assertEquals(req.method, "POST");
assertEquals(await req.json(), {
fields: ["type", "title"],
name: "idx-name",
type: "json",
});
});

test("CACHE: add key/value", async () => {
const req = await hyper.cache.add("x-1", {
type: "test",
Expand Down

0 comments on commit deda182

Please sign in to comment.