Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. expectStatus = function(expected)
  2. {
  3. var match = responseCode.code === expected;
  4. tests[expected] = match;
  5.  
  6. if (!match)
  7. {
  8. throw "status code match failed";
  9. }
  10. }
  11.  
  12.  
  13. compareJson = function(comparingWhat, actualJson, expectedJson)
  14. {
  15. var fields = Object.keys(expectedJson);
  16. for (var i = 0; i < fields.length; i++)
  17. {
  18. field = fields[i]
  19. tests[comparingWhat + " : " + field] = JSON.stringify(actualJson[field]) === JSON.stringify(expectedJson[field]);
  20. }
  21. }
  22.  
  23. compareJsonArray = function(comparingWhat, actualJsonArray, expectedJsonArray)
  24. {
  25. for (var i = 0; i < expectedJsonArray.length; i++)
  26. {
  27. var found = false
  28. for (var j = 0; j < actualJsonArray.length; j++)
  29. {
  30. if (actualJsonArray[j]["id"] === expectedJsonArray[i]["id"])
  31. {
  32. console.log(actualJsonArray[j]["id"] + " --- " + expectedJsonArray[i]["id"])
  33. compareJson("deals " + actualJsonArray[j]["id"], actualJsonArray[j], expectedJsonArray[i]);
  34. found = true;
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement