Sha256: ca05359f98fee940d8cfb1c536069e0e33006e0d919669c1eb7f5f7b21f5cea6

Contents?: true

Size: 1.42 KB

Versions: 31

Compression:

Stored size: 1.42 KB

Contents

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

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

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

suite.addBatch({
  "last": {
    topic: function() {
      return d3.last;
    },
    "compares using natural order by default": function(last) {
      assert.strictEqual(last([1, 0]), 1);
      assert.strictEqual(last(["1", 0]), "1");
      assert.strictEqual(last(["2", "10"]), "2");
      assert.strictEqual(last(["2", NaN, "10"]), "2");
      assert.strictEqual(last([2, NaN, 10]), 10);
    },
    "compares using optional comparator": function(last) {
      var i = 0, aa, bb, o = new Object();
      assert.strictEqual(last([1, o], function(a, b) { aa = a; bb = b; return ++i; }), 1);
      assert.strictEqual(aa, 1);
      assert.strictEqual(bb, o);
      assert.strictEqual(last([1, 0], d3.descending), 0);
      assert.strictEqual(last(["1", 0], d3.descending), 0);
      assert.strictEqual(last(["2", "10"], d3.descending), "10");
      assert.strictEqual(last(["2", NaN, "10"], d3.descending), "10");
      assert.strictEqual(last([2, NaN, 10], d3.descending), 2);
    },
    "returns the last of equal values": function(last) {
      var a = new Object(), b = new Object(), c = new Object();
      assert.strictEqual(last([a, b, c], function() { return 0; }), c);
    },
    "returns undefined for an empty array": function(last) {
      assert.isUndefined(last([]));
    }
  }
});

suite.export(module);

Version data entries

31 entries across 31 versions & 2 rubygems

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