-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): adds human-readable elapsed time config (#264)
- Loading branch information
1 parent
8465eae
commit 21af3a6
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import t from "tap"; | ||
import { create, insert, search } from "../src/index.js"; | ||
|
||
t.test("elapsed", t => { | ||
t.plan(2); | ||
|
||
t.test("should correctly set elapsed time to a human-readable form", async t => { | ||
t.plan(1); | ||
const db = await create({ | ||
schema: { | ||
title: "string", | ||
body: "string", | ||
}, | ||
components: { | ||
elapsed: { | ||
format: "human" | ||
} | ||
} | ||
}); | ||
|
||
await insert(db, { | ||
title: "Hello world", | ||
body: "This is a test", | ||
}); | ||
|
||
const results = await search(db, { | ||
term: "test" | ||
}); | ||
|
||
t.same(typeof results.elapsed, "string"); | ||
}); | ||
|
||
t.test("should correctly set elapsed time to a raw, bigInt", async t => { | ||
t.plan(1); | ||
const db = await create({ | ||
schema: { | ||
title: "string", | ||
body: "string", | ||
}, | ||
components: { | ||
elapsed: { | ||
format: "raw" | ||
} | ||
} | ||
}); | ||
|
||
await insert(db, { | ||
title: "Hello world", | ||
body: "This is a test", | ||
}); | ||
|
||
const results = await search(db, { | ||
term: "test" | ||
}); | ||
|
||
t.same(typeof results.elapsed, "bigint"); | ||
}); | ||
}); |