Commit 376da9f8 authored by Juan Corona's avatar Juan Corona

Remove `Annotator` from the relevant tests

parent a5a8fdc0
CrossFrame = require('../cross-frame') proxyquire = require('proxyquire')
Plugin = require('../../plugin')
CrossFrame = null
describe 'Annotator.Plugin.CrossFrame', -> describe 'Annotator.Plugin.CrossFrame', ->
fakeDiscovery = null fakeDiscovery = null
fakeBridge = null fakeBridge = null
fakeAnnotationSync = null fakeAnnotationSync = null
proxyDiscovery = null
proxyBridge = null
proxyAnnotationSync = null
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
createCrossFrame = (options) -> createCrossFrame = (options) ->
...@@ -28,9 +36,17 @@ describe 'Annotator.Plugin.CrossFrame', -> ...@@ -28,9 +36,17 @@ describe 'Annotator.Plugin.CrossFrame', ->
fakeAnnotationSync = fakeAnnotationSync =
sync: sandbox.stub() sync: sandbox.stub()
CrossFrame.AnnotationSync = sandbox.stub().returns(fakeAnnotationSync) proxyAnnotationSync = sandbox.stub().returns(fakeAnnotationSync)
CrossFrame.Discovery = sandbox.stub().returns(fakeDiscovery) proxyDiscovery = sandbox.stub().returns(fakeDiscovery)
CrossFrame.Bridge = sandbox.stub().returns(fakeBridge) proxyBridge = sandbox.stub().returns(fakeBridge)
CrossFrame = proxyquire('../cross-frame', {
'../plugin': Plugin,
'../annotation-sync': proxyAnnotationSync,
'../../shared/bridge': proxyBridge,
'../../shared/discovery': proxyDiscovery
})
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
...@@ -38,23 +54,23 @@ describe 'Annotator.Plugin.CrossFrame', -> ...@@ -38,23 +54,23 @@ describe 'Annotator.Plugin.CrossFrame', ->
describe 'CrossFrame constructor', -> describe 'CrossFrame constructor', ->
it 'instantiates the Discovery component', -> it 'instantiates the Discovery component', ->
createCrossFrame() createCrossFrame()
assert.calledWith(CrossFrame.Discovery, window) assert.calledWith(proxyDiscovery, window)
it 'passes the options along to the bridge', -> it 'passes the options along to the bridge', ->
createCrossFrame(server: true) createCrossFrame(server: true)
assert.calledWith(CrossFrame.Discovery, window, server: true) assert.calledWith(proxyDiscovery, window, server: true)
it 'instantiates the CrossFrame component', -> it 'instantiates the CrossFrame component', ->
createCrossFrame() createCrossFrame()
assert.calledWith(CrossFrame.Discovery) assert.calledWith(proxyDiscovery)
it 'instantiates the AnnotationSync component', -> it 'instantiates the AnnotationSync component', ->
createCrossFrame() createCrossFrame()
assert.called(CrossFrame.AnnotationSync) assert.called(proxyAnnotationSync)
it 'passes along options to AnnotationSync', -> it 'passes along options to AnnotationSync', ->
createCrossFrame() createCrossFrame()
assert.calledWith(CrossFrame.AnnotationSync, fakeBridge, { assert.calledWith(proxyAnnotationSync, fakeBridge, {
on: sinon.match.func on: sinon.match.func
emit: sinon.match.func emit: sinon.match.func
}) })
......
Annotator = require('annotator')
proxyquire = require('proxyquire') proxyquire = require('proxyquire')
adder = require('../adder') adder = require('../adder')
Observable = require('../util/observable').Observable Observable = require('../util/observable').Observable
$ = Annotator.$ Delegator = require('../delegator')
Annotator['@noCallThru'] = true; $ = require('jquery')
Delegator['@noCallThru'] = true
Guest = null Guest = null
anchoring = {} anchoring = {}
...@@ -37,10 +37,12 @@ describe 'Guest', -> ...@@ -37,10 +37,12 @@ describe 'Guest', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
guestOptions = {pluginClasses: {}}
createGuest = (options) -> createGuest = (options={}) ->
options = Object.assign({}, guestOptions, options)
element = document.createElement('div') element = document.createElement('div')
return new Guest(element, options || {}) return new Guest(element, options)
beforeEach -> beforeEach ->
FakeAdder::instance = null FakeAdder::instance = null
...@@ -60,7 +62,7 @@ describe 'Guest', -> ...@@ -60,7 +62,7 @@ describe 'Guest', ->
selections = obs selections = obs
return () -> return () ->
) )
'annotator': Annotator, './delegator': Delegator,
'raf': raf, 'raf': raf,
'scroll-into-view': scrollIntoView, 'scroll-into-view': scrollIntoView,
}) })
...@@ -73,11 +75,10 @@ describe 'Guest', -> ...@@ -73,11 +75,10 @@ describe 'Guest', ->
CrossFrame = sandbox.stub() CrossFrame = sandbox.stub()
CrossFrame.returns(fakeCrossFrame) CrossFrame.returns(fakeCrossFrame)
Annotator.Plugin.CrossFrame = CrossFrame guestOptions.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
delete Annotator.Plugin.CrossFrame
describe 'cross frame', -> describe 'cross frame', ->
......
Annotator = require('annotator')
proxyquire = require('proxyquire') proxyquire = require('proxyquire')
Host = proxyquire('../host', { Host = proxyquire('../host', {})
'annotator': Annotator,
})
describe 'Host', -> describe 'Host', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
hostOptions = {pluginClasses: {}}
createHost = (options={}, element=null) -> createHost = (options={}, element=null) ->
options = Object.assign({app: '/base/annotator/test/empty.html'}, options) options = Object.assign({app: '/base/annotator/test/empty.html'}, hostOptions, options)
if !element if !element
element = document.createElement('div') element = document.createElement('div')
return new Host(element, options) return new Host(element, options)
...@@ -27,11 +24,10 @@ describe 'Host', -> ...@@ -27,11 +24,10 @@ describe 'Host', ->
CrossFrame = sandbox.stub() CrossFrame = sandbox.stub()
CrossFrame.returns(fakeCrossFrame) CrossFrame.returns(fakeCrossFrame)
Annotator.Plugin.CrossFrame = CrossFrame hostOptions.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
delete Annotator.Plugin.CrossFrame
describe 'widget visibility', -> describe 'widget visibility', ->
it 'starts hidden', -> it 'starts hidden', ->
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
'use strict'; 'use strict';
var Annotator = require('annotator');
var unroll = require('../../../shared/test/util').unroll; var unroll = require('../../../shared/test/util').unroll;
var Guest = require('../../guest'); var Guest = require('../../guest');
...@@ -48,17 +46,18 @@ function FakeCrossFrame() { ...@@ -48,17 +46,18 @@ function FakeCrossFrame() {
describe('anchoring', function () { describe('anchoring', function () {
var guest; var guest;
var guestOptions;
var container; var container;
before(function () { before(function () {
Annotator.Plugin.CrossFrame = FakeCrossFrame; guestOptions = {pluginClasses: {CrossFrame: FakeCrossFrame}};
}); });
beforeEach(function () { beforeEach(function () {
container = document.createElement('div'); container = document.createElement('div');
container.innerHTML = require('./test-page.html'); container.innerHTML = require('./test-page.html');
document.body.appendChild(container); document.body.appendChild(container);
guest = new Guest(container); guest = new Guest(container, guestOptions);
}); });
afterEach(function () { afterEach(function () {
......
Annotator = require('annotator')
events = require('../../shared/bridge-events') events = require('../../shared/bridge-events')
proxyquire = require('proxyquire') proxyquire = require('proxyquire')
Sidebar = proxyquire('../sidebar', { Sidebar = proxyquire('../sidebar', {})
'annotator': Annotator,
})
describe 'Sidebar', -> describe 'Sidebar', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
sidebarOptions = {pluginClasses: {}}
createSidebar = (options={}) -> createSidebar = (options={}) ->
options = Object.assign({}, sidebarOptions, options)
element = document.createElement('div') element = document.createElement('div')
return new Sidebar(element, options) return new Sidebar(element, options)
...@@ -23,11 +22,10 @@ describe 'Sidebar', -> ...@@ -23,11 +22,10 @@ describe 'Sidebar', ->
CrossFrame = sandbox.stub() CrossFrame = sandbox.stub()
CrossFrame.returns(fakeCrossFrame) CrossFrame.returns(fakeCrossFrame)
Annotator.Plugin.CrossFrame = CrossFrame sidebarOptions.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
delete Annotator.Plugin.CrossFrame
describe 'crossframe listeners', -> describe 'crossframe listeners', ->
emitEvent = (event, args...) -> emitEvent = (event, args...) ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment