From c594f75b4c59a5341741f012a4f2942a920bac8c Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Mon, 2 Jan 2012 20:50:17 -0800 Subject: refactor: remove old JSTD assertions So that we can run the tests even without JSTD :-D --- test/BinderSpec.js | 156 +++++++++++++++++++------------------- test/JsonSpec.js | 32 ++++---- test/markupSpec.js | 92 +++++++++++----------- test/service/filter/filterSpec.js | 71 ++++++++--------- test/testabilityPatch.js | 10 ++- 5 files changed, 182 insertions(+), 179 deletions(-) (limited to 'test') diff --git a/test/BinderSpec.js b/test/BinderSpec.js index 691e2db8..34504b30 100644 --- a/test/BinderSpec.js +++ b/test/BinderSpec.js @@ -27,33 +27,33 @@ describe('Binder', function() { it('BindUpdate', inject(function($rootScope, $compile) { $compile('
')($rootScope); $rootScope.$digest(); - assertEquals(123, $rootScope.a); + expect($rootScope.a).toBe(123); })); it('ExecuteInitialization', inject(function($rootScope, $compile) { $compile('
')($rootScope); - assertEquals($rootScope.a, 123); + expect($rootScope.a).toBe(123); })); it('ExecuteInitializationStatements', inject(function($rootScope, $compile) { $compile('
')($rootScope); - assertEquals($rootScope.a, 123); - assertEquals($rootScope.b, 345); + expect($rootScope.a).toBe(123); + expect($rootScope.b).toBe(345); })); it('ApplyTextBindings', inject(function($rootScope, $compile) { var element = $compile('
x
')($rootScope); $rootScope.model = {a:123}; $rootScope.$apply(); - assertEquals('123', element.text()); + expect(element.text()).toBe('123'); })); it('ReplaceBindingInTextWithSpan preserve surounding text', function() { - assertEquals(this.compileToHtml("a{{b}}c"), 'ac'); + expect(this.compileToHtml("a{{b}}c")).toBe('ac'); }); it('ReplaceBindingInTextWithSpan', function() { - assertEquals(this.compileToHtml("{{b}}"), ''); + expect(this.compileToHtml("{{b}}")).toBe(''); }); it('BindingSpaceConfusesIE', inject(function($rootScope, $compile) { @@ -61,48 +61,47 @@ describe('Binder', function() { var span = document.createElement("span"); span.innerHTML = ' '; var nbsp = span.firstChild.nodeValue; - assertEquals( - ''+nbsp+'', - this.compileToHtml("{{a}} {{b}}")); + expect(this.compileToHtml("{{a}} {{b}}")). + toBe('' + nbsp + ''); dealoc(($rootScope)); - assertEquals( - ''+nbsp+'x '+nbsp+'()', - this.compileToHtml("{{A}} x {{B}} ({{C}})")); + expect(this.compileToHtml("{{A}} x {{B}} ({{C}})")). + toBe('' + nbsp + 'x ' + + '' + nbsp + '()'); })); it('BindingOfAttributes', inject(function($rootScope, $compile) { var element = $compile("")($rootScope); var attrbinding = element.attr("ng:bind-attr"); var bindings = fromJson(attrbinding); - assertEquals("http://s/a{{b}}c", decodeURI(bindings.href)); - assertTrue(!bindings.foo); + expect(decodeURI(bindings.href)).toBe("http://s/a{{b}}c"); + expect(bindings.foo).toBeFalsy(); })); it('MarkMultipleAttributes', inject(function($rootScope, $compile) { var element = $compile('')($rootScope); var attrbinding = element.attr("ng:bind-attr"); var bindings = fromJson(attrbinding); - assertEquals(bindings.foo, "{{d}}"); - assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c"); + expect(bindings.foo).toBe("{{d}}"); + expect(decodeURI(bindings.href)).toBe("http://s/a{{b}}c"); })); it('AttributesNoneBound', inject(function($rootScope, $compile) { var a = $compile("")($rootScope); - assertEquals(a[0].nodeName, "A"); - assertTrue(!a.attr("ng:bind-attr")); + expect(a[0].nodeName).toBe("A"); + expect(a.attr("ng:bind-attr")).toBeFalsy(); })); it('ExistingAttrbindingIsAppended', inject(function($rootScope, $compile) { var a = $compile("")($rootScope); - assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng:bind-attr')); + expect(a.attr('ng:bind-attr')).toBe('{"b":"{{def}}","href":"http://s/{{abc}}"}'); })); it('AttributesAreEvaluated', inject(function($rootScope, $compile) { var a = $compile('')($rootScope); $rootScope.$eval('a=1;b=2'); $rootScope.$apply(); - assertEquals(a.attr('a'), 'a'); - assertEquals(a.attr('b'), 'a+b=3'); + expect(a.attr('a')).toBe('a'); + expect(a.attr('b')).toBe('a+b=3'); })); it('InputTypeButtonActionExecutesInScope', inject(function($rootScope, $compile) { @@ -114,7 +113,7 @@ describe('Binder', function() { savedCalled = true; }; browserTrigger(element, 'click'); - assertTrue(savedCalled); + expect(savedCalled).toBe(true); })); it('InputTypeButtonActionExecutesInScope2', inject(function($rootScope, $compile) { @@ -136,7 +135,7 @@ describe('Binder', function() { savedCalled = true; }; browserTrigger(element, 'click'); - assertTrue(savedCalled); + expect(savedCalled).toBe(true); })); it('RepeaterUpdateBindings', inject(function($rootScope, $compile) { @@ -148,28 +147,31 @@ describe('Binder', function() { $rootScope.model = {items:items}; $rootScope.$apply(); - assertEquals('
    ' + + expect(sortedHtml(form)).toBe( + '
      ' + '<#comment>' + '
    • A
    • ' + '
    • B
    • ' + - '
    ', sortedHtml(form)); + '
'); items.unshift({a:'C'}); $rootScope.$apply(); - assertEquals('
    ' + + expect(sortedHtml(form)).toBe( + '
      ' + '<#comment>' + '
    • C
    • ' + '
    • A
    • ' + '
    • B
    • ' + - '
    ', sortedHtml(form)); + '
'); items.shift(); $rootScope.$apply(); - assertEquals('
    ' + + expect(sortedHtml(form)).toBe( + '
      ' + '<#comment>' + '
    • A
    • ' + '
    • B
    • ' + - '
    ', sortedHtml(form)); + '
'); items.shift(); items.shift(); @@ -183,15 +185,16 @@ describe('Binder', function() { '')($rootScope); $rootScope.model = {items:[{a:"A"}]}; $rootScope.$apply(); - assertEquals('
    ' + + expect(sortedHtml(element)).toBe( + '
      ' + '<#comment>' + '
    • A
    • ' + - '
    ', sortedHtml(element)); + '
'); })); it('DoNotOverwriteCustomAction', function() { var html = this.compileToHtml(''); - assertTrue(html.indexOf('action="foo();"') > 0 ); + expect(html.indexOf('action="foo();"')).toBeGreaterThan(0); }); it('RepeaterAdd', inject(function($rootScope, $compile, $browser) { @@ -242,11 +245,11 @@ describe('Binder', function() { $rootScope.error['throw'] = function() {throw "MyError";}; errorLogs.length = 0; $rootScope.$apply(); - assertEquals(['MyError'], errorLogs.shift()); + expect(errorLogs.shift()).toBe('MyError'); $rootScope.error['throw'] = function() {return "ok";}; $rootScope.$apply(); - assertEquals(0, errorLogs.length); + expect(errorLogs.length).toBe(0); }) ); @@ -281,18 +284,20 @@ describe('Binder', function() { $rootScope.model = [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]; $rootScope.$apply(); - assertEquals('
'+ - '<#comment>'+ - '
'+ + expect(sortedHtml(element)).toBe( + '
'+ '<#comment>'+ - '
    '+ - '
      '+ - '
      '+ - '
      '+ - '<#comment>'+ - '
        '+ - '
          '+ - '
          ', sortedHtml(element)); + '
          '+ + '<#comment>'+ + '
            '+ + '
              '+ + '
              '+ + '
              '+ + '<#comment>'+ + '
                '+ + '
                  '+ + '
                  ' + + '
                  '); })); it('HideBindingExpression', inject(function($rootScope, $compile) { @@ -354,12 +359,12 @@ describe('Binder', function() { $rootScope.clazz = 'testClass'; $rootScope.$apply(); - assertEquals('
                  ', sortedHtml(element)); + expect(sortedHtml(element)).toBe('
                  '); $rootScope.clazz = ['a', 'b']; $rootScope.$apply(); - assertEquals('
                  ', sortedHtml(element)); + expect(sortedHtml(element)).toBe('
                  '); })); it('BindClassEvenOdd', inject(function($rootScope, $compile) { @@ -372,11 +377,10 @@ describe('Binder', function() { var d2 = jqLite(element[0].childNodes[2]); expect(d1.hasClass('o')).toBeTruthy(); expect(d2.hasClass('e')).toBeTruthy(); - assertEquals( + expect(sortedHtml(element)).toBe( '
                  <#comment>' + '
                  ' + - '
                  ', - sortedHtml(element)); + '
                  '); })); it('BindStyle', inject(function($rootScope, $compile) { @@ -385,7 +389,7 @@ describe('Binder', function() { $rootScope.$eval('style={height: "10px"}'); $rootScope.$apply(); - assertEquals("10px", element.css('height')); + expect(element.css('height')).toBe("10px"); $rootScope.$eval('style={}'); $rootScope.$apply(); @@ -414,7 +418,7 @@ describe('Binder', function() { "
                  ")($rootScope); $rootScope.a = 123; $rootScope.$apply(); - assertEquals('123{{a}}{{b}}{{c}}', element.text()); + expect(element.text()).toBe('123{{a}}{{b}}{{c}}'); })); it('ShouldTemplateBindPreElements', inject(function ($rootScope, $compile) { @@ -422,9 +426,8 @@ describe('Binder', function() { $rootScope.name = "World"; $rootScope.$apply(); - assertEquals( - '
                  Hello World!
                  ', - sortedHtml(element)); + expect( sortedHtml(element)).toBe( + '
                  Hello World!
                  '); })); it('FillInOptionValueWhenMissing', inject(function($rootScope, $compile) { @@ -463,8 +466,7 @@ describe('Binder', function() { '
                  ')($rootScope); $rootScope.$apply(); function assertChild(index, disabled) { - var child = childNode(element, index); - assertEquals(sortedHtml(child), disabled, !!child.attr('disabled')); + expect(!!childNode(element, index).attr('disabled')).toBe(disabled); } assertChild(0, true); @@ -490,7 +492,7 @@ describe('Binder', function() { var errorLogs = $log.error.logs; browserTrigger(first, 'click'); - assertEquals("ABC", $rootScope.greeting); + expect($rootScope.greeting).toBe("ABC"); expect(errorLogs).toEqual([]); browserTrigger(second, 'click'); @@ -509,16 +511,16 @@ describe('Binder', function() { var male = jqLite(element[0].childNodes[1]); browserTrigger(female); - assertEquals("female", $rootScope.sex); - assertEquals(true, female[0].checked); - assertEquals(false, male[0].checked); - assertEquals("female", female.val()); + expect($rootScope.sex).toBe("female"); + expect(female[0].checked).toBe(true); + expect(male[0].checked).toBe(false); + expect(female.val()).toBe("female"); browserTrigger(male); - assertEquals("male", $rootScope.sex); - assertEquals(false, female[0].checked); - assertEquals(true, male[0].checked); - assertEquals("male", male.val()); + expect($rootScope.sex).toBe("male"); + expect(female[0].checked).toBe(false); + expect(male[0].checked).toBe(true); + expect(male.val()).toBe("male"); })); it('ItShouldRepeatOnHashes', inject(function($rootScope, $compile) { @@ -527,12 +529,12 @@ describe('Binder', function() { '
                • ' + '')($rootScope); $rootScope.$apply(); - assertEquals('', - sortedHtml(element)); + expect(sortedHtml(element)).toBe( + ''); })); it('ItShouldFireChangeListenersBeforeUpdate', inject(function($rootScope, $compile) { @@ -541,16 +543,14 @@ describe('Binder', function() { $rootScope.$watch("watched", "name=123"); $rootScope.watched = "change"; $rootScope.$apply(); - assertEquals(123, $rootScope.name); - assertEquals( - '
                  123
                  ', - sortedHtml(element)); + expect($rootScope.name).toBe(123); + expect(sortedHtml(element)).toBe('
                  123
                  '); })); it('ItShouldHandleMultilineBindings', inject(function($rootScope, $compile) { var element = $compile('
                  {{\n 1 \n + \n 2 \n}}
                  ')($rootScope); $rootScope.$apply(); - assertEquals("3", element.text()); + expect(element.text()).toBe("3"); })); }); diff --git a/test/JsonSpec.js b/test/JsonSpec.js index 736e6032..3329c223 100644 --- a/test/JsonSpec.js +++ b/test/JsonSpec.js @@ -219,14 +219,14 @@ describe('json', function() { }); - + it('should read/write to date', function() { var date = new Date("Sep 10 2003 13:02:03 GMT"); - assertEquals("2003-09-10T13:02:03.000Z", jsonDateToString(date)); - assertEquals(date.getTime(), jsonStringToDate(jsonDateToString(date)).getTime()); + expect(jsonDateToString(date)).toBe("2003-09-10T13:02:03.000Z"); + expect(jsonStringToDate(jsonDateToString(date)).getTime()).toBe(date.getTime()); }); - - + + it('should convert to date', function() { //full ISO8061 expect(jsonStringToDate("2003-09-10T13:02:03.000Z")). @@ -249,31 +249,31 @@ describe('json', function() { toEqual(new Date("Sep 10 2003 00:00:00 GMT")); }); - + it('should parse date', function() { var date = jsonStringToDate("2003-09-10T13:02:03.000Z"); - assertEquals("2003-09-10T13:02:03.000Z", jsonDateToString(date)); - assertEquals("str", jsonStringToDate("str")); + expect(jsonDateToString(date)).toBe("2003-09-10T13:02:03.000Z"); + expect(jsonStringToDate("str")).toBe("str"); }); describe('string', function() { it('should quote', function() { - assertEquals(quoteUnicode('a'), '"a"'); - assertEquals(quoteUnicode('\\'), '"\\\\"'); - assertEquals(quoteUnicode("'a'"), '"\'a\'"'); - assertEquals(quoteUnicode('"a"'), '"\\"a\\""'); - assertEquals(quoteUnicode('\n\f\r\t'), '"\\n\\f\\r\\t"'); + expect(quoteUnicode('a')).toBe('"a"'); + expect(quoteUnicode('\\')).toBe('"\\\\"'); + expect(quoteUnicode("'a'")).toBe('"\'a\'"'); + expect(quoteUnicode('"a"')).toBe('"\\"a\\""'); + expect(quoteUnicode('\n\f\r\t')).toBe('"\\n\\f\\r\\t"'); }); it('should quote slashes', function() { - assertEquals('"7\\\\\\\"7"', quoteUnicode("7\\\"7")); + expect(quoteUnicode("7\\\"7")).toBe('"7\\\\\\\"7"'); }); it('should quote unicode', function() { - assertEquals('"abc\\u00a0def"', quoteUnicode('abc\u00A0def')); + expect(quoteUnicode('abc\u00A0def')).toBe('"abc\\u00a0def"'); }); }); - + }); diff --git a/test/markupSpec.js b/test/markupSpec.js index 6b6ba664..7c7f64f8 100644 --- a/test/markupSpec.js +++ b/test/markupSpec.js @@ -173,87 +173,87 @@ describe("markups", function() { it('should Parse Text With No Bindings', inject(function($rootScope, $compile) { var parts = parseBindings("a"); - assertEquals(parts.length, 1); - assertEquals(parts[0], "a"); - assertTrue(!binding(parts[0])); + expect(parts.length).toBe(1); + expect(parts[0]).toBe("a"); + expect(binding(parts[0])).toBeFalsy(); })); it('should Parse Empty Text', inject(function($rootScope, $compile) { var parts = parseBindings(""); - assertEquals(parts.length, 1); - assertEquals(parts[0], ""); - assertTrue(!binding(parts[0])); + expect(parts.length).toBe(1); + expect(parts[0]).toBe(""); + expect(binding(parts[0])).toBeFalsy(); })); it('should Parse Inner Binding', inject(function($rootScope, $compile) { var parts = parseBindings("a{{b}}C"); - assertEquals(parts.length, 3); - assertEquals(parts[0], "a"); - assertTrue(!binding(parts[0])); - assertEquals(parts[1], "{{b}}"); - assertEquals(binding(parts[1]), "b"); - assertEquals(parts[2], "C"); - assertTrue(!binding(parts[2])); + expect(parts.length).toBe(3); + expect(parts[0]).toBe("a"); + expect(binding(parts[0])).toBeFalsy(); + expect(parts[1]).toBe("{{b}}"); + expect(binding(parts[1])).toBe("b"); + expect(parts[2]).toBe("C"); + expect(binding(parts[2])).toBeFalsy(); })); it('should Parse Ending Binding', inject(function($rootScope, $compile) { var parts = parseBindings("a{{b}}"); - assertEquals(parts.length, 2); - assertEquals(parts[0], "a"); - assertTrue(!binding(parts[0])); - assertEquals(parts[1], "{{b}}"); - assertEquals(binding(parts[1]), "b"); + expect(parts.length).toBe(2); + expect(parts[0]).toBe("a"); + expect(binding(parts[0])).toBeFalsy(); + expect(parts[1]).toBe("{{b}}"); + expect(binding(parts[1])).toBe("b"); })); it('should Parse Begging Binding', inject(function($rootScope, $compile) { var parts = parseBindings("{{b}}c"); - assertEquals(parts.length, 2); - assertEquals(parts[0], "{{b}}"); - assertEquals(binding(parts[0]), "b"); - assertEquals(parts[1], "c"); - assertTrue(!binding(parts[1])); + expect(parts.length).toBe(2); + expect(parts[0]).toBe("{{b}}"); + expect(binding(parts[0])).toBe("b"); + expect(parts[1]).toBe("c"); + expect(binding(parts[1])).toBeFalsy(); })); it('should Parse Loan Binding', inject(function($rootScope, $compile) { var parts = parseBindings("{{b}}"); - assertEquals(parts.length, 1); - assertEquals(parts[0], "{{b}}"); - assertEquals(binding(parts[0]), "b"); + expect(parts.length).toBe(1); + expect(parts[0]).toBe("{{b}}"); + expect(binding(parts[0])).toBe("b"); })); it('should Parse Two Bindings', inject(function($rootScope, $compile) { var parts = parseBindings("{{b}}{{c}}"); - assertEquals(parts.length, 2); - assertEquals(parts[0], "{{b}}"); - assertEquals(binding(parts[0]), "b"); - assertEquals(parts[1], "{{c}}"); - assertEquals(binding(parts[1]), "c"); + expect(parts.length).toBe(2); + expect(parts[0]).toBe("{{b}}"); + expect(binding(parts[0])).toBe("b"); + expect(parts[1]).toBe("{{c}}"); + expect(binding(parts[1])).toBe("c"); })); it('should Parse Two Bindings With Text In Middle', inject(function($rootScope, $compile) { var parts = parseBindings("{{b}}x{{c}}"); - assertEquals(parts.length, 3); - assertEquals(parts[0], "{{b}}"); - assertEquals(binding(parts[0]), "b"); - assertEquals(parts[1], "x"); - assertTrue(!binding(parts[1])); - assertEquals(parts[2], "{{c}}"); - assertEquals(binding(parts[2]), "c"); + expect(parts.length).toBe(3); + expect(parts[0]).toBe("{{b}}"); + expect(binding(parts[0])).toBe("b"); + expect(parts[1]).toBe("x"); + expect(binding(parts[1])).toBeFalsy(); + expect(parts[2]).toBe("{{c}}"); + expect(binding(parts[2])).toBe("c"); })); it('should Parse Multiline', inject(function($rootScope, $compile) { var parts = parseBindings('"X\nY{{A\nB}}C\nD"'); - assertTrue(!!binding('{{A\nB}}')); - assertEquals(parts.length, 3); - assertEquals(parts[0], '"X\nY'); - assertEquals(parts[1], '{{A\nB}}'); - assertEquals(parts[2], 'C\nD"'); + expect(binding('{{A\nB}}')).toBeTruthy(); + expect(parts.length).toBe(3); + expect(parts[0]).toBe('"X\nY'); + expect(parts[1]).toBe('{{A\nB}}'); + expect(parts[2]).toBe('C\nD"'); })); it('should Has Binding', inject(function($rootScope, $compile) { - assertTrue(hasBindings(parseBindings("{{a}}"))); - assertTrue(!hasBindings(parseBindings("a"))); - assertTrue(hasBindings(parseBindings("{{b}}x{{c}}"))); + expect(hasBindings(parseBindings("{{a}}"))).toBe(true); + expect(hasBindings(parseBindings("a"))).toBeFalsy(); + expect(hasBindings(parseBindings("{{b}}x{{c}}"))).toBe(true); })); }); diff --git a/test/service/filter/filterSpec.js b/test/service/filter/filterSpec.js index 9c43144c..a33358d0 100644 --- a/test/service/filter/filterSpec.js +++ b/test/service/filter/filterSpec.js @@ -2,67 +2,68 @@ describe('Filter: filter', function() { var filter; - + beforeEach(inject(function($filter){ filter = $filter('filter'); })); - + it('should filter by string', function() { - var items = ["MIsKO", {name:"shyam"}, ["adam"], 1234]; - assertEquals(4, filter(items, "").length); - assertEquals(4, filter(items, undefined).length); + var items = ['MIsKO', {name: 'shyam'}, ['adam'], 1234]; + expect(filter(items, '').length).toBe(4); + expect(filter(items, undefined).length).toBe(4); - assertEquals(1, filter(items, 'iSk').length); - assertEquals("MIsKO", filter(items, 'isk')[0]); + expect(filter(items, 'iSk').length).toBe(1); + expect(filter(items, 'isk')[0]).toBe('MIsKO'); - assertEquals(1, filter(items, 'yam').length); - assertEquals(items[1], filter(items, 'yam')[0]); + expect(filter(items, 'yam').length).toBe(1); + expect(filter(items, 'yam')[0]).toEqual(items[1]); - assertEquals(1, filter(items, 'da').length); - assertEquals(items[2], filter(items, 'da')[0]); + expect(filter(items, 'da').length).toBe(1); + expect(filter(items, 'da')[0]).toEqual(items[2]); - assertEquals(1, filter(items, '34').length); - assertEquals(1234, filter(items, '34')[0]); + expect(filter(items, '34').length).toBe(1); + expect(filter(items, '34')[0]).toBe(1234); - assertEquals(0, filter(items, "I don't exist").length); + expect(filter(items, "I don't exist").length).toBe(0); }); it('should not read $ properties', function() { - assertEquals("", "".charAt(0)); // assumption - var items = [{$name:"misko"}]; - assertEquals(0, filter(items, "misko").length); + expect(''.charAt(0)).toBe(''); // assumption + + var items = [{$name: 'misko'}]; + expect(filter(items, 'misko').length).toBe(0); }); it('should filter on specific property', function() { - var items = [{ignore:"a", name:"a"}, {ignore:"a", name:"abc"}]; - assertEquals(2, filter(items, {}).length); + var items = [{ignore: 'a', name: 'a'}, {ignore: 'a', name: 'abc'}]; + expect(filter(items, {}).length).toBe(2); - assertEquals(2, filter(items, {name:'a'}).length); + expect(filter(items, {name: 'a'}).length).toBe(2); - assertEquals(1, filter(items, {name:'b'}).length); - assertEquals("abc", filter(items, {name:'b'})[0].name); + expect(filter(items, {name: 'b'}).length).toBe(1); + expect(filter(items, {name: 'b'})[0].name).toBe('abc'); }); it('should take function as predicate', function() { - var items = [{name:"a"}, {name:"abc", done:true}]; - assertEquals(1, filter(items, function(i) {return i.done;}).length); + var items = [{name: 'a'}, {name: 'abc', done: true}]; + expect(filter(items, function(i) {return i.done;}).length).toBe(1); }); it('should take object as perdicate', function() { - var items = [{first:"misko", last:"hevery"}, - {first:"adam", last:"abrons"}]; - - assertEquals(2, filter(items, {first:'', last:''}).length); - assertEquals(1, filter(items, {first:'', last:'hevery'}).length); - assertEquals(0, filter(items, {first:'adam', last:'hevery'}).length); - assertEquals(1, filter(items, {first:'misko', last:'hevery'}).length); - assertEquals(items[0], filter(items, {first:'misko', last:'hevery'})[0]); + var items = [{first: 'misko', last: 'hevery'}, + {first: 'adam', last: 'abrons'}]; + + expect(filter(items, {first:'', last:''}).length).toBe(2); + expect(filter(items, {first:'', last:'hevery'}).length).toBe(1); + expect(filter(items, {first:'adam', last:'hevery'}).length).toBe(0); + expect(filter(items, {first:'misko', last:'hevery'}).length).toBe(1); + expect(filter(items, {first:'misko', last:'hevery'})[0]).toEqual(items[0]); }); it('should support negation operator', function() { - var items = ["misko", "adam"]; + var items = ['misko', 'adam']; - assertEquals(1, filter(items, '!isk').length); - assertEquals(items[1], filter(items, '!isk')[0]); + expect(filter(items, '!isk').length).toBe(1); + expect(filter(items, '!isk')[0]).toEqual(items[1]); }); }); diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 8150a0a3..b4d11f3a 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -174,12 +174,14 @@ function isCssVisible(node) { } function assertHidden(node) { - assertFalse("Node should be hidden but vas visible: " + - angular.module.ngMock.dump(node), isCssVisible(node)); + if (isCssVisible(node)) { + throw new Error('Node should be hidden but was visible: ' + angular.module.ngMock.dump(node)); + } } function assertVisible(node) { - assertTrue("Node should be visible but vas hidden: " + - angular.module.ngMock.dump(node), isCssVisible(node)); + if (!isCssVisible(node)) { + throw new Error('Node should be visible but was hidden: ' + angular.module.ngMock.dump(node)); + } } -- cgit v1.2.3