Skip to content

Commit

Permalink
Adding a test for normalize (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
nshiab authored Aug 6, 2024
1 parent 50ac2bc commit 5008bab
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/unit/methods/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,27 @@ describe("normalize", () => {
{ key1: "Banane", key2: null, key3: null, normalized: null },
])
})
it("should normalize data with positive and negative values", async () => {
const table = sdb.newTable()
await table.loadArray([
{ key1: -1 },
{ key1: -0.5 },
{ key1: 0 },
{ key1: 0.5 },
{ key1: 1 },
])

await table.normalize("key1", "normalized")
await table.sort({ key1: "asc" })

const data = await table.getData()

assert.deepStrictEqual(data, [
{ key1: -1, normalized: 0 },
{ key1: -0.5, normalized: 0.25 },
{ key1: 0, normalized: 0.5 },
{ key1: 0.5, normalized: 0.75 },
{ key1: 1, normalized: 1 },
])
})
})

0 comments on commit 5008bab

Please sign in to comment.