本文整理汇总了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];
});
示例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');
});
示例3: before
before(function() {
onClick = createSpy();
sandbox = document.createElement('div');
newCaseButton = new NewCaseButton();
newCaseButton.onClick(onClick);
newCaseButton.appendTo(sandbox);
});
示例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');
});
示例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');
});
示例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'));
});
示例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');
});
示例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);
});
示例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');
});
示例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);
});