Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should pass requestInterceptor/responseInterceptor to fn.execute", function(){
// Given
let configs = {
requestInterceptor: createSpy(),
responseInterceptor: createSpy()
}
const system = {
fn: {
buildRequest: createSpy(),
execute: createSpy().andReturn(Promise.resolve())
},
specActions: {
executeRequest: createSpy(),
setMutatedRequest: createSpy(),
setRequest: createSpy()
},
specSelectors: {
spec: () => fromJS({}),
parameterValues: () => fromJS({}),
contentTypeValues: () => fromJS({}),
url: () => fromJS({}),
isOAS3: () => false
},
getConfigs: () => configs
}
// When
it('should no resubmit if async submit is in progress', () => {
const store = makeStore({
testForm: {}
})
const Form = () => (
<form>
)
const submitSpy = createSpy().andCall(() => new Promise(() => { /* Promise will never resolve */
}))
const Decorated = reduxForm({
form: 'testForm',
onSubmit: submitSpy
})(Form)
const dom = TestUtils.renderIntoDocument(
)
const stub = TestUtils.findRenderedComponentWithType(dom, Decorated)
stub.submit()</form>
it("should be an event emitter", () => {
// Given
const fakeAce = new FakeAce()
const spy = createSpy()
fakeAce.on("foo", spy)
// When
fakeAce.emit("foo", "bar")
// Then
expect(spy.calls.length).toEqual(1)
expect(spy.calls[0].arguments[0]).toEqual("bar")
})
it("should call the updateSpec function passed in as props with the contents of the file", () => {
const fileContents = "This is my awesome file!"
const props = {
specActions: {
updateSpec: expect.createSpy()
}
}
global.FileReader.andReturn({
readAsText: function () { this.onloadend() },
result: fileContents
})
const editorLayout = new EditorLayout(props)
editorLayout.onDrop(["accepted.file"])
expect(props.specActions.updateSpec).toHaveBeenCalledWith(fileContents, "fileDrop")
})
})
it('can have multiple subscribers', () => {
let pushToObservable
let activations = 0
let deactivationFunction = expect.createSpy()
const obs = Observable(add => {
pushToObservable = add
activations++
return deactivationFunction
})
const subValues = []
const unsub1 = obs.subscribe(x => subValues.push({ 1: x }))
const unsub2 = obs.subscribe(x => subValues.push({ 2: x }))
expect(activations).toBe(1)
expect(deactivationFunction.calls.length).toBe(0)
expect(subValues).toEqual([])
pushToObservable(10)
expect(subValues).toEqual([{ 1: 10 }, { 2: 10 }])
this.renderer = {
setShowGutter: createSpy(),
setScrollMargin: createSpy()
}
}
edit = createSpy().andReturn(this)
acequire = createSpy().andCall((module) => {
if(module == "ace/range") {
return { Range }
}
})
getSession = createSpy().andCall(() => {
return this.session
})
setOption = createSpy().andCall((option, val) => {
this.$options[option] = val
})
setOptions = createSpy().andCall((options) => {
this.$options = {...this.$options, ...options}
})
getOption = createSpy().andCall((optionName) => {
return this.$options[optionName]
})
setValue = createSpy().andCall((val, addToUndo=true) => {
const createRestorableSpy = (fn) => {
return createSpy(fn, function restore() {
this.calls = [];
});
};
const createRestorableSpy = (fn) => {
return createSpy(fn, function restore() {
this.calls = [];
});
};
import Media from '../media/mediaContainer';
import componentSetup from '../../util/specHelpers/componentSetup.spec';
const events = {
onAbort: expect.createSpy(),
onCanPlay: expect.createSpy(),
onCanPlayThrough: expect.createSpy(),
onDurationChange: expect.createSpy(),
onEmptied: expect.createSpy(),
onEncrypted: expect.createSpy(),
onEnded: expect.createSpy(),
onError: expect.createSpy(),
onLoadedData: expect.createSpy(),
onLoadedMetadata: expect.createSpy(),
onLoadStart: expect.createSpy(),
onPause: expect.createSpy(),
onPlay: expect.createSpy(),
onPlaying: expect.createSpy(),
onProgress: expect.createSpy(),
onRateChange: expect.createSpy(),
onSeeked: expect.createSpy(),
onSeeking: expect.createSpy(),
onStalled: expect.createSpy(),
onSuspend: expect.createSpy(),
onTimeUpdate: expect.createSpy(),
onVolumeChange: expect.createSpy(),
onWaiting: expect.createSpy(),
};
const setup = (props) => {
const values = componentSetup(Video, {
...props,
import expect from 'expect';
import Audio from './audio';
import Media from '../media/mediaContainer';
import componentSetup from '../../util/specHelpers/componentSetup.spec';
const events = {
onAbort: expect.createSpy(),
onCanPlay: expect.createSpy(),
onCanPlayThrough: expect.createSpy(),
onDurationChange: expect.createSpy(),
onEmptied: expect.createSpy(),
onEncrypted: expect.createSpy(),
onEnded: expect.createSpy(),
onError: expect.createSpy(),
onLoadedData: expect.createSpy(),
onLoadedMetadata: expect.createSpy(),
onLoadStart: expect.createSpy(),
onPause: expect.createSpy(),
onPlay: expect.createSpy(),
onPlaying: expect.createSpy(),
onProgress: expect.createSpy(),
onRateChange: expect.createSpy(),
onSeeked: expect.createSpy(),
onSeeking: expect.createSpy(),
onStalled: expect.createSpy(),
onSuspend: expect.createSpy(),
onTimeUpdate: expect.createSpy(),
onVolumeChange: expect.createSpy(),