~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/test/layout/cluster-test.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require("../env");
2
 
 
3
 
var vows = require("vows"),
4
 
    assert = require("assert");
5
 
 
6
 
var suite = vows.describe("d3.layout.cluster");
7
 
 
8
 
suite.addBatch({
9
 
  "cluster": {
10
 
    topic: d3.layout.cluster,
11
 
    "can handle an empty children array": function(cluster) {
12
 
      assert.deepEqual(cluster.nodes({value: 1, children: [{value: 1, children: []}, {value: 1}]}).map(layout), [
13
 
        {value: 1, depth: 0, x: 0.5,  y: 0},
14
 
        {value: 1, depth: 1, x: 0.25, y: 1},
15
 
        {value: 1, depth: 1, x: 0.75, y: 1}
16
 
      ]);
17
 
    },
18
 
    "can handle zero-valued nodes": function(cluster) {
19
 
      assert.deepEqual(cluster.nodes({value: 0, children: [{value: 0}, {value: 1}]}).map(layout), [
20
 
        {value: 0, depth: 0, x: 0.5,  y: 0},
21
 
        {value: 0, depth: 1, x: 0.25, y: 1},
22
 
        {value: 1, depth: 1, x: 0.75, y: 1}
23
 
      ]);
24
 
    },
25
 
    "can handle a single node": function(cluster) {
26
 
      assert.deepEqual(cluster.nodes({value: 0}).map(layout), [
27
 
        {value: 0, depth: 0, x: 0.5,  y: 0}
28
 
      ]);
29
 
    }
30
 
  }
31
 
});
32
 
 
33
 
function layout(node) {
34
 
  return {
35
 
    value: node.value,
36
 
    depth: node.depth,
37
 
    x: node.x,
38
 
    y: node.y
39
 
  };
40
 
}
41
 
 
42
 
suite.export(module);