-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
100 lines (76 loc) · 2.26 KB
/
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
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
// tests for viewbox helper library
'use strict'
var expect = require('chai').expect
var viewbox = require('./')
describe('viewbox', function() {
it('should be able to create a new viewbox', function() {
var result = viewbox.create()
expect(result).to.eql([])
})
it('should be able to add two viewboxes', function() {
var box1 = [0, -1, 4, 5]
var box2 = [-3, 1, 2, 6]
var result = viewbox.add(box1, box2)
expect(result).to.eql([-3, -1, 7, 8])
})
it('should be able to add a viewbox to a new viewbox', function() {
var box1 = viewbox.create()
var box2 = [-3, 1, 2, 6]
var result = viewbox.add(box1, box2)
expect(result).to.eql([-3, 1, 2, 6])
})
it('should be able to add a new viewbox to a viewbox', function() {
var box1 = [0, -1, 4, 5]
var box2 = viewbox.create()
var result = viewbox.add(box1, box2)
expect(result).to.eql([0, -1, 4, 5])
})
it('should be able to scale a viewbox', function() {
var box = [-1.5, 0.5, 1, 3]
var result = viewbox.scale(box, 2)
expect(result).to.eql([-3, 1, 2, 6])
})
it('should be able to generate attributes for an SVG rectangle', function() {
var box = [0, -1, 4, 5]
var result = viewbox.rect(box)
expect(result).to.eql({
x: 0,
y: -1,
width: 4,
height: 5
})
})
it('should output a 0 size rectangle for a new viewbox', function() {
var box = viewbox.create()
var result = viewbox.rect(box)
expect(result).to.eql({
x: 0,
y: 0,
width: 0,
height: 0
})
})
it('should output a 0 size rectangle for something falsey', function() {
var result = viewbox.rect()
expect(result).to.eql({
x: 0,
y: 0,
width: 0,
height: 0
})
})
it('should be able to generate a viewbox string', function() {
var box = [1, 2, 3, 4]
var result = viewbox.asString(box)
expect(result).to.equal('1 2 3 4')
})
it('should output a new viewbox as a 0 size viewbox string', function() {
var box = viewbox.create()
var result = viewbox.asString(box)
expect(result).to.equal('0 0 0 0')
})
it('should output something falsey as a 0 size viewbox string', function() {
var result = viewbox.asString()
expect(result).to.equal('0 0 0 0')
})
})