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


TypeScript helper.createSpy函数代码示例

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


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

示例1: before

  before(function() {
    optionHandler1 = createSpy();
    optionHandler2 = createSpy();
    options = {
      'label1': optionHandler1,
      'label2': optionHandler2
    };

    optionList = new OptionList(options);

    domElement = getWidgetDOMElement(optionList);
    optionButton1 = domElement.children[0];
    optionButton2 = domElement.children[1];
  });
开发者ID:gurdiga,项目名称:xo,代码行数:14,代码来源:OptionListTest.ts

示例2: before

  before(function() {
    optionHandler1 = createSpy();
    optionHandler2 = createSpy();
    options = {
      'label1': optionHandler1,
      'label2': optionHandler2
    };

    labelText = 'Add';
    dropdownButton = new DropdownButton(labelText, options);

    domElement = getWidgetDOMElement(dropdownButton);
    toggleButton = domElement.firstChild;
    optionList = domElement.querySelector('option-list');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:15,代码来源:DropdownButtonTest.ts

示例3: before

  before(function() {
    onClick = createSpy();

    sandbox = document.createElement('div');
    newCaseButton = new NewCaseButton();
    newCaseButton.onClick(onClick);
    newCaseButton.appendTo(sandbox);
  });
开发者ID:gurdiga,项目名称:xo,代码行数:8,代码来源:NewCaseButtonTest.ts

示例4: it

  it('accepts to reset its options', function() {
    var handlerA = createSpy();
    var handlerB = createSpy();
    var newOptions = {
      'labelA': handlerA,
      'labelB': handlerB
    };

    optionList.setOptions(newOptions);

    var optionLabels = _.toArray(domElement.children).map(_.property('textContent'));
    assert.deepEqual(optionLabels, Object.keys(newOptions), 'option buttons have the expected labels');

    var optionA = domElement.children[0];
    optionA.click();
    optionA.click();
    assert.deepEqual(handlerA.calls.length, 2, 'clicking on an option calls its corresponding handler');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:18,代码来源:OptionListTest.ts

示例5: it

  it('announces its changes', function() {
    var callback = createSpy();

    labeledCheckbox.setValue(false);
    labeledCheckbox.onChange(callback);
    checkbox.click();

    assert(callback.executed, 'calls the given callback');
    assert(callback.calls[0].args[0] === true, 'the callback is passed the current state of the checkbox');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:10,代码来源:LabeledCheckboxTest.ts

示例6: before

  before(function() {
    activities = [
      new InstitutionActivity()
    ];
    activityAdder = createSpy();
    addActivityButton = new AddActivityButton(activities, activityAdder);

    domElement = getWidgetDOMElement(addActivityButton);
    optionButtons = _.toArray(domElement.querySelectorAll('dropdown-button>option-list>button'));
  });
开发者ID:gurdiga,项目名称:xo,代码行数:10,代码来源:AddActivityButtonTest.ts

示例7: it

  it('works with a thing that has a `hide` method', function() {
    var thing = { hide: createSpy() };

    hideOnEscapeOrOutsideClick(thing);

    document.body.dispatchEvent(new Event('click'));
    assert.equal(thing.hide.calls.length, 1, 'calls thing’s hide method when clicking the body');

    simulateEscapeKey();
    assert.equal(thing.hide.calls.length, 2, 'calls thing’s hide method when pressing the Esc key');
  });
开发者ID:gurdiga,项目名称:xo,代码行数:11,代码来源:hideOnEscapeOrOutsideClickTest.ts

示例8: beforeEach

  beforeEach(function() {
    value = '25.06.2015';
    dateFieldInput = new DateFieldInput(value);

    domElement = getWidgetDOMElement(dateFieldInput);
    datePickerButton = domElement.nextSibling;

    sandbox = domElement.parentNode;
    document.body.appendChild(sandbox);

    bodyClickListener = createSpy();
    document.body.addEventListener('click', bodyClickListener);
  });
开发者ID:gurdiga,项目名称:xo,代码行数:13,代码来源:DateFieldInputTest.ts

示例9: it

    it('can be reset', function() {
      var optionHandler = createSpy();
      var newOptions = {
        'label': optionHandler
      };

      var expectedOptionLabels = Object.keys(newOptions);

      dropdownButton.resetOptionList(newOptions);

      var optionButtons = optionList.querySelectorAll('button');
      var optionButtonLabels = _.map(optionButtons, _.property('textContent'));
      assert.deepEqual(optionButtonLabels, expectedOptionLabels, 'options are updated');
    });
开发者ID:gurdiga,项目名称:xo,代码行数:14,代码来源:DropdownButtonTest.ts

示例10: before

  before(function() {
    sandbox = document.createElement('div');
    domElement = document.createElement('the-widget');

    domElement.style.color = 'green';
    sandbox.appendChild(domElement);

    onRemove = createSpy();

    additionalButtonStyle = {
      color: 'red',
      top: '50px'
    };

    makeRemovable(domElement, onRemove, additionalButtonStyle);
  });
开发者ID:gurdiga,项目名称:xo,代码行数:16,代码来源:makeRemovableTest.ts


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