当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.throws方法代码示例

本文整理汇总了TypeScript中test/helper.assert.throws方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.throws方法的具体用法?TypeScript assert.throws怎么用?TypeScript assert.throws使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test/helper.assert的用法示例。


在下文中一共展示了assert.throws方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('throws meaningful error messages', function() {
      assert.throws(function callWithABadTagNameArgument() {
        var badTagName = 42;
        domElement = createDOMElement(badTagName);
      },
        'createDOMElement expects the first argument, tagName, to be a DOM element'
      );

      assert.throws(function callWithABadStyleArgument() {
        var badStyle = 42;

        domElement = createDOMElement('thing', badStyle);
      },
        'createDOMElement expects the second argument, style, to be a hash'
      );

      assert.throws(function callWithABadAttributesArgument() {
        var goodStyle = {};
        var badAttributes = 42;

        domElement = createDOMElement('thing', goodStyle, badAttributes);
      },
        'createDOMElement expects the third argument, attributes, to be a hash'
      );
    });
开发者ID:gurdiga,项目名称:xo,代码行数:25,代码来源:createDOMElementTest.ts

示例2: it

  it('validates input', function() {
    var domElement = createDOMElement('div');
    var style = { color: 'red' };

    assert.throws(function() {
      toggleStyle(42);
    },
      'toggleStyle expects the first argument to be a DOM element'
    );

    assert.throws(function() {
      toggleStyle(domElement, 42);
    },
      'toggleStyle expects the second argument, style, to be a hash'
    );

    assert.throws(function() {
      toggleStyle(domElement, style, 42);
    },
      'toggleStyle expects the third argument, onEventName, to be a string'
    );

    assert.throws(function() {
      toggleStyle(domElement, style, 'mouseenter', 42);
    },
      'toggleStyle expects the third argument, offEventName, to be a string'
    );
  });
开发者ID:gurdiga,项目名称:xo,代码行数:28,代码来源:toggleStyleTest.ts

示例3: it

  it('validates input', function() {
    assert.throws(function() {
      addHoverEffect(42);
    },
      'addHoverEffect expects the first argument to be a DOM element'
    );

    assert.throws(function() {
      addHoverEffect(domElement, 42);
    },
      'addHoverEffect expects the second argument, style, to be a hash'
    );
  });
开发者ID:gurdiga,项目名称:xo,代码行数:13,代码来源:addHoverEffectTest.ts

示例4: it

    it('throws meaningful errors', function() {
      assert.throws(function runWithoutTheFirstArgument() {
        DateFormatting.format();
      },
        'DateFormatting.format: the first argument is required and has to be a JS Date instance'
      );

      assert.throws(function runWithoutTheSecondArgument() {
        DateFormatting.format(date);
      },
        'DateFormatting.format: the second argument is required and has to be a string representing the date format mask to represent date as'
      );
    });
开发者ID:gurdiga,项目名称:xo,代码行数:13,代码来源:DateFormattingTest.ts

示例5: it

  it('validates input', function() {
    assert.throws(function() {
      makeRemovable(42);
    },
      'makeRemovable: the first argument is required to be a DOM element'
    );

    assert.throws(function() {
      makeRemovable(domElement);
    },
      'makeRemovable: the second argument is required to be a function to call back on remove'
    );
  });
开发者ID:gurdiga,项目名称:xo,代码行数:13,代码来源:makeRemovableTest.ts

示例6: it

    it('throws meaningful error messages', function() {
      assert.throws(function() {
        addStyle(42);
      },
        'addStyle expects the first argument to be a DOM element'
      );

      assert.throws(function() {
        addStyle(createDOMElement('div'), 42);
      },
        'addStyle expects the second argument to be a hash'
      );
    });
开发者ID:gurdiga,项目名称:xo,代码行数:13,代码来源:addStyleTest.ts

示例7: it

  it('validates input', function() {
    assert.throws(function() {
      var getValue = getFieldValueCollector([field1, field2, {}]);
      getValue();
    },
      'Every field is expected to have an internalName'
    );

    assert.throws(function() {
      var getValue = getFieldValueCollector([field1, field2, { internalName: 'yes' }]);
      getValue();
    },
      'Every field is expected to have a getValue method'
    );
  });
开发者ID:gurdiga,项目名称:xo,代码行数:15,代码来源:getFieldValueCollectorTest.ts

示例8: it

 it('validates input', function() {
   assert.throws(function() {
     new CompletionLabel(); // eslint-disable-line no-new
   },
     'CompletionLabel expects the completionTime argument to be a Date object'
   );
 });
开发者ID:gurdiga,项目名称:xo,代码行数:7,代码来源:CompletionLabelTest.ts

示例9: it

 it('validates input', function() {
   assert.throws(function callingWithNonPlainObject() {
     Activity.createWithData(42);
   },
     'Activity.createWithData expects the argument to be a plain JS object'
   );
 });
开发者ID:gurdiga,项目名称:xo,代码行数:7,代码来源:ActivityTest.ts

示例10: it

 it('requires the label text to be a string', function() {
   assert.throws(function callingWithInvalidTextLabel() {
     new TodoItem(id, 42); // eslint-disable-line no-new
   },
     'TodoItem constructor expects the first argument, label text, to be a string'
   );
 });
开发者ID:gurdiga,项目名称:xo,代码行数:7,代码来源:TodoItemTest.ts


注:本文中的test/helper.assert.throws方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。