以下单元测试失败,因为日期是英文,即“2017年6月16日星期五”,而不是预期的荷兰语版本,即“vrijdag 2017 juni 2017”。
test('returns dutch version of date when given ISO version', () => {
const dateToFormat = new Date('2017-06-16');
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
};
const result = new Intl
.DateTimeFormat('nl-NL', options)
.format(dateToFormat);
expect(result).toBe('vrijdag 16 juni 2017');
});
为什么这个单元测试失败了?
环境:
单元测试失败的日志:
FAIL [path-to-file]
returns dutch version of date when given ISO version
expect(received).toBe(expected)
Expected value to be (using ===):
"vrijdag 16 juni 2017"
Received:
"Friday, June 16, 2017"
at Object.<anonymous> ([path-to-file]:15:20)
at emitTwo (events.js:106:13)
at process.emit (events.js:191:7)
at process.nextTick (internal/child_process.js:758:12)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)