Skip to content

Commit 13eec84

Browse files
committed
Added tests
1 parent 9264599 commit 13eec84

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"build:dev": "webpack",
2727
"test": "npm run build:prod && jest",
2828
"test:dev": "npm run build:dev && jest",
29+
"test:debug": "node --inspect=9229 node_modules/jest/bin/jest.js --runInBand",
2930
"prepublishOnly": "npm run build:prod",
3031
"prepare": "jest --clearCache",
3132
"release": "npm publish dist"
3233
}
33-
}
34+
}

test/index.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import arrayToObjectKeys from "../dist"
2+
3+
it("should run with 1 argument", () => {
4+
const result = arrayToObjectKeys(["a", "b"])
5+
expect(result).toEqual({
6+
a: null,
7+
b: null,
8+
})
9+
})
10+
11+
it("should run with an integer as second argument", () => {
12+
const result = arrayToObjectKeys(["a", "b"], 7)
13+
expect(result).toEqual({
14+
a: 7,
15+
b: 7,
16+
})
17+
})
18+
19+
it("should run with a function as second argument", () => {
20+
const valueGenerator = (key, index) => `${index + 1}-${key}-x`
21+
const result = arrayToObjectKeys(["a", "b"], valueGenerator)
22+
expect(result).toEqual({
23+
a: "1-a-x",
24+
b: "2-b-x",
25+
})
26+
})

0 commit comments

Comments
 (0)