Это мои данные.
var cat =
{
"_id": "5c7d5fde213e25232864dbe0",
"name": "Politics",
"updatedAt": "2019-03-04T17:26:54.262Z",
"createdAt": "2019-03-04T17:26:54.262Z",
"__v": 0
}
var allCategories = [
cat
];
Это мой тестовый пример.
fit('expects service to fetch data with proper sorting',
inject([HttpTestingController, CategoriesService],
(httpMock: HttpTestingController, service: CategoriesService) => {
service.getCategories().subscribe(data => {
expect(of(data)).toEqual(of(allCategories));
});
const req = httpMock.expectOne('http://localhost:3000/categories');
expect(req.request.method).toEqual('GET');
req.flush(of(allCategories));
})
);
Однако я получаю эти две ошибки каждый раз.
Expected $._subscribe = Function to equal Function.
Expected $.value = Observable({ _isScalar: true, _subscribe: Function, value: [ Object({ _id: '5c7d5fde213e25232864dbe0', name: 'Politics', updatedAt: '2019-03-04T17:26:54.262Z', createdAt: '2019-03-04T17:26:54.262Z', __v: 0 }) ] }) to equal [ Object({ _id: '5c7d5fde213e25232864dbe0', name: 'Politics', updatedAt: '2019-03-04T17:26:54.262Z', createdAt: '2019-03-04T17:26:54.262Z', __v: 0 }) ].
В чем причина?Есть ли решение?