Skip to content

Instantly share code, notes, and snippets.

@lukewilde
Created April 27, 2015 11:23
Show Gist options
  • Save lukewilde/a171ee81d4116d14768a to your computer and use it in GitHub Desktop.
Save lukewilde/a171ee81d4116d14768a to your computer and use it in GitHub Desktop.
/*jshint expr: true*/
var expect = require('chai').expect;
var sinon = require('sinon');
var PaylineCommand = require('../../../../src/js/app/commands/PaylinesCommand');
var SymbolAnimsComponent = require('../../../../src/js/app/components/SymbolAnimsComponent');
var PaylinesComponent = require('../../../../src/js/app/components/PaylinesComponent');
var Command = require('../../../../src/js/app/commands/Command');
var Utils = require('../../app/utils/Utils');
var Mocks = require('../helpers/Mocks')();
describe("PaylineCommand tests", function() {
var myClass, initSpy, logSpy, symbolAnimsComponent, paylinesComponent;
before(function() {
symbolAnimsComponent = new sinon.createStubInstance(SymbolAnimsComponent);
Utils.addComponent(symbolAnimsComponent);
paylinesComponent = new sinon.createStubInstance(PaylinesComponent);
Utils.addComponent(paylinesComponent);
});
beforeEach(function() {
initSpy = sinon.spy(PaylineCommand.prototype, 'init');
logSpy = sinon.spy(console, 'log');
myClass = new PaylineCommand(Mocks.setup);
});
afterEach(function() {
PaylineCommand.prototype.init.restore();
console.log.restore();
});
after(function() {
});
describe("constructor: ", function() {
it("accepts setup object", function() {
expect(myClass.setup).to.eql(Mocks.setup);
});
it("frameLabels array is empty", function() {
expect(myClass.frameLabels).to.be.empty;
});
it("numSquares default is 0", function() {
expect(myClass.numSquares).to.equal(0);
});
it("payLineIndexes default is a single element set to 0", function() {
expect(myClass.payLineIndexes.length).to.equal(1);
expect(myClass.payLineIndexes[0]).to.equal(0);
});
});
describe("interface: ", function() {
it("Should extend base Command", function() {
expect(myClass).to.be.an.instanceof(Command);
});
});
describe("init: ", function() {
var paylineIndexes = [1, 2, 3];
var frameLabels = ["m2", "m1", "m3", "m1", "m1"];
var numSquares = 3;
it("Should override default parameters", function() {
myClass.init(paylineIndexes, frameLabels, numSquares);
expect(myClass.paylineIndexes).to.equal(paylineIndexes);
expect(myClass.numSquares).to.equal(numSquares);
expect(myClass.frameLabels).to.equal(frameLabels);
});
it("Should use default when no parameters are passed", function() {
symbolAnimsComponent.init();
expect(myClass.frameLabels).to.be.empty;
expect(myClass.numSquares).to.equal(0);
expect(myClass.payLineIndexes.length).to.equal(1);
expect(myClass.payLineIndexes[0]).to.equal(0);
expect(myClass).to.be.an.instanceof(Command);
});
});
describe("execute", function() {
var paylineIndexes = [1, 2, 3];
var frameLabels = ["m2", "m1", "m3", "m1", "m1"];
var numSquares = 3;
beforeEach(function() {
myClass.init(paylineIndexes, frameLabels, numSquares);
myClass.execute();
});
it("should show animations for each payline", function() {
expect(symbolAnimsComponent.playAnims.withArgs(paylineIndexes[0], 0, frameLabels).calledOnce);
expect(symbolAnimsComponent.playAnims.withArgs(paylineIndexes[1], 0, frameLabels).calledOnce);
expect(symbolAnimsComponent.playAnims.withArgs(paylineIndexes[2], 0, frameLabels).calledOnce);
});
it("should hide all currently displaying paylines", function() {
});
it("should show new payline", function() {
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment