-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheither-pratices.spec.js
More file actions
38 lines (31 loc) · 1.19 KB
/
either-pratices.spec.js
File metadata and controls
38 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const {
street,
streetName,
parseDbUrl,
startApp,
} = require("./either-pratices")
it("should return the the street or a left", () => {
const user = { address: { street: { name: "Willow" } } }
expect(street(user)).toEqual({ name: "Willow" })
expect(street({})).toBe("no street")
})
it("should return the street name or a left", () => {
const user = { address: { street: { name: "Willow" } } }
expect(streetName(user)).toBe("Willow")
expect(streetName({})).toBe("no street")
expect(streetName({ address: { street: null } })).toBe("no street")
})
it("should parse the dbUrl or return a null ", () => {
const config = '{"url": "postgres://sally:muppets@localhost:5432/mydb"}'
expect(parseDbUrl(config)[1]).toBe("sally")
expect(parseDbUrl()).toBe(null)
})
it("should start the app or return a error message", () => {
const config = '{"url": "postgres://sally:muppets@localhost:5432/mydb"}'
expect(startApp(config)).toBe("starting mydb, sally, muppets")
expect(startApp()).toBe("can't get config")
})
// QUnit.test("Ex3: startApp", assert => {
// assert.equal(String(startApp(config)), "starting mydb, sally, muppets")
// assert.equal(String(startApp()), "can't get config")
// })