Add data from crafting-guide
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
###
|
||||
Crafting Guide - data.test.coffee
|
||||
|
||||
Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
{Mod} = require 'crafting-guide'
|
||||
{ModParser} = require 'crafting-guide'
|
||||
{ModVersion} = require 'crafting-guide'
|
||||
{ModVersionParser} = require 'crafting-guide'
|
||||
fs = require 'fs'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
describe 'data files for', ->
|
||||
|
||||
for modSlug in fs.readdirSync './data/'
|
||||
do (modSlug)->
|
||||
describe modSlug, ->
|
||||
|
||||
mod = new Mod slug:modSlug
|
||||
modParser = new ModParser model:mod, showAllErrors:true
|
||||
modParser.parse fs.readFileSync "./data/#{modSlug}/mod.cg", 'utf8'
|
||||
|
||||
it 'loads mod.cg without errors', ->
|
||||
modParser.errors.should.eql []
|
||||
mod.name.should.not.equal ''
|
||||
mod.activeModVersion.should.exist
|
||||
|
||||
it 'has an icon file', ->
|
||||
stats = fs.statSync "./data/#{modSlug}/icon.png"
|
||||
stats.isFile().should.be.true
|
||||
|
||||
mod.eachModVersion (modVersion)->
|
||||
do (modVersion)->
|
||||
describe modVersion.version, ->
|
||||
|
||||
modVersionParser = new ModVersionParser model:modVersion#, showAllErrors:true
|
||||
fileName = "./data/#{modSlug}/versions/#{modVersion.version}/mod-version.cg"
|
||||
modVersionParser.parse fs.readFileSync fileName, 'utf8'
|
||||
|
||||
it 'loads mod-version.cg without errors', ->
|
||||
try
|
||||
modVersionParser.errors.should.eql []
|
||||
_.keys(modVersion._items).length.should.be.greaterThan 0
|
||||
_.keys(modVersion._recipes).length.should.be.greaterThan 0
|
||||
catch e
|
||||
console.error e
|
||||
@@ -0,0 +1,28 @@
|
||||
###
|
||||
# Crafting Guide - event_recorder.coffee
|
||||
#
|
||||
# Copyright (c) 2014-2015 by Redwood Labs
|
||||
# All rights reserved.
|
||||
###
|
||||
|
||||
util = require 'util'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class EventRecorder
|
||||
|
||||
constructor: (model)->
|
||||
if not model? then throw new Error 'model is required'
|
||||
|
||||
@model = model
|
||||
@events = []
|
||||
|
||||
Object.defineProperty this, 'names', get:-> e.event for e in @events
|
||||
|
||||
@model.on 'all', (event, model, args...)=>
|
||||
logger.verbose -> "#{model?.constructor?.name}(#{model?.cid}) emitted #{event}
|
||||
with args: #{util.inspect(args)}"
|
||||
@events.push id:model?.cid, event:event, args:args
|
||||
|
||||
reset: ->
|
||||
@events = []
|
||||
@@ -0,0 +1,24 @@
|
||||
###
|
||||
# Crafting Guide - test.coffee
|
||||
#
|
||||
# Copyright (c) 2014-2015 by Redwood Labs
|
||||
# All rights reserved.
|
||||
###
|
||||
|
||||
# Test Set-up ##########################################################################################################
|
||||
|
||||
chai = require 'chai'
|
||||
chai.use require 'sinon-chai'
|
||||
chai.config.includeStack = true
|
||||
|
||||
global._ = require 'underscore'
|
||||
global.Backbone = require 'backbone'
|
||||
global.assert = chai.assert
|
||||
global.expect = chai.expect
|
||||
global.should = chai.should()
|
||||
global.util = require 'util'
|
||||
global.w = require 'when'
|
||||
global.window = {}
|
||||
|
||||
{Logger} = require 'crafting-guide-common'
|
||||
global.logger = new Logger level:Logger.FATAL
|
||||
Reference in New Issue
Block a user