I am trying to write a test for an angular component service call which is using graphql & Apollo and I end up getting this Error.'Error: Expected one matching operation for criteria "Match DocumentNode", found none.'.
I have also tried putting '__typename' in each returned response but nothing worked to fix the issue.
component.spec.ts
it('should call getCDMADetails()',()=>{
const tnNumber = '8934216345';
const userQueryDetails = gql `
query
{
cdmaLineFeatures (telephoneNumber: "8934216345"){
sMSFeatures {
smsProvisionedReceive,
smsProvisionedSend
}
}
}
`;
const TEST_Login = {
'data': {
'cdmaLineFeatures': {
'sMSFeatures': {
'smsProvisionedReceive': "YES",
'smsProvisionedSend': "YES",
'__typename': "DefinedOnBackend"
}
}
}
};
homePageService.getCDMADetailsServiceInfo(tnNumber);
component.getCDMADetails();
controller.expectOne(addTypenameToDocument(userQueryDetails)).flush(TEST_Login);
expect(component.getCDMADetails).toBeTruthy();
controller.verify();
});