Sha256: 83244d66eb57fa0ed81aca8c08e1c79b6eab10e54c4f811f9c2b591c99a54c45
Contents?: true
Size: 794 Bytes
Versions: 3
Compression:
Stored size: 794 Bytes
Contents
describe("corkboard/lib/weighted_randomizer.js", function() { it("defines $.corkboard.WeightedRandomizer", function() { expect($.corkboard.WeightedRandomizer).toBeDefined(); }); describe("WeightedRandomizer", function() { var constructor = $.corkboard.WeightedRandomizer; describe("constructor", function() { it("normalizes the setup data", function() { var instance = new constructor({ one : 2, two : 8 }); expect(instance.normalized).toEqual({ one : 0.2, two : 0.8 }); }); }); describe("#sample", function() { it("returns a selection from the setup, weighted by value", function() { var instance = new constructor({ one : 0, two : 1000000 }); expect(instance.sample()).toEqual('two'); }); }); }); });
Version data entries
3 entries across 3 versions & 1 rubygems