Make Studio load XBlock fragment js and css on the client-side
[LMS-1421][LMS-1517]
This commit is contained in:
@@ -2,9 +2,9 @@ describe "XBlock", ->
|
||||
beforeEach ->
|
||||
setFixtures """
|
||||
<div>
|
||||
<div class='xblock' id='vA' data-runtime-version="A" data-init="initFnA" data-name="a-name"/>
|
||||
<div class='xblock' id='vA' data-runtime-version="A" data-runtime-class="TestRuntime" data-init="initFnA" data-name="a-name"/>
|
||||
<div>
|
||||
<div class='xblock' id='vZ' data-runtime-version="Z" data-init="initFnZ"/>
|
||||
<div class='xblock' id='vZ' data-runtime-version="Z" data-runtime-class="TestRuntime" data-init="initFnZ"/>
|
||||
</div>
|
||||
<div class='xblock' id='missing-version' data-init='initFnA' data-name='no-version'/>
|
||||
<div class='xblock' id='missing-init' data-runtime-version="A" data-name='no-init'/>
|
||||
@@ -13,8 +13,11 @@ describe "XBlock", ->
|
||||
|
||||
describe "initializeBlock", ->
|
||||
beforeEach ->
|
||||
XBlock.runtime.vA = jasmine.createSpy().andReturn('runtimeA')
|
||||
XBlock.runtime.vZ = jasmine.createSpy().andReturn('runtimeZ')
|
||||
window.TestRuntime = {}
|
||||
@runtimeA = {name: 'runtimeA'}
|
||||
@runtimeZ = {name: 'runtimeZ'}
|
||||
TestRuntime.vA = jasmine.createSpy().andReturn(@runtimeA)
|
||||
TestRuntime.vZ = jasmine.createSpy().andReturn(@runtimeZ)
|
||||
|
||||
window.initFnA = jasmine.createSpy()
|
||||
window.initFnZ = jasmine.createSpy()
|
||||
@@ -28,12 +31,12 @@ describe "XBlock", ->
|
||||
@missingInitBlock = XBlock.initializeBlock($('#missing-init')[0])
|
||||
|
||||
it "loads the right runtime version", ->
|
||||
expect(XBlock.runtime.vA).toHaveBeenCalledWith($('#vA')[0], @fakeChildren)
|
||||
expect(XBlock.runtime.vZ).toHaveBeenCalledWith($('#vZ')[0], @fakeChildren)
|
||||
expect(TestRuntime.vA).toHaveBeenCalledWith($('#vA')[0], @fakeChildren)
|
||||
expect(TestRuntime.vZ).toHaveBeenCalledWith($('#vZ')[0], @fakeChildren)
|
||||
|
||||
it "loads the right init function", ->
|
||||
expect(window.initFnA).toHaveBeenCalledWith('runtimeA', $('#vA')[0])
|
||||
expect(window.initFnZ).toHaveBeenCalledWith('runtimeZ', $('#vZ')[0])
|
||||
expect(window.initFnA).toHaveBeenCalledWith(@runtimeA, $('#vA')[0])
|
||||
expect(window.initFnZ).toHaveBeenCalledWith(@runtimeZ, $('#vZ')[0])
|
||||
|
||||
it "loads when missing versions", ->
|
||||
expect(@missingVersionBlock.element).toBe($('#missing-version'))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe "XBlock.runtime.v1", ->
|
||||
describe "XBlock.Runtime.v1", ->
|
||||
beforeEach ->
|
||||
setFixtures """
|
||||
<div class='xblock' data-handler-prefix='/xblock/fake-usage-id/handler'/>
|
||||
@@ -10,9 +10,7 @@ describe "XBlock.runtime.v1", ->
|
||||
|
||||
@element = $('.xblock')[0]
|
||||
|
||||
@runtime = XBlock.runtime.v1(@element, @children)
|
||||
it "provides a handler url", ->
|
||||
expect(@runtime.handlerUrl(@element, 'foo')).toBe('/xblock/fake-usage-id/handler/foo')
|
||||
@runtime = new XBlock.Runtime.v1(@element, @children)
|
||||
|
||||
it "provides a list of children", ->
|
||||
expect(@runtime.children).toBe(@children)
|
||||
|
||||
Reference in New Issue
Block a user