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