forked from svgdotjs/svg.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup.js
More file actions
executable file
·108 lines (95 loc) · 2.88 KB
/
Copy pathgroup.js
File metadata and controls
executable file
·108 lines (95 loc) · 2.88 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
describe('Group', function() {
var group
beforeEach(function() {
group = draw.group()
group.rect(100,100)
})
afterEach(function() {
draw.clear()
})
describe('x()', function() {
it('returns the value of x without an argument', function() {
expect(group.x()).toBe(0)
})
it('sets the value of x with the first argument', function() {
group.x(123)
var box = group.bbox()
expect(box.x).toBe(123)
})
it('sets the value of x correctly when called multiple times', function() {
group.x(10).x(100).x(13)
var box = group.bbox()
expect(box.x).toBe(13)
})
})
describe('y()', function() {
it('returns the value of y without an argument', function() {
expect(group.y()).toBe(0)
})
it('sets the value of y with the first argument', function() {
group.y(345)
var box = group.bbox()
expect(box.y).toBe(345)
})
it('sets the value of y correctly when called multiple times', function() {
group.y(1).y(10).y(15)
var box = group.bbox()
expect(box.y).toBe(15)
})
})
describe('cx()', function() {
it('returns the value of cx without an argument', function() {
expect(group.cx()).toBe(50)
})
it('sets the value of cx with the first argument', function() {
group.cx(123)
var box = group.bbox()
expect(box.cx).toBe(123)
})
})
describe('cy()', function() {
it('returns the value of cy without an argument', function() {
expect(group.cy()).toBe(50)
})
it('sets the value of cy with the first argument', function() {
group.cy(345)
var box = group.bbox()
expect(box.cy).toBe(345)
})
})
describe('move()', function() {
it('sets the x and y position', function() {
group.move(123,456)
expect(group.node.getAttribute('transform')).toBe('matrix(1,0,0,1,123,456)')
})
})
describe('center()', function() {
it('sets the cx and cy position', function() {
group.center(321,567)
var box = group.bbox()
expect(box.cx).toBe(321)
expect(box.cy).toBe(567)
})
})
describe('dx()', function() {
it('moves the x positon of the element relative to the current position', function() {
group.move(50,60)
group.dx(100)
expect(group.node.getAttribute('transform')).toBe('matrix(1,0,0,1,150,60)')
})
})
describe('dy()', function() {
it('moves the y positon of the element relative to the current position', function() {
group.move(50,60)
group.dy(120)
expect(group.node.getAttribute('transform')).toBe('matrix(1,0,0,1,50,180)')
})
})
describe('dmove()', function() {
it('moves the x and y positon of the element relative to the current position', function() {
group.move(50, 60)
group.dmove(80, 25)
expect(group.node.getAttribute('transform')).toBe('matrix(1,0,0,1,130,85)')
})
})
})