本文整理汇总了TypeScript中expect.createSpy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createSpy函数的具体用法?TypeScript createSpy怎么用?TypeScript createSpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createSpy函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getSpy
private getSpy(targetKey: string): Spy<T> {
if (!Reflect.hasMetadata(SPY_KEY, this.mock, targetKey)) {
Reflect.defineMetadata(SPY_KEY, createSpy(), this.mock, targetKey);
}
return Reflect.getMetadata(SPY_KEY, this.mock, targetKey);
}
开发者ID:otbe,项目名称:emock,代码行数:7,代码来源:Mock.ts
示例2: getImageResponseMock
export function getImageResponseMock(): any {
return {
Architecture: 'amd64',
Author: 'Brian Palmer <[email protected]>',
Config: {
Cmd: [ 'bin', '-sh' ],
Entrypoint: [ 'test1.sh', 'test2.sh' ],
Env: [ 'TEST_VAR=5'],
ExposedPorts: {
'9000/tcp': null,
'8080/udp': null,
},
User: 'TestUser',
Volumes: {
'/temp/tmp': null
},
WorkingDir: '/app'
},
Created: '2016-05-20T16:14:30.654638605Z',
Id: 'sha256:9cfad7bf4e016fb7191140fb23537636bc186ffebff82e4f9b0a04422fcf1532',
Os: 'linux',
RepoTags: [
'test:0.15',
'test:latest',
],
Size: 267464419,
VirtualSize: 267464419,
history: createSpy()
};
}
开发者ID:Mercateo,项目名称:dwatch,代码行数:31,代码来源:DockerFacade.ts
示例3: it
it('can have multiple subscribers', () => {
let pushToObservable: Function = () => {}
let activations = 0
let deactivationFunction = expect.createSpy<Function0<void>>()
const obs = Observable<number>(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 }])
pushToObservable(20)
expect(subValues).toEqual([{ 1: 10 }, { 2: 10 }, { 1: 20 }, { 2: 20 }])
unsub1()
expect(deactivationFunction.calls.length).toBe(0)
unsub2()
expect(deactivationFunction.calls.length).toBe(1)
expect(activations).toBe(1)
obs.subscribe(x => x)
obs.subscribe(x => x)
expect(activations).toBe(2)
})
开发者ID:AlexGalays,项目名称:kaiju,代码行数:34,代码来源:observable.ts
示例4: getContainerResponseMock
export function getContainerResponseMock (): any {
return {
Id: 'myId',
Name: '/myContainer',
Created: new Date(),
Config: {
WorkingDir: 'there',
Image: 'myImage',
Env: [ 'myEnv' ],
Cmd: [ 'go-for-it' ]
},
State: {
Running: true,
FinishedAt: new Date(),
StartedAt: new Date(),
ExitCode: 0,
Status: 'running'
},
NetworkSettings: {
Ports: {
'3000/tcp': null,
'8000/udp': [
{
HostPort: '8080',
HostIp: '1.3.3.7'
}
]
}
},
Node: {
Addr: 'myAddr',
Cpus: 5,
id: 'nodeId',
memoryLimit: 200,
name: 'nodeName'
},
stop: createSpy(),
start: createSpy(),
pause: createSpy(),
unpause: createSpy(),
stats: createSpy(),
top: createSpy()
}
}
开发者ID:Webysther,项目名称:dwatch,代码行数:45,代码来源:DockerFacade.ts
示例5: SumoLogger
import * as SumoLogger from 'sumo-logger';
import * as expect from 'expect';
const onErrorSpy = expect.createSpy();
const onSuccessSpy = expect.createSpy();
const logger = new SumoLogger({
endpoint: 'http://example.com/',
onSuccess() {
console.log('success');
},
onError: onErrorSpy,
});
expect(logger.flushLogs).toExist();
expect(logger.log).toExist();
logger.log('message');
logger.log({ json: 'object' });
expect(onErrorSpy).toHaveBeenCalled();
expect(onErrorSpy.calls.length).toBe(2);
expect(onSuccessSpy).toNotHaveBeenCalled();
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:23,代码来源:sumo-logger-tests.ts
注:本文中的expect.createSpy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论