Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
gerold-penz committed Aug 15, 2024
1 parent a61b30b commit 4530598
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions tests/memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ test("hmSet(), hmGet()", async () => {
// Set multiple fields
store.hmSet(KEY_1, {
"field-1": "value-1",
"field-2": "value-2"
"field-2": "value-2",
"field-3": "value-3"
})

// Get multiple fields
Expand All @@ -654,17 +655,17 @@ test("hmSet(), hmGet()", async () => {
expect(result?.["field-100"]).toBeUndefined()

// Get all fields
expect(Object.keys(store.hmGet(KEY_1)!).length).toEqual(2)
expect(Object.keys(store.hmGet(KEY_1)!).length).toEqual(3)
})


test("hHasField()", async () => {
const store = new BunSqliteKeyValue()

store.hSet(KEY_1, "field-1", "value-1")
store.hSet(KEY_1, FIELD_1, STRING_VALUE_1)

expect(store.hHasField(KEY_1, "field-1")).toBeTrue()
expect(store.hExists(KEY_2, "field-1")).toBeUndefined()
expect(store.hHasField(KEY_1, FIELD_1)).toBeTrue()
expect(store.hExists(KEY_2, FIELD_1)).toBeUndefined()
})


Expand All @@ -673,33 +674,29 @@ test("hGetCount()", async () => {

expect(store.hGetCount(KEY_1)).toBeUndefined()

store.set(KEY_1, "value-1")
store.set(KEY_1, STRING_VALUE_1)
expect(store.hGetCount(KEY_1)).toBeUndefined()

store.hSet(KEY_2, "field-1", "value-1")
store.hSet(KEY_2, FIELD_1, STRING_VALUE_1)
expect(store.hLen(KEY_2)).toEqual(1)
})


test("hGetFields()", async () => {
const store = new BunSqliteKeyValue()

store.hmSet(KEY_1, {
"field-1": "value-1",
"field-2": "value-2"
})
expect(store.hGetFields(KEY_1)).toEqual(["field-1", "field-2"])
store.hSet(KEY_1, FIELD_1, STRING_VALUE_1)
store.hSet(KEY_1, FIELD_2, STRING_VALUE_2)
expect(store.hGetFields(KEY_1)).toEqual([FIELD_1, FIELD_2])
expect(store.hKeys(KEY_1)).toBeArrayOfSize(2)
})


test("hGetValues()", async () => {
const store = new BunSqliteKeyValue()

store.hmSet(KEY_1, {
"field-1": "value-1",
"field-2": "value-2"
})
expect(store.hGetValues(KEY_1)).toEqual(["value-1", "value-2"])
store.hSet(KEY_1, FIELD_1, STRING_VALUE_1)
store.hSet(KEY_1, FIELD_2, STRING_VALUE_2)
expect(store.hGetValues(KEY_1)).toEqual([STRING_VALUE_1, STRING_VALUE_2])
expect(store.hVals(KEY_1)).toBeArrayOfSize(2)
})

0 comments on commit 4530598

Please sign in to comment.