-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix: append error - added test cases - fixed wrong test case on `delete.test.ts` - fixed `append` malfunction
- Loading branch information
Showing
5 changed files
with
124 additions
and
17 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
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,57 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import Flat from "../src/Flat"; | ||
|
||
describe("get(key: string) function", () => { | ||
it("should get keys on simple objet", () => { | ||
const flat = Flat.from({ | ||
foo: "bar", | ||
}); | ||
|
||
expect(flat.getKeys()).toEqual(["foo"]); | ||
}); | ||
|
||
it("should get keys on array", () => { | ||
const flat = Flat.from({ | ||
foo: ["bar", "baz"], | ||
}); | ||
|
||
expect(flat.getKeys()).toEqual(["foo", "foo__0", "foo__1"]); | ||
}); | ||
|
||
it("should get keys on nested object", () => { | ||
const flat = Flat.from({ | ||
foo: { | ||
bar: "baz", | ||
}, | ||
}); | ||
|
||
expect(flat.getKeys()).toEqual(["foo", "foo__bar"]); | ||
}); | ||
|
||
it("should get keys on nested array", () => { | ||
const flat = Flat.from({ | ||
foo: { | ||
bar: ["baz", "qux"], | ||
}, | ||
}); | ||
|
||
expect(flat.getKeys()).toEqual([ | ||
"foo", | ||
"foo__bar", | ||
"foo__bar__0", | ||
"foo__bar__1", | ||
]); | ||
}); | ||
|
||
it("should get keys on nested object", () => { | ||
const flat = Flat.from({ | ||
foo: { | ||
bar: { | ||
baz: "qux", | ||
}, | ||
}, | ||
}); | ||
|
||
expect(flat.getKeys()).toEqual(["foo", "foo__bar", "foo__bar__baz"]); | ||
}); | ||
}); |