Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('invited', t => {
const changeStatus = sinon.fake()
const withdraw = sinon.fake()
const wrapper = mountWithIntl(
)
t.is(wrapper.find('h4').first().text(), 'Thank you so much!')
})
it('should update the host', function() {
const changeHostHandler = sinon.fake()
const msg = {
host: '192.168.1.3',
}
device.on('change:host', changeHostHandler)
device._applyUpdate(msg, [])
changeHostHandler.calledOnce.should.equal(true)
changeHostHandler.calledWith(msg.host).should.equal(true)
})
it('should not emit `stale` when `staleTimeout` is disabled', function() {
const clock = sinon.useFakeTimers()
const staleHandler = sinon.fake()
const deviceStaleHandler = sinon.fake()
shellies.on('stale', staleHandler)
device.on('stale', deviceStaleHandler)
shellies.staleTimeout = 0
device.online = true
shellies.addDevice(device)
device.online = false
staleHandler.called.should.equal(false)
clock.tick(99999999999)
staleHandler.calledOnce.should.equal(false)
deviceStaleHandler.calledOnce.should.equal(false)
clock.restore()
})
it('should emit `discover` when a new device is found', function() {
const discoverHandler = sinon.fake()
shellies.on('discover', discoverHandler)
const msg = {
deviceType: 'SHSW-1',
deviceId: 'ABC123',
host: '192.168.1.2',
}
shellies._listener.emit('statusUpdate', msg)
discoverHandler.calledOnce.should.equal(true)
discoverHandler.lastCall.args[0].type.should.equal(msg.deviceType)
discoverHandler.lastCall.args[0].id.should.equal(msg.deviceId)
discoverHandler.lastCall.args[0].host.should.equal(msg.host)
discoverHandler.lastCall.args[1].should.be.false()
const msg2 = {
it('should emit `add` when a new device is discovered', function() {
const addHandler = sinon.fake()
shellies.on('add', addHandler)
const msg = {
deviceType: 'SHSW-1',
deviceId: 'ABC123',
host: '192.168.1.2',
}
shellies._listener.emit('statusUpdate', msg)
addHandler.calledOnce.should.equal(true)
})
function createFakeWorker(postMessage) {
return {
postMessage: postMessage ? sinon.fake(postMessage) : sinon.fake(),
onmessage: null
};
}
beforeEach(() => {
stroke = sinon.fake();
fill = sinon.fake();
sinon.replace(window.CanvasRenderingContext2D.prototype, 'stroke', stroke);
sinon.replace(window.CanvasRenderingContext2D.prototype, 'fill', fill);
ctx = new window.CanvasRenderingContext2D();
polyfillPath2D(window);
});
function buildOverrides(secondOverride: Override) {
fakeReceiver = createFakeReceiver();
fakeErrorHandler = sinon.fake();
dummyAuthorizationResult = { botToken: '', botId: '' };
overrides = mergeOverrides(
withNoopAppMetadata(),
secondOverride,
withMemoryStore(sinon.fake()),
withConversationContext(sinon.fake.returns(noopMiddleware))
);
return overrides;
}
},
};
export const npStart = {
core: {
chrome: {},
},
plugins: {
embeddable: {
getEmbeddableFactory: sinon.fake(),
getEmbeddableFactories: sinon.fake(),
registerEmbeddableFactory: sinon.fake(),
},
expressions: {
registerFunction: sinon.fake(),
registerRenderer: sinon.fake(),
registerType: sinon.fake(),
},
data: {
getSuggestions: sinon.fake(),
},
inspector: {
isAvailable: () => false,
open: () => ({
onClose: Promise.resolve(undefined),
close: () => Promise.resolve(undefined),
}),
},
uiActions: {
attachAction: sinon.fake(),
registerAction: sinon.fake(),
registerTrigger: sinon.fake(),