Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created May 14, 2017 06:47
Show Gist options
  • Save z3t0/217db3c777f0b574d52588f03cd23cda to your computer and use it in GitHub Desktop.
Save z3t0/217db3c777f0b574d52588f03cd23cda to your computer and use it in GitHub Desktop.
/* global describe it */
let chai = require('chai')
let assert = chai.assert
let sinon = require('sinon')
var ModLoader = require('../mod_loader.js')
describe('modLoader', function () {
var game = {empty: ''} // fake object
var modLoader = new ModLoader(game)
it('constructor(game)', () => {
assert.equal(modLoader.game, game, 'should have a reference to the game instance')
assert.isArray(modLoader.mods)
// assert.deepEqual(modLoader.mods, [], 'list of mods should be empty when starting')
})
var mod = {
name: 'Fake',
version: '0.0.1',
dependencies: [],
init: sinon.spy(),
destroy: sinon.spy(),
enable: sinon.spy(),
disable: sinon.spy()
}
it('registerMod(mod)', () => {
modLoader.registerMod(mod)
assert(mod.init.calledOnce, 'init was not called')
assert(mod.init.calledWith(game), 'was not called with game')
assert(mod.enable.notCalled, 'enable was called prematurely')
assert(mod.disable.notCalled, 'enable was called prematurely')
assert(mod.destroy.notCalled, 'destroy was called prematurely')
assert.deepEqual(modLoader.mods[0], mod, 'was not added to the mod list')
})
it('enableMod', () => {
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment