當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript testing.beforeEach函數代碼示例

本文整理匯總了TypeScript中@angular/testing.beforeEach函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript beforeEach函數的具體用法?TypeScript beforeEach怎麽用?TypeScript beforeEach使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了beforeEach函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('SumPipe', () => {
    
    let pipe: SumPipe;
    
    beforeEach(() => {
       pipe = new SumPipe(); 
    });
    
    it('Should return 10', () => {
        
        expect(pipe.transform([1,2,3,4])).toEqual(10);
    });
    
    it('Should return 1', () => {
        
        expect(pipe.transform([1])).toEqual(1);
    });
    
    it('Should return 2', () => {
        
        expect(pipe.transform([1,1])).toEqual(2);
    });
    
    it('Should return 15', () => {
        
        expect(pipe.transform(15)).toEqual(15);
    });
    
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:29,代碼來源:sum.pipe.spec.ts

示例2: describe

describe('RepeatPipe', () => {
    
    let pipe: RepeatPipe;
    
    beforeEach(() => {
       pipe = new RepeatPipe(); 
    });
    
    it('Should do nothing', () => {
       
       expect(pipe.transform('a', 1, '')).toEqual('a');
    });
    
    it('Should repeat two times', () => {
       
       expect(pipe.transform('a', 2, '')).toEqual('aa');
    });
    
    it('Should repeat two times with space', () => {
       
       expect(pipe.transform('a', 2, ' ')).toEqual('a a');
    });


    it('Should return the value unchanged', () => {
       
       expect(pipe.transform(1, null)).toEqual(1); 
    });
   
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:30,代碼來源:repeat.pipe.spec.ts

示例3: describe

describe('CountPipe', () => {
    
    let pipe: CountPipe;
    
    beforeEach(() => {
       pipe = new CountPipe(); 
    });
    
    it('Should return the length of the collection', () => {
       
       expect(pipe.transform([1,2])).toEqual(2); 
    });
    
    it('Should return the length of the object (keys)', () => {
       
       expect(pipe.transform({ a: 1, b: 2, c: 3})).toEqual(3); 
    });
    
  
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a')).toEqual('a'); 
    });
    
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:26,代碼來源:count.pipe.spec.ts

示例4: describe

describe('CeilPipe', () => {
    
    let pipe: CeilPipe;
    
    beforeEach(() => {
       pipe = new CeilPipe(); 
    });
    
    it('Should return 4', () => {
        
        expect(pipe.transform(3.4, 0)).toEqual(4);
    });
    
    it('Should return 1', () => {
        
        expect(pipe.transform(1, 0)).toEqual(1);
    });
    
    it('Should return 1', () => {
        
        expect(pipe.transform(0.65, 0)).toEqual(1);
    });
    
    it('Should return 1.5', () => {
       
       expect(pipe.transform(1.5, 1)).toEqual(1.5); 
    });
    
    
    it('Should return 1.55', () => {
       
       expect(pipe.transform(1.5444, 2)).toEqual(1.55); 
    });
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:34,代碼來源:ceil.pipe.spec.ts

示例5: describe

describe('Login Component', () => {
  setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
  let tcb: TestComponentBuilder;

  beforeEachProviders(() => [
    TestComponentBuilder,
    provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
    provide(ViewResolver, {useClass: MockViewResolver}),
    LoginComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], (tcb_) => {
    tcb = tcb_;
  }));

  it('should render form', (done) => {
    tcb.createAsync(LoginComponent)
      .then((fixture) => {
        let element = fixture.nativeElement;
        fixture.detectChanges();
        let form = element.querySelector('form');
        expect(form).toBeTruthy();
        expect(form.querySelector('input[name="username"]')).toBeTruthy();
        expect(form.querySelector('input[name="password"]')).toBeTruthy();
        done();
      });
  });
});
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:28,代碼來源:login.component.spec.ts

示例6: describe

describe('TakePipe', () => {
    
    let pipe: TakePipe;
    
    beforeEach(() => {
       pipe = new TakePipe(); 
    });
    
    it('Should return []', () => {
       
       expect(pipe.transform([])).toEqual([]); 
    });
    
    it('Should return [1]', () => {
       
       const value = [1, 2, 3, 4];
       
       expect(pipe.transform(value)).toEqual([1]); 
       expect(value).toEqual([1, 2, 3, 4]); // Check integrity
    });
    
    it ('Should return [1, 2]', () => {
       
       expect(pipe.transform([1, 2, 3, 4], 2)).toEqual([1, 2]); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a')).toEqual('a'); 
    });
    
})
開發者ID:josx,項目名稱:angular-pipes,代碼行數:32,代碼來源:take.pipe.spec.ts

示例7: describe

describe('ToArrayPipe', () => {
    
    let pipe: ToArrayPipe;
    
    beforeEach(() => {
       pipe = new ToArrayPipe(); 
    });
    
    const value = {
        a: 1,
        b: 2,
        c: 3
    };
    
    it ('should transform the object to an array', () => {
       
       expect(pipe.transform(value)).toEqual([1, 2, 3]);
    });
    
    it ('should return the input unchanged', () => {
       
       expect(pipe.transform('a')).toEqual('a');
    });
    
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:25,代碼來源:to-array.pipe.spec.ts

示例8: describe

describe('TemplatePipe', () => {
    
    let pipe: TemplatePipe;
    
    beforeEach(() => {
       pipe = new TemplatePipe(); 
    });
    
    it ('Should replace the parameters', () => {
       
       expect(pipe.transform('Hello $1', 'World')).toEqual('Hello World'); 
    });
    
    
    it ('Should replace the parameters #2', () => {
       
       expect(pipe.transform('Hello $1, how is it $2', 'World', 'going?')).toEqual('Hello World, how is it going?'); 
    });
   
   
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform(1, [null])).toEqual(1); 
    });
   
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:26,代碼來源:template.pipe.spec.ts

示例9: describe

describe('MapPipe', () => {
    
    let pipe: MapPipe;
    
    beforeEach(() => {
       pipe = new MapPipe(); 
    });
    
    it('Should return the modified array', () => {
       
       const array = [0, 1, 2, 3];
       const fn = function (item) {
           return ++item;
       };
       
       expect(pipe.transform(array, fn)).toEqual([1, 2, 3, 4]); 
       expect(array).toEqual([0, 1, 2, 3]); // Check integrity
    });
    
    it('Should return the original array', () => {
       
       // undefined to avoid typescript error
       expect(pipe.transform([1,2], undefined)).toEqual([1, 2]); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a', null)).toEqual('a'); 
    });
    
})
開發者ID:josx,項目名稱:angular-pipes,代碼行數:31,代碼來源:map.pipe.spec.ts

示例10: describe

describe('Dashboard Component', () => {
  setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
  let tcb: TestComponentBuilder;

  beforeEachProviders(() => [
    TestComponentBuilder,
    HTTP_PROVIDERS,
    ROUTER_FAKE_PROVIDERS,
    provide(Location, {useClass: SpyLocation}),
    provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
    provide(ViewResolver, {useClass: MockViewResolver}),
    HeroService,
    AppComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], (tcb_) => {
    tcb = tcb_;
  }));

  it('should render the title', (done) => {
    return tcb.createAsync(DashboardComponent)
      .then(fixture => {
        let component = fixture.componentInstance;
        component.title = 'Top_heroes';
        fixture.detectChanges();
        let element = fixture.nativeElement;
        expect(element.querySelector('h3').innerText).toContain('Top_heroes');
        done();
      });
  });
});
開發者ID:mahpah,項目名稱:ng2-pack,代碼行數:31,代碼來源:dashboard.component.spec.ts


注:本文中的@angular/testing.beforeEach函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。