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


TypeScript TestComponentBuilder.overrideProviders方法代码示例

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


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

示例1: inject

      inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
        tcb.overrideProviders(ContactFormComponent, [provide(ContactService, { useValue: contactService })])
          .createAsync(ContactFormComponent).then((fixture) => {

            fixture.detectChanges();

            const originalLength = contacts.length;
            
            expect(originalLength).toBeGreaterThan(0);

            const cmp: ContactFormComponent = fixture.componentInstance;
            
            const newContact: Contact = { name: 'Test', email: 'test@example.com' };            
            
            cmp.contact = newContact;
            
            cmp.save();            

            fixture.detectChanges();
            
            const createdContact = contacts[originalLength];
            
            expect(contacts.length).toBe(originalLength + 1);            
            expect(createdContact.name).toEqual(newContact.name);
            expect(createdContact.email).toEqual(newContact.email);        
            expect(cmp.contact).toEqual({});

            async.done();
          });
      }));
开发者ID:truckfondue,项目名称:angular2-minimalist-starter,代码行数:30,代码来源:contact-form.component_spec.ts

示例2: inject

      inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
        tcb.overrideProviders(ContactComponent, [provide(ContactService, { useValue: contactService })])
          .createAsync(ContactComponent).then((fixture) => {

            fixture.detectChanges();

            const cmp: ContactComponent = fixture.componentInstance;

            const compiled = fixture.debugElement.nativeElement;
            expect(compiled.querySelector('h2').textContent).toEqual('Contacts!');

            const itemsSelector = 'tbody tr';

            function obtainContactsLenght() {
              return compiled.querySelectorAll(itemsSelector).length;
            }

            const originalLength = obtainContactsLenght();
            let newLength = originalLength;
            
            expect(originalLength).toBeGreaterThan(0);            
            expect(originalLength).toBe(contacts.length);

            const existingContact = ObjectUtil.clone(contacts[0]);

            cmp.select(existingContact._id);

            fixture.detectChanges();

            const selectedContact = cmp.selectedContact;

            expect(selectedContact._id).toBe(existingContact._id);
            expect(selectedContact.name).toBe(existingContact.name);

            cmp.remove(new Event('mock'), existingContact);

            fixture.detectChanges();

            newLength--;

            expect(obtainContactsLenght()).toBe(newLength);

            async.done();
          });
      }));
开发者ID:brunkb,项目名称:a2-contact,代码行数:45,代码来源:spec.ts

示例3: createInjector

 function createInjector(tcb: TestComponentBuilder, proviers: any[]): Promise<Injector> {
   return tcb.overrideProviders(MyComp, [proviers])
       .createAsync(MyComp)
       .then((fixture) => fixture.componentInstance.injector);
 }
开发者ID:CutiePanther,项目名称:angular,代码行数:5,代码来源:regression_integration_spec.ts


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