File: areaRadial-test.js

package info (click to toggle)
node-d3-shape 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,388 kB
  • sloc: makefile: 11; sh: 2
file content (85 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download | duplicates (3)
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
var tape = require("tape"),
    shape = require("../");

require("./pathEqual");

tape("areaRadial() returns a default radial area shape", function(test) {
  var a = shape.areaRadial();
  test.equal(a.startAngle()([42, 34]), 42);
  test.equal(a.endAngle(), null);
  test.equal(a.innerRadius()([42, 34]), 0);
  test.equal(a.outerRadius()([42, 34]), 34);
  test.equal(a.defined()([42, 34]), true);
  test.equal(a.curve(), shape.curveLinear);
  test.equal(a.context(), null);
  test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,-1L2.727892,1.248441L-3.784012,3.268218L0,0L0,0L0,0Z");
  test.end();
});

tape("areaRadial.lineStartAngle() returns a line derived from the area", function(test) {
  var defined = function() { return true; },
      curve = shape.curveCardinal,
      context = {},
      startAngle = function() {},
      endAngle = function() {},
      radius = function() {},
      a = shape.areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle),
      l = a.lineStartAngle();
  test.equal(l.defined(), defined);
  test.equal(l.curve(), curve);
  test.equal(l.context(), context);
  test.equal(l.angle(), startAngle);
  test.equal(l.radius(), radius);
  test.end();
});

tape("areaRadial.lineEndAngle() returns a line derived from the area", function(test) {
  var defined = function() { return true; },
      curve = shape.curveCardinal,
      context = {},
      startAngle = function() {},
      endAngle = function() {},
      radius = function() {},
      a = shape.areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle),
      l = a.lineEndAngle();
  test.equal(l.defined(), defined);
  test.equal(l.curve(), curve);
  test.equal(l.context(), context);
  test.equal(l.angle(), endAngle);
  test.equal(l.radius(), radius);
  test.end();
});

tape("areaRadial.lineInnerRadius() returns a line derived from the area", function(test) {
  var defined = function() { return true; },
      curve = shape.curveCardinal,
      context = {},
      angle = function() {},
      innerRadius = function() {},
      outerRadius = function() {},
      a = shape.areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius),
      l = a.lineInnerRadius();
  test.equal(l.defined(), defined);
  test.equal(l.curve(), curve);
  test.equal(l.context(), context);
  test.equal(l.angle(), angle);
  test.equal(l.radius(), innerRadius);
  test.end();
});

tape("areaRadial.lineOuterRadius() returns a line derived from the area", function(test) {
  var defined = function() { return true; },
      curve = shape.curveCardinal,
      context = {},
      angle = function() {},
      innerRadius = function() {},
      outerRadius = function() {},
      a = shape.areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius),
      l = a.lineOuterRadius();
  test.equal(l.defined(), defined);
  test.equal(l.curve(), curve);
  test.equal(l.context(), context);
  test.equal(l.angle(), angle);
  test.equal(l.radius(), outerRadius);
  test.end();
});