本文整理汇总了TypeScript中external/gs_tools/src/mock.Mocks类的典型用法代码示例。如果您正苦于以下问题:TypeScript Mocks类的具体用法?TypeScript Mocks怎么用?TypeScript Mocks使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mocks类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should throw error if the ace editor CSS style cannot be found', () => {
const mockSession = jasmine.createSpyObj('Session', ['setTabSize', 'setUseSoftTabs']);
const mockEditor = jasmine.createSpyObj(
'Editor',
[
'destroy',
'setFontSize',
'setHighlightActiveLine',
'setReadOnly',
]);
mockEditor.session = mockSession;
mockAce.edit.and.returnValue(mockEditor);
const mockShadowRoot = jasmine.createSpyObj('ShadowRoot', ['appendChild', 'querySelector']);
const containerEl = Mocks.object('containerEl');
containerEl.parentNode = mockShadowRoot;
mockDocument.getElementById.and.returnValue(null);
spyOn(input, 'addDisposable').and.callThrough();
assert(() => {
input['getEditor_'](containerEl);
}).to.throwError(/css not found/);
assert(mockDocument.getElementById).to.haveBeenCalledWith('ace_editor.css');
});
示例2: it
it('should set the correct target element to active', () => {
const rootEl = Mocks.object('rootEl');
const fullPath = 'fullPath';
const slotName = 'slotName';
const path = 'path';
const childWithPath = document.createElement('div');
childWithPath.setAttribute('gs-view-path', path);
childWithPath.setAttribute('slot', slotName);
const childNoPath = document.createElement('div');
const element = document.createElement('div');
element.appendChild(childNoPath);
element.appendChild(childWithPath);
element[__fullPath] = fullPath;
const appendedPath = 'appendedPath';
spyOn(LocationService, 'appendParts').and.returnValue(appendedPath);
spyOn(LocationService, 'hasMatch').and.returnValue(true);
spyOn(viewSlot, 'setRootElVisible_');
const fakeSwitchValueSetter = new FakeMonadSetter<string | null>(null);
const updates = viewSlot.updateActiveView_(element, rootEl, fakeSwitchValueSetter);
assert(fakeSwitchValueSetter.findValue(updates)!.value).to.equal(slotName);
assert(viewSlot['setRootElVisible_']).to.haveBeenCalledWith(rootEl, true);
assert(LocationService.appendParts).to.haveBeenCalledWith(ImmutableList.of([fullPath, path]));
assert(LocationService.hasMatch).to.haveBeenCalledWith(appendedPath);
assert(childWithPath.getAttribute('gs-view-active')).to.equal('true');
});
示例3: it
it('should resolve with the file content correctly', async () => {
const mockListenableFileReader = jasmine.createSpyObj('ListenableFileReader', ['dispose']);
spyOn(ListenableDom, 'of').and.returnValue(mockListenableFileReader);
const content = 'content';
const mockFileReader = jasmine.createSpyObj('FileReader', ['readAsText']);
mockFileReader.result = content;
mockFileReader.readyState = 2;
spyOn(service, 'createFileReader_').and.returnValue(mockFileReader);
const listenToSpy = spyOn(service, 'listenTo');
const file = Mocks.object('file');
const promise = service['processFile_'](file);
assert(mockFileReader.readAsText).to.haveBeenCalledWith(file);
assert(ListenableDom.of).to.haveBeenCalledWith(mockFileReader);
assert(service.listenTo).to.haveBeenCalledWith(
mockListenableFileReader,
DomEvent.LOADEND,
Matchers.any(Function) as any);
listenToSpy.calls.argsFor(0)[2]();
const actualContent = await promise;
assert(actualContent).to.equal(content);
assert(mockListenableFileReader.dispose).to.haveBeenCalledWith();
});
示例4: it
it('should throw error if shadow root is null', () => {
const element = Mocks.object('element');
element.shadowRoot = null;
assert(() => {
themedElement.onCreated(element);
}).to.throwError(/root is null/);
});
示例5: beforeEach
beforeEach(() => {
const injector = Mocks.object('injector');
mockThemeService = jasmine.createSpyObj('ThemeService', ['applyTheme', 'install']);
mockRegistrar = jasmine.createSpyObj('Registrar', ['register']);
main = new Main(injector, mockThemeService, mockRegistrar);
TestDispose.add(main);
});
示例6: it
it(`should hide the overlay if set to hide`, async () => {
Graph.createProvider($.host.fitParentWidth.getId(), false);
Graph.createProvider($.host.anchorPoint.getId(), AnchorLocation.BOTTOM_LEFT);
Graph.createProvider($.host.anchorTarget.getId(), AnchorLocation.TOP_RIGHT);
const parentElement = Mocks.object('parentElement');
parentElement.clientWidth = 123;
const element = Mocks.object('element');
element.parentElement = parentElement;
Object.setPrototypeOf(element, HTMLElement.prototype);
Graph.createProvider($.host.el.getId(), element);
await menu['setOverlayVisible_'](false, Graph.getTimestamp());
assert(mockOverlayService.hideOverlay).to.haveBeenCalledWith(menu['id_']);
});
示例7: it
it('should set the top and height correctly', () => {
const start = 123;
const length = 456;
const style = Mocks.object('style');
tab.setHighlightEl(start, length, {style} as HTMLElement);
assert(style).to.equal(Matchers.objectContaining({top: `${start}px`, height: `${length}px`}));
});
示例8: it
it(`should return the ID in the container element`, () => {
const shownId = Symbol('shownId');
const containerEl = Mocks.object('containerEl');
containerEl[__shownId] = shownId;
spyOn(service, 'getOverlayContainerEl_').and.returnValue(containerEl);
assert(service['getShownId_']()).to.equal(shownId);
});