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 handle returning no Bot', async(inject([], () => {
let resp = new Response(new ResponseOptions({status: 200, body: {data: []}}));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
service.getBot(100) // unknown id
.then(bot => expect(bot.id).not.toBeDefined('should have no Bot'));
})));
});
onResponse(response: Response): Response {
return new Response(new ResponseOptions({ body: JSON.stringify('override'), status: 200 }));
}
}
backend.connections.subscribe((connection: MockConnection) => {
let options = new ResponseOptions({
body: JSON.stringify({
'entity': {
'token': 'This is a Auth Token'
},
}),
status: 200
});
let a = new Response(options);
connection.mockRespond(a);
});
items: [
{ id: 0, name: 'Name 0' },
{ id: 1, name: 'Name 1' },
{ id: 2, name: 'Name 2' },
{ id: 3, name: 'Name 3' }
],
totalRecords: 5
};
this.paginatorService.get().subscribe((items) => {
this.result = items;
});
this.lastConnection.mockRespond(
new Response(
new ResponseOptions({
body: JSON.stringify({
entity: fakeEntity
}),
headers: new Headers({
Link: headerLink,
'X-Pagination-Current-Page': '3',
'X-Pagination-Link-Pages': '5',
'X-Pagination-Per-Page': '10',
'X-Pagination-Total-Entries': '38'
})
})
)
);
});
backend.connections.subscribe(connection => {
connection.mockRespond(new Response(new ResponseOptions({ body : '["string", "password"]'})));
});
mockBackend.connections.subscribe((connection) => {
connection.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify(mockResponse)
})));
});
function mockConnectionContentletResponse(): void {
return lastConnection.mockRespond(
new Response(
new ResponseOptions({
body: {
entity: mockDotContentlet
}
})
)
);
}
mockBackend.connections.subscribe(connection => {
let response = new ResponseOptions({body: {id: 1}});
connection.mockRespond(new Response(response));
});
spyOn(componentFixture.instance.notification, 'createNotification');
backend.connections.subscribe((connection: MockConnection) => {
connection.mockError(new MockError(new ResponseOptions(mockResponse)));
});
let onError = (err) => {
let responseOptions = new ResponseOptions({body: err, type: ResponseType.Error});
if (isPresent(baseResponseOptions)) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
ngZone.run(() => {
responseObserver.error(new Response(responseOptions));
});
};