1 | var tape = require('tape-catch'),
|
2 | jsdom = require('jsdom'),
|
3 | d3 = require('../build/d3-er')
|
4 |
|
5 |
|
6 | tape('d3 creates an svg element', function (test) {
|
7 | var document = jsdom.jsdom()
|
8 | global.document = document
|
9 | var svg = d3.svg('body')
|
10 | test.ok(svg, 'svg element exists')
|
11 | delete global.document
|
12 | test.end()
|
13 | })
|
14 |
|
15 | tape('d3 can set height and with on svg element', function (test) {
|
16 | var document = jsdom.jsdom()
|
17 | global.document = document
|
18 | var svg = d3.svg('body', {
|
19 | width: 100,
|
20 | height: 50
|
21 | })
|
22 | test.ok(svg, 'svg element exists')
|
23 | test.ok(svg.attr('width', 100), 'svg element has correct width')
|
24 | test.ok(svg.attr('height', 50), 'svg element has correct height')
|
25 | delete global.document
|
26 | test.end()
|
27 | })
|
28 |
|
29 | tape('d3 can set height and width and margin on svg element', function (test) {
|
30 | var document = jsdom.jsdom()
|
31 | global.document = document
|
32 |
|
33 | var svg = d3.svg('body', {
|
34 | width: 100,
|
35 | height: 50,
|
36 | margin: {
|
37 | top: 1,
|
38 | right: 1,
|
39 | bottom: 1,
|
40 | left: 1
|
41 | }
|
42 | })
|
43 | test.ok(svg, 'svg element exists')
|
44 | test.ok(svg.attr('width', 102), 'svg element has correct width with margins included')
|
45 | test.ok(svg.attr('height', 52), 'svg element has correct height with margins included')
|
46 | delete global.document
|
47 | test.end()
|
48 | })
|
49 |
|
50 | tape('d3 creates an svg element that can be appended to', function (test) {
|
51 | var document = jsdom.jsdom()
|
52 | global.document = document
|
53 | var svg = d3.svg('body')
|
54 | var g = svg.append('g')
|
55 | test.ok(g, 'g element exists')
|
56 | delete global.document
|
57 | test.end()
|
58 | }) |
\ | No newline at end of file |