Commit e0670e4c authored by Robert Knight's avatar Robert Knight

Convert mocking from proxyquire to mockable-imports

Convert proxyquire mocking of several CoffeeScript modules.
parent 6a9248a8
proxyquire = require('proxyquire')
Plugin = require('../../plugin')
CrossFrame = null
CrossFrame = require('../cross-frame')
describe 'CrossFrame', ->
fakeDiscovery = null
......@@ -41,16 +39,16 @@ describe 'CrossFrame', ->
proxyDiscovery = sandbox.stub().returns(fakeDiscovery)
proxyBridge = sandbox.stub().returns(fakeBridge)
CrossFrame = proxyquire('../cross-frame', {
CrossFrame.$imports.$mock({
'../plugin': Plugin,
'../annotation-sync': proxyAnnotationSync,
'../../shared/bridge': proxyBridge,
'../../shared/discovery': proxyDiscovery
})
afterEach ->
sandbox.restore()
CrossFrame.$imports.$restore()
describe 'CrossFrame constructor', ->
it 'instantiates the Discovery component', ->
......
proxyquire = require('proxyquire')
Host = proxyquire('../host', {})
Host = require('../host')
describe 'Host', ->
sandbox = sinon.sandbox.create()
......
'use strict';
const proxyquire = require('proxyquire');
const isLoaded = require('../../util/frame-util').isLoaded;
const FRAME_DEBOUNCE_WAIT = require('../../frame-observer').DEBOUNCE_WAIT + 10;
const CrossFrame = require('../../plugin/cross-frame');
describe('CrossFrame multi-frame scenario', function() {
let fakeAnnotationSync;
......@@ -30,7 +30,7 @@ describe('CrossFrame multi-frame scenario', function() {
proxyAnnotationSync = sandbox.stub().returns(fakeAnnotationSync);
proxyBridge = sandbox.stub().returns(fakeBridge);
const CrossFrame = proxyquire('../../plugin/cross-frame', {
CrossFrame.$imports.$mock({
'../annotation-sync': proxyAnnotationSync,
'../../shared/bridge': proxyBridge,
});
......@@ -53,6 +53,8 @@ describe('CrossFrame multi-frame scenario', function() {
sandbox.restore();
crossFrame.destroy();
container.parentNode.removeChild(container);
CrossFrame.$imports.$restore();
});
it('detects frames on page', function() {
......
events = require('../../shared/bridge-events')
proxyquire = require('proxyquire')
rafStub = (fn) ->
fn()
Sidebar = proxyquire('../sidebar', { raf: rafStub })
Sidebar = require('../sidebar')
DEFAULT_WIDTH = 350
DEFAULT_HEIGHT = 600
......@@ -17,6 +12,14 @@ describe 'Sidebar', ->
fakeCrossFrame = null
sidebarConfig = {pluginClasses: {}}
before ->
rafStub = (fn) ->
fn()
Sidebar.$imports.$mock({ raf: rafStub })
after ->
Sidebar.$imports.$restore()
createSidebar = (config={}) ->
config = Object.assign({}, sidebarConfig, config)
element = document.createElement('div')
......
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