1
0

h-matchers.js 906 B

12345678910111213141516171819202122232425262728293031323334
  1. beforeEach(function() {
  2. this.addMatchers({
  3. toExactlyMatch: function(expected) {
  4. var a1, a2,
  5. l, i,
  6. key,
  7. actual = this.actual;
  8. var getKeys = function(o) {
  9. var a = [];
  10. for(key in o) {
  11. if(o.hasOwnProperty(key)) {
  12. a.push(key);
  13. }
  14. }
  15. return a;
  16. }
  17. a1 = getKeys(actual);
  18. a2 = getKeys(expected);
  19. l = a1.length;
  20. if(l !== a2.length) {
  21. return false;
  22. }
  23. for(i = 0; i < l; i++) {
  24. key = a1[i];
  25. expect(key).toEqual(a2[i]);
  26. expect(actual[key]).toEqual(expected[key]);
  27. }
  28. return true;
  29. }
  30. })
  31. });