Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: falsy boolean queries #13

Merged
merged 20 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bf9c9d7
test: mock engine should not give values by reference
acodeninja Sep 21, 2024
629b989
test: allow stubbing fs without specifying a filesystem
acodeninja Sep 21, 2024
2c71b6a
refactor: make Engine.configuration public
acodeninja Sep 21, 2024
6ef2bdc
fix: allow falsy matching queries
acodeninja Sep 23, 2024
66b10e1
refactor: unnecessary return await
acodeninja Sep 23, 2024
cff112b
refactor: avoid square-bracket notation
acodeninja Sep 23, 2024
b75d39e
refactor: empty functions
acodeninja Sep 23, 2024
3a8aa41
refactor: variable name shadows variable in outer scope
acodeninja Sep 23, 2024
866776b
refactor: class methods should utilize this
acodeninja Sep 23, 2024
5b343f6
refactor: all code paths should have explicit returns, or none
acodeninja Sep 23, 2024
3fcadbc
refactor: remove shorthand type coercions
acodeninja Sep 23, 2024
646154c
refactor: usage of exported name as property of default import
acodeninja Sep 23, 2024
c9f9aa1
docs: add jsdoc blocks for test models
acodeninja Sep 23, 2024
38ee35f
docs: add jsdoc block for test model collection
acodeninja Sep 23, 2024
f3824fb
docs: add jsdoc blocks tyo all type classes
acodeninja Sep 23, 2024
e7e0068
docs: add jsdoc block for complex types
acodeninja Sep 24, 2024
21f0200
docs: add jsdoc blocks for engine classes
acodeninja Sep 24, 2024
5727394
docs: add jsdoc block for calledWith test function
acodeninja Sep 24, 2024
25b45f8
refactor: file retrival consistency
acodeninja Sep 24, 2024
4b1fee8
refactor: async function should have await expression
acodeninja Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: unnecessary return await
acodeninja committed Sep 23, 2024
commit 66b10e14bb2707ced7426a9606fb765f18beb08d
8 changes: 4 additions & 4 deletions src/Transactions.test.js
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ test('transaction.commit() throws an exception if the transaction was successful

await transaction.commit();

await t.throwsAsync(async () => await transaction.commit(), {
await t.throwsAsync(() => transaction.commit(), {
instanceOf: TransactionCommittedError,
message: 'Transaction was already committed.',
});
@@ -68,7 +68,7 @@ test('transaction.commit() throws an exception if the transaction fails', async
await transaction.put(model);

await t.throwsAsync(
async () => await transaction.commit(),
() => transaction.commit(),
{
instanceOf: EngineError,
message: 'Failed to put model',
@@ -98,7 +98,7 @@ test('transaction.commit() reverts already commited changes if the transaction f
await transaction.put(model);

await t.throwsAsync(
async () => await transaction.commit(),
() => transaction.commit(),
{
instanceOf: EngineError,
message: 'Failed to put model LinkedModel/000000000000',
@@ -132,7 +132,7 @@ test('transaction.commit() reverts already commited changes if the transaction f
await transaction.put(model);

await t.throwsAsync(
async () => await transaction.commit(),
() => transaction.commit(),
{
instanceOf: EngineError,
message: 'Failed to put model LinkedModel/000000000000',
12 changes: 6 additions & 6 deletions src/engine/Engine.api.test.js
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {

test(`${engine.toString()}.get(MainModel, id) throws MissConfiguredError when engine is not configured`, async t => {
const error = await t.throwsAsync(
async () => await engine.get(MainModel, 'MainModel/000000000000'),
() => engine.get(MainModel, 'MainModel/000000000000'),
{
instanceOf: MissConfiguredError,
},
@@ -91,7 +91,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {
const store = engine.configure(configuration());

const error = await t.throwsAsync(
async () => await store.get(MainModel, 'MainModel/999999999999'),
() => store.get(MainModel, 'MainModel/999999999999'),
{
instanceOf: NotFoundEngineError,
},
@@ -102,7 +102,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {

test(`${engine.toString()}.put(model) throws MissConfiguredError when engine is not configured`, async t => {
const error = await t.throwsAsync(
async () => await engine.put(MainModel, {string: 'string'}),
() => engine.put(MainModel, {string: 'string'}),
{
instanceOf: MissConfiguredError,
},
@@ -120,7 +120,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {

test(`${engine.toString()}.find(MainModel, parameters) throws MissConfiguredError when engine is not configured`, async t => {
const error = await t.throwsAsync(
async () => await engine.find(MainModel, {string: 'string'}),
() => engine.find(MainModel, {string: 'string'}),
{
instanceOf: MissConfiguredError,
},
@@ -139,7 +139,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {

test(`${engine.toString()}.search(MainModel, 'string') throws MissConfiguredError when engine is not configured`, async t => {
const error = await t.throwsAsync(
async () => await engine.search(MainModel, 'string'),
() => engine.search(MainModel, 'string'),
{
instanceOf: MissConfiguredError,
},
@@ -162,7 +162,7 @@ for (const {engine, configuration, configurationIgnores} of engines) {

test(`${engine.toString()}.hydrate(model) throws MissConfiguredError when engine is not configured`, async t => {
const error = await t.throwsAsync(
async () => await engine.hydrate(new Models().createFullTestModel().toData()),
() => engine.hydrate(new Models().createFullTestModel().toData()),
{
instanceOf: MissConfiguredError,
},
4 changes: 2 additions & 2 deletions src/engine/FileEngine.test.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ test('FileEngine.configure(configuration) returns a new engine without altering

test('FileEngine.get(MainModel, id) when engine is not configured', async t => {
const error = await t.throwsAsync(
async () => await FileEngine.get(MainModel, 'MainModel/000000000000'),
() => FileEngine.get(MainModel, 'MainModel/000000000000'),
{
instanceOf: MissConfiguredError,
},
@@ -425,7 +425,7 @@ test('FileEngine.search(MainModel, "test") when no index exists for the model',
filesystem,
};

await t.throwsAsync(async () => await FileEngine.configure(configuration).search(MainModel, 'test'), {
await t.throwsAsync(() => FileEngine.configure(configuration).search(MainModel, 'test'), {
instanceOf: EngineError,
message: 'The model MainModel does not have a search index available.',
});
4 changes: 2 additions & 2 deletions src/engine/HTTPEngine.test.js
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ test('HTTPEngine.configure(configuration) with additional headers returns a new

test('HTTPEngine.get(MainModel, id) when engine is not configured', async t => {
const error = await t.throwsAsync(
async () => await HTTPEngine.get(MainModel, 'MainModel/000000000000'),
() => HTTPEngine.get(MainModel, 'MainModel/000000000000'),
{
instanceOf: MissConfiguredError,
},
@@ -796,7 +796,7 @@ test('HTTPEngine.search(MainModel, "not-even-close-to-a-match") when no matching
test('HTTPEngine.search(MainModel, "tes") when no index exists for the model', async t => {
const fetch = stubFetch({}, []);

await t.throwsAsync(async () => await HTTPEngine.configure({
await t.throwsAsync(() => HTTPEngine.configure({
host: 'https://example.com',
prefix: 'test',
fetch,
4 changes: 2 additions & 2 deletions src/engine/S3Engine.test.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ test('S3Engine.configure(configuration) returns a new engine without altering th

test('S3Engine.get(MainModel, id) when engine is not configured', async t => {
const error = await t.throwsAsync(
async () => await S3Engine.get(MainModel, 'MainModel/000000000000'),
() => S3Engine.get(MainModel, 'MainModel/000000000000'),
{
instanceOf: MissConfiguredError,
},
@@ -813,7 +813,7 @@ test('S3Engine.search(MainModel, "test") when no search index exists for the mod
client,
};

await t.throwsAsync(async () => await S3Engine.configure(configuration).search(MainModel, 'test'), {
await t.throwsAsync(() => S3Engine.configure(configuration).search(MainModel, 'test'), {
instanceOf: EngineError,
message: 'The model MainModel does not have a search index available.',
});