From 4b1913c5ecac75e60e7a0de831100b6961d5d294 Mon Sep 17 00:00:00 2001
From: Vojta Jina
Date: Wed, 7 Sep 2011 09:17:10 +0200
Subject: fix(filter.currency): Return empty string for non-numbers
---
test/FiltersSpec.js | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
(limited to 'test/FiltersSpec.js')
diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js
index 2673b36e..83d8aac0 100644
--- a/test/FiltersSpec.js
+++ b/test/FiltersSpec.js
@@ -83,20 +83,33 @@ describe('filter', function() {
});
describe('currency', function() {
- it('should do basic currency filtering', function() {
- var html = jqLite('');
- var context = createScope();
+ var currency, html, context;
+
+ beforeEach(function() {
+ html = jqLite('');
+ context = createScope();
context.$element = html;
- var currency = bind(context, filter.currency);
+ currency = bind(context, filter.currency);
+ });
+ afterEach(function() {
+ dealoc(context);
+ });
+
+ it('should do basic currency filtering', function() {
expect(currency(0)).toEqual('$0.00');
expect(html.hasClass('ng-format-negative')).toBeFalsy();
expect(currency(-999)).toEqual('($999.00)');
expect(html.hasClass('ng-format-negative')).toBeTruthy();
expect(currency(1234.5678, "USD$")).toEqual('USD$1,234.57');
expect(html.hasClass('ng-format-negative')).toBeFalsy();
+ });
- dealoc(context);
+ it('should return empty string for non-numbers', function() {
+ expect(currency()).toBe('');
+ expect(html.hasClass('ng-format-negative')).toBeFalsy();
+ expect(currency('abc')).toBe('');
+ expect(html.hasClass('ng-format-negative')).toBeFalsy();
});
});
--
cgit v1.2.3