我正在做Odin项目。我现在正在学习TDD。我需要通过“ helloWorld”第一次测试的帮助。
JS文件:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(channelId, name, importance);
mChannel.setShowBadge(true);
NotificationManager mNotifyMgr =(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.createNotificationChannel(mChannel);
notification = new Notification.Builder(this)
.setChannelId(CHANNEL_ID) // CHANNEL_ID = "notification"
.setContentTitle("Truiton Music Player")
.setTicker("Truiton Music Player")
.setContentText("My Music")
.setSmallIcon(R.drawable.esp)
.setLargeIcon(
Bitmap.createScaledBitmap(icon, 128, 128, false))
.setContentIntent(pendingIntent)
.setOngoing(true)
.setPriority(Notification.PRIORITY_MAX).setWhen(0)
.addAction(R.drawable.ic_per,
"", ppreviousIntent)
.addAction(R.drawable.ic_play, "",
pplayIntent)
.addAction(R.drawable.ic_next, "",
pnextIntent).build();
// Builds the notification and issues it.
mNotifyMgr.notify(id, notification);
}
.spec文件:
const helloWorld = function() {
return ''
}
module.exports = helloWorld
测试未通过,因为该函数在假定返回“ Hello,World!”时将返回一个空字符串。我进入JS文件并进行更改并保存。
const helloWorld = require('./helloWorld');
describe('Hello World', function() {
it('says hello world', function() {
expect(helloWorld()).toEqual('Hello, World!');
});
});
我在终端中运行“ jasmine helloWorld.spec.js”命令。终端返回以下消息:
const helloWorld = function() {
return 'Hello, World!'
}
module.exports = helloWorld
请帮助。
答案 0 :(得分:0)
现在,您的函数返回一个空字符串''
,而不是使它返回测试所期望的字符串-'Hello, World!'
:
const helloWorld = function() {
return 'Hello, World!'
}
答案 1 :(得分:-1)
您应该写Hello, World!
而不是hello world
。该功能区分字符。