• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript test_lib.beforeEach函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: describe

    describe("PercentPipe", () => {
      var pipe;

      beforeEach(() => { pipe = new PercentPipe(); });

      describe("transform", () => {
        it('should return correct value for numbers', () => {
          expect(pipe.transform(1.23, [])).toEqual('123%');
          expect(pipe.transform(1.2, ['.2'])).toEqual('120.00%');
        });

        it("should not support other objects",
           () => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
      });
    });
开发者ID:lavinjj,项目名称:angular,代码行数:15,代码来源:number_pipe_spec.ts


示例2: describe

  describe("DirectiveResolver", () => {
    var reader;

    beforeEach(() => { reader = new DirectiveResolver(); });

    it('should read out the Directive annotation', () => {
      var directiveMetadata = reader.resolve(SomeDirective);
      expect(directiveMetadata).toEqual(new dirAnn.Directive({selector: 'someDirective'}));
    });

    it('should throw if not matching annotation is found', () => {
      expect(() => { reader.resolve(SomeDirectiveWithoutAnnotation); })
          .toThrowError('No Directive annotation found on SomeDirectiveWithoutAnnotation');
    });
  });
开发者ID:188799958,项目名称:angular,代码行数:15,代码来源:directive_metadata_reader_spec.ts


示例3: describe

  describe("key", function() {
    var registry;

    beforeEach(function() { registry = new KeyRegistry(); });

    it('should be equal to another key if type is the same',
       function() { expect(registry.get('car')).toBe(registry.get('car')); });

    it('should not be equal to another key if types are different',
       function() { expect(registry.get('car')).not.toBe(registry.get('porsche')); });

    it('should return the passed in key',
       function() { expect(registry.get(registry.get('car'))).toBe(registry.get('car')); });

  });
开发者ID:188799958,项目名称:angular,代码行数:15,代码来源:key_spec.ts


示例4: describe

	describe('logo', () => {
		var injector: Injector;
		var backend: MockBackend;
		var response;
		
		beforeEachBindings(() => [
			BaseRequestOptions,
			MockBackend,
			bind(Http).toFactory((connectionBackend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
				return new Http(connectionBackend, defaultOptions);
			}, [
				MockBackend,
				BaseRequestOptions
			]),
			bind(IconStore).toClass(IconStore, [
				Http
			])
		]);

		beforeEach(() => {
			injector = Injector.resolveAndCreate([
				MockBackend
			]);
			backend = injector.get(MockBackend);
			response = new Response({ body: LOGO_GLYPH_HTML });
		});
		
		afterEach(() => backend.verifyNoPendingRequests());
		
		it('should append an svg as child of self', inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
			let html = '<div class="logo" logo></div>';
			ObservableWrapper.subscribe(backend.connections, (connection: MockConnection) => {
				// console.log(connection);
				connection.mockRespond(response)
			});
			tcb
				.overrideTemplate(Test, html)
				.createAsync(Test)
				.then((rootTC) => {
					rootTC.detectChanges();
					let logo: Element = DOM.querySelector(rootTC.nativeElement, '.logo');
					let prefixSelector = isNativeShadowDOMSupported ? '* /deep/ ' : ''; // soon use '>>>' https://www.chromestatus.com/features/6750456638341120
					// console.log(logo.firstChild, prefixSelector);
					// expect(logo.querySelector(prefixSelector + 'svg')).not.toBe(null);
					async.done();
				});
		}));
	});
开发者ID:Luphia,项目名称:Laria,代码行数:48,代码来源:logo.spec.ts


示例5: describe

      describe("dirty", () => {
        var c, g;

        beforeEach(() => {
          c = new Control('value');
          g = new ControlGroup({"one": c});
        });

        it("should be false after creating a control", () => { expect(g.dirty).toEqual(false); });

        it("should be false after changing the value of the control", () => {
          c.markAsDirty();

          expect(g.dirty).toEqual(true);
        });
      });
开发者ID:B-Thapa,项目名称:angular,代码行数:16,代码来源:model_spec.ts


示例6: describe

        describe("dirty", () => {
          var c, a;

          beforeEach(() => {
            c = new Control('value');
            a = new ControlArray([c]);
          });

          it("should be false after creating a control", () => { expect(a.dirty).toEqual(false); });

          it("should be false after changing the value of the control", () => {
            c.markAsDirty();

            expect(a.dirty).toEqual(true);
          });
        });
开发者ID:MigCoder,项目名称:angular,代码行数:16,代码来源:model_spec.ts


示例7: describe

  describe('TemplateCloner', () => {
    var cloner: TemplateCloner;
    var bigTemplate: Element;
    var smallTemplate: Element;

    beforeEach(() => {
      cloner = new TemplateCloner(1);
      bigTemplate = DOM.createTemplate('a<div></div>');
      smallTemplate = DOM.createTemplate('a');
    });

    describe('prepareForClone', () => {
      it('should use a reference for small templates',
         () => { expect(cloner.prepareForClone(smallTemplate)).toBe(smallTemplate); });

      it('should use a reference if the max element count is -1', () => {
        cloner = new TemplateCloner(-1);
        expect(cloner.prepareForClone(bigTemplate)).toBe(bigTemplate);
      });

      it('should use a string for big templates', () => {
        expect(cloner.prepareForClone(bigTemplate)).toEqual(DOM.getInnerHTML(bigTemplate));
      });
    });

    describe('cloneTemplate', () => {

      function shouldReturnTemplateContentNodes(template: Element, importIntoDoc: boolean) {
        var clone = cloner.cloneContent(cloner.prepareForClone(template), importIntoDoc);
        expect(clone).not.toBe(DOM.content(template));
        expect(DOM.getText(DOM.firstChild(clone))).toEqual('a');
      }

      it('should return template.content nodes (small template, no import)',
         () => { shouldReturnTemplateContentNodes(smallTemplate, false); });

      it('should return template.content nodes (small template, import)',
         () => { shouldReturnTemplateContentNodes(smallTemplate, true); });

      it('should return template.content nodes (big template, no import)',
         () => { shouldReturnTemplateContentNodes(bigTemplate, false); });

      it('should return template.content nodes (big template, import)',
         () => { shouldReturnTemplateContentNodes(bigTemplate, true); });
    });

  });
开发者ID:goderbauer,项目名称:angular,代码行数:47,代码来源:template_cloner_spec.ts


示例8: describe

 describe('NativeShadowDomStratgey', () => {
   beforeEach(() => {
     var urlResolver = new UrlResolver();
     var styleUrlResolver = new StyleUrlResolver(urlResolver);
     strategy = new NativeShadowDomStrategy(styleUrlResolver);
   });
   it('should attach the view nodes to the shadow root', () => {
     var host = el('<div></div>');
     var nodes = el('<div>view</div>');
     var pv = new ProtoView(nodes, new DynamicProtoChangeDetector(null, null), null);
     var view = pv.instantiate(null, null);
     strategy.attachTemplate(host, view);
     var shadowRoot = DOM.getShadowRoot(host);
     expect(isPresent(shadowRoot)).toBeTruthy();
     expect(shadowRoot).toHaveText('view');
   });
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:17,代码来源:shadow_dom_strategy_spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript test_lib.beforeEachBindings函数代码示例发布时间:2022-05-25
下一篇:
TypeScript test.TestComponentBuilder类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap