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


TypeScript Mocks.object方法代码示例

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


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

示例1: it

    it('should call the overlay service correctly', async () => {
      const parentWidth = 123;
      const parentElement = Mocks.object('parentElement');
      parentElement.clientWidth = parentWidth;

      Graph.createProvider($.host.fitParentWidth.getId(), true);

      const anchorPoint = AnchorLocation.BOTTOM_LEFT;
      Graph.createProvider($.host.anchorPoint.getId(), anchorPoint);

      const anchorTarget = AnchorLocation.TOP_RIGHT;
      Graph.createProvider($.host.anchorTarget.getId(), anchorTarget);

      const menuContentStyle = Mocks.object('menuContentStyle');
      const menuContent = Mocks.object('menuContent');
      menuContent.style = menuContentStyle;

      const element = Mocks.object('element');
      element.firstElementChild = menuContent;
      element.parentElement = parentElement;
      Object.setPrototypeOf(element, HTMLElement.prototype);
      Graph.createProvider($.host.el.getId(), element);

      await menu['setOverlayVisible_'](true, Graph.getTimestamp());
      assert(mockOverlayService.showOverlay).to.haveBeenCalledWith(
          menu['id_'],
          element,
          menuContent,
          parentElement,
          anchorTarget,
          anchorPoint);
      assert(menuContentStyle.width).to.equal(`${parentWidth}px`);
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:33,代码来源:menu_test.ts

示例2: it

    it('should update the highlight element correctly', () => {
      const currentStart = 12;
      const currentLength = 34;
      const targetStart = 56;
      const targetLength = 78;

      const animate = Mocks.object('animate');
      const mockAnimation = jasmine.createSpyObj('Animation', ['start']);
      mockAnimation.start.and.returnValue(animate);
      spyOn(Animation, 'newInstance').and.returnValue(mockAnimation);

      const keyframe1 = Mocks.object('keyframe1');
      const keyframe2 = Mocks.object('keyframe2');
      Fakes.build(spyOn(tab, 'getAnimationKeyframe'))
          .when(currentStart).return(keyframe1)
          .when(targetStart).return(keyframe2);

      spyOn(tab, 'setHighlightEl');

      tab['setHighlight_'](targetStart, targetLength, currentStart, currentLength);

      assert(mockAnimation.start).to.haveBeenCalledWith(tab, HIGHLIGHT_EL);
      assert(Animation.newInstance).to.haveBeenCalledWith(
          [keyframe1, keyframe2],
          Matchers.any(Object),
          Matchers.anyThing());
      assert(tab['getAnimationKeyframe']).to.haveBeenCalledWith(currentStart, currentLength);
      assert(tab['getAnimationKeyframe']).to.haveBeenCalledWith(targetStart, targetLength);
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:29,代码来源:base-tab_test.ts

示例3: it

 it('should apply the theme to the shadow root', () => {
   const shadowRoot = Mocks.object('shadowRoot');
   const htmlElement = Mocks.object('htmlElement');
   htmlElement.shadowRoot = shadowRoot;
   element.onCreate(htmlElement);
   assert(mockThemeService.applyTheme).to.haveBeenCalledWith(shadowRoot);
 });
开发者ID:garysoed,项目名称:gs-ui,代码行数:7,代码来源:base-themed-element2_test.ts

示例4: it

    it('should return the correct color', () => {
      const foreground = Mocks.object('foreground');
      const background = Mocks.object('background');
      const contrast = 12;

      const mixColor = Mocks.object('mixColor');
      spyOn(Colors, 'mix').and.returnValue(mixColor);

      const alpha = 0.34;
      const spySolve = spyOn(Solve, 'findThreshold').and.returnValue(alpha);

      assert(Theme['getForegroundFade_'](foreground, background, contrast)).to.equal(mixColor);
      assert(Colors.mix).to.haveBeenCalledWith(foreground, background, alpha);
      assert(Solve.findThreshold).to.haveBeenCalledWith(
          Matchers.any(Spec),
          Matchers.any(Function) as any,
          false);
      assert(spySolve.calls.argsFor(0)[0].getStart()).to.equal(0);
      assert(spySolve.calls.argsFor(0)[0].getDelta()).to.equal(0.1);
      assert(spySolve.calls.argsFor(0)[0].getEnd()).to.equal(1);

      const testAlpha = 0.56;
      spyOn(Theme, 'isHighContrastForegroundAlpha_').and.returnValue(true);
      assert(spySolve.calls.argsFor(0)[1](testAlpha) as boolean).to.beTrue();
      assert(Theme['isHighContrastForegroundAlpha_']).to.haveBeenCalledWith(
          foreground,
          background,
          testAlpha,
          contrast);
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:30,代码来源:theme_test.ts

示例5: it

    it('should do nothing if not valid', () => {
      const mimeTypes = Mocks.object('mimeTypes');
      const dataTransfer = Mocks.object('dataTransfer');

      const mockEvent = jasmine.createSpyObj('Event', ['preventDefault', 'stopPropagation']);
      mockEvent.dataTransfer = dataTransfer;

      const newBundleId = 'bundleId';
      const deleteBundleFn = Mocks.object('deleteBundleFn');
      mockFileService.addBundle.and.returnValue({deleteFn: deleteBundleFn, id: newBundleId});

      spyOn(input, 'isValid_').and.returnValue(false);
      spyOn(input, 'onDragLeave_');

      const mockDeleteBundleFn = jasmine.createSpy('DeleteBundleFn');
      const fakeBundleFnSetter = new FakeMonadSetter<DeleteBundleFn | null>(mockDeleteBundleFn);
      const fakeBundleIdSetter = new FakeMonadSetter<string | null>(null);

      const list = input.onDrop_(
          mockEvent,
          fakeBundleFnSetter,
          fakeBundleIdSetter,
          mimeTypes);
      assert([...list]).to.equal([]);
      assert(mockFileService.addBundle).toNot.haveBeenCalled();
      assert(mockEvent.preventDefault).to.haveBeenCalledWith();
      assert(mockEvent.stopPropagation).to.haveBeenCalledWith();
      assert(input['isValid_']).to.haveBeenCalledWith(mimeTypes, dataTransfer);
      assert(mockDeleteBundleFn).toNot.haveBeenCalled();
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:30,代码来源:file-input_test.ts

示例6: spyOn

        () => {
          const height = 123;
          const width = 456;
          const assignedNode = Mocks.object('distributedElement');
          assignedNode.clientHeight = height;
          assignedNode.clientWidth = width;

          const mockSlotEl = jasmine.createSpyObj('SlotEl', ['assignedNodes']);
          mockSlotEl.assignedNodes.and.returnValue([assignedNode]);

          const mockClassList = jasmine.createSpyObj('ClassList', ['add']);
          const rootEl = Mocks.object('rootEl');
          rootEl.classList = mockClassList;
          rootEl.style = {};

          const mockDispatcher = jasmine.createSpy('Dispatcher');

          const mockAnimation = jasmine.createSpyObj('Animation', ['start']);
          spyOn(OverlayContainer['BASE_SHOW_ANIMATION_'], 'appendKeyframe').and
              .returnValue(mockAnimation);

          container['show_'](rootEl, mockSlotEl, mockDispatcher);

          assert(mockDispatcher).to.haveBeenCalledWith('gs-show', {});

          assert(mockClassList.add).to.haveBeenCalledWith(OverlayContainer['SHOW_CLASS_']);
          assert(mockAnimation.start).to.haveBeenCalledWith(container, '#container');
          assert(OverlayContainer['BASE_SHOW_ANIMATION_'].appendKeyframe).to.haveBeenCalledWith(
              Matchers.objectContaining({
                height: `${height}px`,
                width: `${width}px`,
              }));
        });
开发者ID:garysoed,项目名称:gs-ui,代码行数:33,代码来源:overlay-container_test.ts

示例7: it

    it('should do nothing if background color cannot be determined', async () => {
      const customStyleEl = Mocks.object('customStyleEl');

      const baseHue = Mocks.object('baseHue');
      const mockTheme = jasmine.createSpyObj('Theme', ['getBaseHue']);
      mockTheme.getBaseHue.and.returnValue(baseHue);
      mockThemeService.getTheme.and.returnValue(mockTheme);

      spyOn(Colors, 'fromCssColor').and.returnValue(null);

      const backgroundColorString = 'backgroundColorString';
      mockWindow.getComputedStyle.and.returnValue({backgroundColor: backgroundColorString});

      const editorEl = Mocks.object('editorEl');

      mockThemeService.isHighlightMode.and.returnValue(false);
      mockThemeService.isReversedMode.and.returnValue(false);

      TestGraph.set($.editor.el.getId(), input, editorEl);
      TestGraph.set($.customStyle.el.getId(), input, customStyleEl);

      await input.onThemeChanged_();

      assert(customStyleEl.innerHTML).toNot.beDefined();
    });
开发者ID:garysoed,项目名称:gs-ui,代码行数:25,代码来源:code-input_test.ts


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