| OLD | NEW |
| (Empty) |
| 1 library curerncy_spec; | |
| 2 | |
| 3 import '../_specs.dart'; | |
| 4 import 'package:intl/intl.dart'; | |
| 5 | |
| 6 void main() { | |
| 7 describe('number', () { | |
| 8 var currency; | |
| 9 | |
| 10 beforeEach((FormatterMap map, Injector injector) { | |
| 11 currency = injector.get(map[new Formatter(name: 'currency')]); | |
| 12 }); | |
| 13 | |
| 14 | |
| 15 it('should do basic currency filtering', () { | |
| 16 expect(currency(0)).toEqual(r'$0.00'); | |
| 17 expect(currency(-999)).toEqual(r'($999.00)'); | |
| 18 expect(currency(1234.5678, r"USD$")).toEqual(r'USD$1,234.57'); | |
| 19 }); | |
| 20 | |
| 21 | |
| 22 it('should return empty string for non-numbers', () { | |
| 23 expect(currency(null)).toEqual(null); | |
| 24 }); | |
| 25 | |
| 26 it('should handle zero and nearly-zero values properly', () { | |
| 27 // This expression is known to yield 4.440892098500626e-16 instead of 0.0. | |
| 28 expect(currency(1.07 + 1 - 2.07)).toEqual(r'$0.00'); | |
| 29 expect(currency(0.008)).toEqual(r'$0.01'); | |
| 30 expect(currency(0.003)).toEqual(r'$0.00'); | |
| 31 }); | |
| 32 | |
| 33 it('should accept various locales', () { | |
| 34 expect(Intl.withLocale('de', () => currency(0.008, '€', false))).toEqual(r
'0,01€'); | |
| 35 }); | |
| 36 }); | |
| 37 } | |
| OLD | NEW |