小编mrp*_*tem的帖子

蓝鸟承诺每个在摩卡/柴测试不工作

我想帮助确定为什么我在sails.js应用程序中的单元测试没有按预期工作.

我在sails.js应用程序上使用mocha,chai和bluebird promise库.

我想要实现的目标:

  • 为TagsService.create(name)方法创建一个测试,该方法接受一个name参数.
  • 测试此方法不会根据我传递的无效名称创建新的标记记录
  • name参数是必需的,长度应小于121个字符

我目前拥有的:

// Test the 'create' method
describe('Method \'create\' test result: \n', function () {
  
  // Test that name is required and less than 121 chars long
  it('Must receive the name parameter and be less than 121 chars long', function(done) {
		
    // It should not accept any of the following names
    var names = ['',' ','thisstringislongerthanthemaxof121characterslongthisstringislongerthanthemaxof121characterslongthisstringislongerthanthema',[],[{}],[{test: 'test'}],'wrongchars*[]$£%fsf','$%@~}[','£$%jkdfi',' $%"£asdwdFDE','hD8U £$&{DS ds'];
    
    
      sails.bluebird.each(names,function(name){
        TagsService.create(name).then(function(data){
          assert.propertyVal(data,'status','err','An error was NOT returned - even though names provided should be …
Run Code Online (Sandbox Code Playgroud)

mocha.js chai sails.js bluebird

5
推荐指数
1
解决办法
419
查看次数

标签 统计

bluebird ×1

chai ×1

mocha.js ×1

sails.js ×1