本文整理汇总了TypeScript中external/gs_tools/src/mock.Fakes.build方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Fakes.build方法的具体用法?TypeScript Fakes.build怎么用?TypeScript Fakes.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类external/gs_tools/src/mock.Fakes
的用法示例。
在下文中一共展示了Fakes.build方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return WHITE if it has a bigger contrast', () => {
Fakes.build(spyOn(Colors, 'getContrast'))
.when(BLACK).return(12)
.when(WHITE).return(34);
assert(theme.getBlackOnAccent()).to.equal(WHITE);
assert(Colors.getContrast).to.haveBeenCalledWith(BLACK, accent);
assert(Colors.getContrast).to.haveBeenCalledWith(WHITE, accent);
});
示例2: it
it(`should do nothing if the ID does not match`, () => {
const mockMenuContainer = jasmine.createSpyObj('MenuContainer', ['setAttribute']);
spyOn(service, 'getShownId_').and.returnValue(Symbol('otherId'));
Fakes.build(spyOn(OverlayBus, 'dispatch')).call((_: any, fn: () => void) => fn());
service.hideOverlay(Symbol('id'));
assert(mockMenuContainer.setAttribute).toNot.haveBeenCalled();
assert(OverlayBus.dispatch).toNot.haveBeenCalled();
});
示例3: it
it(`should handle '.' and '/' correctly`, async () => {
const value = './.';
const normalizedValue = '___';
const height = 12;
const width = 34;
const clientRect = {height, width} as any;
const center = Vector2d.of(56, 78);
const rootEl = document.createElement('div');
spyOn(rootEl, 'getBoundingClientRect').and.returnValue(clientRect);
const otherEl = document.createElement('div');
otherEl.id = normalizedValue;
rootEl.appendChild(otherEl);
const containerEl = document.createElement('div');
const slotContainerEl = document.createElement('div');
const slotEl = document.createElement('slot');
let callCount = 0;
Fakes.build(mockDocument.createElement)
.when('div').call(() => {
const toReturn = callCount === 0 ? slotContainerEl : containerEl;
callCount++;
return toReturn;
})
.when('slot').return(slotEl);
const lastAction = Mocks.object('lastAction');
spyOn(ActionTracker, 'get').and.returnValue(Promise.resolve(lastAction));
const mockContainerAnimation = jasmine.createSpyObj('ContainerAnimation', ['start']);
const mockSlotAnimation = jasmine.createSpyObj('SlotAnimation', ['start']);
spyOn(switchEl, 'computeAnimations_').and.returnValue({
container: mockContainerAnimation,
slot: mockSlotAnimation,
});
spyOn(switchEl, 'getAnimationCircleCenter_').and.returnValue(center);
await switchEl.onValueChange_(value, rootEl);
assert(mockSlotAnimation.start).to.haveBeenCalledWith(switchEl, `#${normalizedValue} > *`);
assert(mockContainerAnimation.start).to.haveBeenCalledWith(switchEl, `#${normalizedValue}`);
assert(rootEl).to.haveChildren([containerEl]);
assert(containerEl).to.haveChildren([slotContainerEl]);
assert(containerEl).to.haveClasses(['container']);
assert(containerEl.id).to.equal(normalizedValue);
assert(slotContainerEl).to.haveChildren([slotEl]);
assert(slotContainerEl).to.haveClasses(['slotContainer']);
assert(slotContainerEl.style).to
.equal(Matchers.objectContaining({height: `${height}px`, width: `${width}px`}));
assert(slotEl.getAttribute('name')).to.equal(value);
assert(switchEl['computeAnimations_']).to.haveBeenCalledWith(clientRect, center);
assert(switchEl['getAnimationCircleCenter_']).to.haveBeenCalledWith(lastAction);
});
示例4: it
it('should not unselect any buttons if the request is to unselect a button', () => {
const mockOtherButton = jasmine.createSpyObj('OtherButton', ['setAttribute']);
mockDocument.querySelector.and.returnValue(mockOtherButton);
Fakes.build(mockButtonEl.getAttribute)
.when('group-id').return('group')
.when('checked').return('true');
service.setSelected(mockButtonEl, false);
assert(mockButtonEl.setAttribute).to.haveBeenCalledWith('checked', 'false');
assert(mockOtherButton.setAttribute).toNot.haveBeenCalled();
});