Sha256: 6dc86a89d2e65c920f17955ee9f334c1b653e63d3b831a3644b7eb5bc4d871cc

Contents?: true

Size: 1.72 KB

Versions: 25

Compression:

Stored size: 1.72 KB

Contents

require("../env");
require("../../d3");

var vows = require("vows"),
    assert = require("assert");

var suite = vows.describe("d3.max");

suite.addBatch({
  "max": {
    topic: function() {
      return d3.max;
    },
    "returns the greatest numeric value for numbers": function(max) {
      assert.equal(max([1]), 1);
      assert.equal(max([5, 1, 2, 3, 4]), 5);
      assert.equal(max([20, 3]), 20);
      assert.equal(max([3, 20]), 20);
    },
    "returns the greatest lexicographic value for strings": function(max) {
      assert.equal(max(["c", "a", "b"]), "c");
      assert.equal(max(["20", "3"]), "3");
      assert.equal(max(["3", "20"]), "3");
    },
    "ignores null, undefined and NaN": function(max) {
      assert.equal(max([NaN, 1, 2, 3, 4, 5]), 5);
      assert.equal(max([1, 2, 3, 4, 5, NaN]), 5);
      assert.equal(max([10, null, 3, undefined, 5, NaN]), 10);
      assert.equal(max([-1, null, -3, undefined, -5, NaN]), -1);
    },
    "compares heterogenous types as numbers": function(max) {
      assert.strictEqual(max([20, "3"]), 20);
      assert.strictEqual(max(["20", 3]), "20");
      assert.strictEqual(max([3, "20"]), "20");
      assert.strictEqual(max(["3", 20]), 20);
    },
    "returns undefined for empty array": function(max) {
      assert.isUndefined(max([]));
      assert.isUndefined(max([null]));
      assert.isUndefined(max([undefined]));
      assert.isUndefined(max([NaN]));
      assert.isUndefined(max([NaN, NaN]));
    },
    "applies the optional accessor function": function(max) {
      assert.equal(d3.max([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return d3.min(d); }), 2);
      assert.equal(d3.max([1, 2, 3, 4, 5], function(d, i) { return i; }), 4);
    }
  }
});

suite.export(module);

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/test/core/max-test.js