* Remove V1 of the mod version parser and shift V2 up to be V1 * Add a parser for mod.cg files, and refactor the the mod-version.cg files to push the appropriate content up to the mod.cg * Remove the concept of "silent" from BaseModel along with logging each event as they are fired (which is what really prompted the need for it in the first place) * Move use of the Storage class to be completely the province of the controllers most closely related to models affected * Convert the ModVersionController to the ModController and have it take on responsibility for choosing the mod version * Update BaseModel to support simple accessors for the current state * Update CraftingPlan to be able to remove uncraftable items * Implement the Mod model
48 lines
1.7 KiB
CoffeeScript
48 lines
1.7 KiB
CoffeeScript
###
|
|
Crafting Guide - mod_version.test.coffee
|
|
|
|
Copyright (c) 2014-2015 by Redwood Labs
|
|
All rights reserved.
|
|
###
|
|
|
|
Item = require '../src/scripts/models/item'
|
|
ModVersion = require '../src/scripts/models/mod_version'
|
|
|
|
########################################################################################################################
|
|
|
|
modVersion = null
|
|
|
|
########################################################################################################################
|
|
|
|
describe 'ModVersion', ->
|
|
|
|
beforeEach -> modVersion = new ModVersion modSlug:'test', version:'0.0'
|
|
|
|
describe 'constructor', ->
|
|
|
|
it 'requires a mod slug', ->
|
|
expect(-> new ModVersion version:'0.0').to.throw Error, 'attributes.modSlug is required'
|
|
|
|
it 'requires a mod version', ->
|
|
expect(-> new ModVersion modSlug:'test').to.throw Error, 'attributes.version is required'
|
|
|
|
describe 'addItem', ->
|
|
|
|
it 'refuses to add duplicates', ->
|
|
modVersion.addItem new Item name:'Wool'
|
|
expect(-> modVersion.addItem new Item name:'Wool').to.throw Error, 'duplicate item for Wool'
|
|
|
|
it 'adds an item indexed by its slug', ->
|
|
modVersion.addItem new Item name:'Wool'
|
|
modVersion._items.wool.name.should.equal 'Wool'
|
|
|
|
it 'sets the modVersion', ->
|
|
modVersion.addItem new Item name:'Wool'
|
|
modVersion._items.wool.modVersion.should.equal modVersion
|
|
|
|
describe 'findItemByName', ->
|
|
|
|
it 'locates items by slugified name', ->
|
|
modVersion.addItem new Item name:'Crafting Table'
|
|
modVersion.findItemByName('Crafting Table').slug.should.equal 'crafting_table'
|