面临 getExperience 方法的问题。不知道为什么我会得到这个,有人可以帮助我吗?错误:在员工模型中测试自定义方法 测试员工模型的 getExperience 方法 在执行 getExperience 方法后检查员工模型中的体验失败 预期 0 为 21。
<!-- Test Case-->
it('Checking experience in Employee Model after getExperience method execution', function() {
var current_date = new Date();
var current_year= current_date.getFullYear();
var calculated_exp= current_year-1999;
employee.getExperience(employee.get('year_of_joining'));
expect(employee.get('experience')).toBe(calculated_exp);
});
var Employee = Backbone.Model.extend({
//Write your code here
getExperience: function(experience) {
var year_of_joining=employee.get('year_of_joining');
var current_date = new Date();
var current_year= current_date.getFullYear();
var calculated_exp= (current_year)-(year_of_joining);
return calculated_exp;
}
});
var employee = new Employee({
employee_id:1111,
name:'Sarah Roe',
year_of_joining:1999,
address:'ABC Street',
experience:0
});
alert("Experience of "+employee.get("name")+" is "+employee.getExperience(employee.get('year_of_joining'))+" years");;
<!-- Hmtl -->
<html>
<head>
</head>
<body>
<div id="app"></div
<script src="lib/jquery/dist/jquery.js"></script>
<script src="lib/underscore/underscore.js"></script>
<script src="lib/backbone/backbone.js"></script>
<script type = "text/javascript" src="index.js"></script>
</html>
慕尼黑5688855
尚方宝剑之说
温温酱
相关分类