小编ama*_*mal的帖子

Jasmine 测试失败,但 'expected' 和 'toBe' 字符串似乎相等?

我正在开发一个 angular(2.4.0)/typescript 应用程序,该应用程序使用自定义货币管道,该管道在内部使用 angular 的内置 CurrencyPipe 为“ en-CA ”和“ fr-CA ”加拿大语言环境格式化输入的货币字符串。在为法语案例编写单元测试时,对于希望给定有效输入字符串格式化输出的快乐路径案例,

describe('for French locale', () => {
 // get the mock custom currency pipe instance for 'fr-CA' locale as 'currencyPipeForFR'
 it('should be formatted for fr-CA locale', () => {
  expect(currencyPipeForFR.transform('7500')).toBe('7 500 $');
 });
});
Run Code Online (Sandbox Code Playgroud)

我收到此错误,

Expected '7 500 $' to be '7 500 $'.
Run Code Online (Sandbox Code Playgroud)

我确实检查了转换结果的实例,它是一个String. 我错过了什么?任何帮助,将不胜感激。

pipe separator jasmine typescript angular

2
推荐指数
1
解决办法
2627
查看次数

标签 统计

angular ×1

jasmine ×1

pipe ×1

separator ×1

typescript ×1