Example #1
0
    it('allows the user to randomize the output order', function() {
      var shuffle = sinon.stub(_, 'shuffle');
      shuffle.onFirstCall().returns([out2, out1, out4, out3]);

      transaction._changeIndex.should.equal(3);
      transaction.shuffleOutputs();
      transaction.outputs[0].should.equal(out2);
      transaction.outputs[1].should.equal(out1);
      transaction.outputs[2].should.equal(out4);
      transaction.outputs[3].should.equal(out3);
      transaction._changeIndex.should.equal(2);

      _.shuffle.restore();
    });
Example #2
0
        it('should return a random powerUp constructor', function () {
            var called = 0;
            sinon.stub(_, 'shuffle', function () {
                var powerUps = [
                    InvinciblePowerUp,
                    FoodPointMultiplierPowerUp
                ];
                if (called) {
                    powerUps.reverse();
                }
                called++;
                return powerUps;
            });
            game.getRandomPowerUpConstructor().should.eql(InvinciblePowerUp);
            game.getRandomPowerUpConstructor().should.eql(FoodPointMultiplierPowerUp);

            _.shuffle.restore();
        });