我将如何测试以下内容,以便将JSON的内在值与期望值进行比较?我已经尝试了正常的Expect()。toEqual();通过但不进行内部检查。
我听说过deepEquals,但是我不确定这是否有效?
service.ts
jsonifyData(user:string, pass:string) {
return {
'user':
{
'username': username,
'password': password,
}
};
}
test.js
const expectJSON = {
'user':
{
'username': someUsername,
'password': somePassword,
}
};
it('should return filled in user json', inject([AuthService],
(service: AuthService) => {
username = 'someUsername';
password = 'somePassword';
returned = service.jsonifyData(username, password);
expect(returned).toEqual(expectJSON);
}));