mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 01:25:42 -05:00
Fix some demo views
This commit is contained in:
parent
5941c4b27f
commit
13b9d81e4c
8 changed files with 87 additions and 25 deletions
|
@ -21,6 +21,7 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
|||
# vendor libraries aren't actually wrapped with common.js, so short circuit those requires
|
||||
return {} if _.string.startsWith(name, 'vendor/')
|
||||
return {} if name is 'tests'
|
||||
return {} if name is 'demo-app'
|
||||
name = 'core/auth' if name is 'lib/auth' # proxy for iPad until it's been updated to use the new, refactored location. TODO: remove this
|
||||
return func(name, loaderPath)
|
||||
_.extend wrapped, window.require # for functions like 'list'
|
||||
|
|
|
@ -6,6 +6,9 @@ requireUtils = require 'lib/requireUtils'
|
|||
DEMO_REQUIRE_PREFIX = 'test/demo/'
|
||||
DEMO_URL_PREFIX = '/demo/'
|
||||
|
||||
require 'vendor/jasmine-bundle'
|
||||
require 'demo-app'
|
||||
|
||||
###
|
||||
What are demo files?
|
||||
|
||||
|
@ -33,24 +36,8 @@ module.exports = DemoView = class DemoView extends RootView
|
|||
constructor: (options, @subPath='') ->
|
||||
super(options)
|
||||
@subPath = @subPath[1..] if @subPath[0] is '/'
|
||||
@loadDemoingLibs() unless DemoView.loaded
|
||||
|
||||
loadDemoingLibs: ->
|
||||
DemoView.loaded = true
|
||||
@queue = new createjs.LoadQueue()
|
||||
@queue.on('complete', @scriptsLoaded, @)
|
||||
window.jasmine = {} # so that mock-ajax properly loads. It expects jasmine to be loaded
|
||||
for f in ['mock-ajax', 'demo-app']
|
||||
@queue.loadFile({
|
||||
src: "/javascripts/#{f}.js"
|
||||
type: createjs.LoadQueue.JAVASCRIPT
|
||||
})
|
||||
|
||||
scriptsLoaded: ->
|
||||
@initDemoFiles()
|
||||
@children = requireUtils.parseImmediateChildren(@demoFiles, @subPath, DEMO_REQUIRE_PREFIX, DEMO_URL_PREFIX)
|
||||
@render()
|
||||
@runDemo()
|
||||
|
||||
# RENDER DATA
|
||||
|
||||
|
@ -62,6 +49,10 @@ module.exports = DemoView = class DemoView extends RootView
|
|||
c.currentFolder = parts[parts.length-1] or parts[parts.length-2] or 'All'
|
||||
c
|
||||
|
||||
afterInsert: ->
|
||||
super()
|
||||
@runDemo()
|
||||
|
||||
# RUNNING DEMOS
|
||||
|
||||
initDemoFiles: ->
|
||||
|
@ -82,6 +73,7 @@ module.exports = DemoView = class DemoView extends RootView
|
|||
jasmine.Ajax.install()
|
||||
view = demoFunc()
|
||||
return unless view
|
||||
@ranDemo = true
|
||||
if view instanceof ModalView
|
||||
@openModalView(view)
|
||||
else
|
||||
|
@ -97,4 +89,5 @@ module.exports = DemoView = class DemoView extends RootView
|
|||
destroy: ->
|
||||
# hack to get jasmine tests to properly run again on clicking links, and make sure if you
|
||||
# leave this page (say, back to the main site) that test stuff doesn't follow you.
|
||||
if @ranDemo
|
||||
document.location.reload()
|
||||
|
|
|
@ -130,7 +130,7 @@ exports.config =
|
|||
|
||||
#- test, demo libraries
|
||||
'javascripts/app/tests.js': regJoin('^test/app/')
|
||||
'javascripts/demo-app.js': regJoin('^test/demo/')
|
||||
'javascripts/app/demo-app.js': regJoin('^test/demo/')
|
||||
|
||||
#- More output files are generated at the below
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CocoModel = require 'models/CocoModel'
|
||||
RootView = require 'views/kinds/RootView'
|
||||
utils = require 'lib/utils'
|
||||
RootView = require 'views/core/RootView'
|
||||
utils = require 'core/utils'
|
||||
Achievement = require 'models/Achievement'
|
||||
EarnedAchievement = require 'models/EarnedAchievement'
|
||||
fixtures = require '../../fixtures/achievements'
|
||||
|
|
File diff suppressed because one or more lines are too long
47
test/demo/views/common/level-session.fixture.coffee
Normal file
47
test/demo/views/common/level-session.fixture.coffee
Normal file
File diff suppressed because one or more lines are too long
21
test/demo/views/common/level.fixture.coffee
Normal file
21
test/demo/views/common/level.fixture.coffee
Normal file
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
"_id": "53c997066567c600002a43d0",
|
||||
"name": "Dungeon Arena",
|
||||
"icon": "db/level/53173f76c269d400000543c2/11_dungeon.png",
|
||||
"banner": "db/level/53173f76c269d400000543c2/dungeon_arena.png",
|
||||
"employerDescription": "Players:\n* Attempt to destroy the enemy base.\n* Choose and control heroes to attack with.\n* Choose which types of lesser units to build and have limited control over them.\n* Try to write strategies that counter other enemy strategies.\n* Play on a small map.",
|
||||
"systems": [],
|
||||
"thangs": [],
|
||||
"scripts": [],
|
||||
"documentation": {
|
||||
"generalArticles": [],
|
||||
"specificArticles": []
|
||||
},
|
||||
"description": "This level is indescribably flarmy!",
|
||||
"version": {
|
||||
"minor": 0,
|
||||
"major": 0,
|
||||
"isLatestMajor": true,
|
||||
"isLatestMinor": true
|
||||
}
|
||||
}
|
|
@ -155,6 +155,6 @@ response =
|
|||
module.exports = ->
|
||||
view = new AddThangComponentsModal({skipOriginals:['52437c851d9e25b8dc000008']}) # FollowsNearest original
|
||||
console.log jasmine.Ajax.requests.all()
|
||||
jasmine.Ajax.requests.mostRecent().response({status: 200, responseText: JSON.stringify(response)})
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({status: 200, responseText: JSON.stringify(response)})
|
||||
view.render()
|
||||
return view
|
Loading…
Reference in a new issue