-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathnote.test.js
53 lines (42 loc) · 1.12 KB
/
note.test.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import alignment from "../src/Note/alignment"
import { assign } from "./utils"
describe("Note-alignment", function() {
const set = {
bbox: {
x: 0,
y: 0,
width: 100,
height: 50
},
orientation: "top"
}
let a
it("stays if orientation is top", function() {
a = alignment(set)
expect(a.x).toEqual(-0)
expect(a.y).toEqual(-50)
a = alignment(
assign(set, { orientation: "topBottom", offset: { x: 0, y: -100 } })
)
expect(a.x).toEqual(-0)
expect(a.y).toEqual(-50)
})
it("stays if orientation is left", function() {
a = alignment(assign(set, { orientation: "left" }))
expect(a.x).toEqual(-100)
expect(a.y).toEqual(0)
})
it("honors alignment", function() {
a = alignment(assign(set, { align: "right" }))
expect(a.x).toEqual(-100)
expect(a.y).toEqual(-50)
})
it("honors padding", function() {
a = alignment(assign(set, { padding: 20 }))
expect(a.x).toEqual(-0)
expect(a.y).toEqual(-70)
a = alignment(assign(set, { padding: 20, orientation: "left" }))
expect(a.x).toEqual(-120)
expect(a.y).toEqual(0)
})
})