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


TypeScript testing.describe函數代碼示例

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


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

示例1: describe

export let secondSuite = () => {
  describe('OrderService', () => {

    beforeEachProviders(() => [{ provide: OrderService, useFactory: () => new OrderService(false) },
      DateFormatter,
      DatePipe
    ]);

    it('should fetch our data', inject([OrderService], (orderService: OrderService) => {
      expect(orderService.getData().length).toBe(2);
    }));

    it('should fetch our data', inject([DateFormatter], (dateFormatService: DateFormatter) => {
      expect(dateFormatService.x).toBe(3);
    }));
  });
};
開發者ID:AnimalStyle55,項目名稱:Angular2,代碼行數:17,代碼來源:test2.ts

示例2: describe

import { SqrtPipe } from '../../index';
        
import {describe, it, beforeEach, expect} from '@angular/testing';

describe('SqrtPipe', () => {
    
    let pipe: SqrtPipe;
    
    beforeEach(() => {
       pipe = new SqrtPipe(); 
    });
    
    it('Should return 2', () => {
        
        expect(pipe.transform(4)).toEqual(2);
    });
    
    it('Should return 9', () => {
       
        expect(pipe.transform(81)).toEqual(9); 
    });
  
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:23,代碼來源:sqrt.pipe.spec.ts

示例3: describe

describe('RoundPipe', () => {
    
    let pipe: RoundPipe;
    
    beforeEach(() => {
       pipe = new RoundPipe(); 
    });
    
    it('Should return 3', () => {
        
        expect(pipe.transform(3.4, 0)).toEqual(3);
    });
    
    it('Should return 3', () => {
        
        expect(pipe.transform(3.5, 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.54', () => {
       
       expect(pipe.transform(1.5444, 2)).toEqual(1.54); 
    });
    
    it('Should return 1.35', () => {
       
       expect(pipe.transform(1.345, 2)).toEqual(1.35); 
    });
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:45,代碼來源:round.pipe.spec.ts

示例4: describe

describe('WherePipe', () => {
    
    let pipe: WherePipe;
    
    const array = [
        {
            a: 2,
            b: 3,
            d: { e : 4}
        },
        {
            a: 4,
            b: 3,
            d: { e : 8 }
        },
        {
            a: 3,
            b: 1,
            d: { e : 4}
        },
        {
            a: 4,
            b: 5,
            d: { e : 5}
        }
    ]
    
    beforeEach(() => {
       pipe = new WherePipe(); 
    });
    
    it ('Should return only the 1 values', () => {
       
       const fn = function (item) {
           return item === 1;
       } 
       
       const value = [1, 2, 3, 1, 1, 4];
       expect(pipe.transform(value, fn)).toEqual([1, 1, 1]);
       expect(value).toEqual([1, 2, 3, 1, 1, 4]);
    });
    
    it('Should return the objects where a is 4', () => {
       
       const fn = function (item) {
           return item.a === 4;
       };
       
       expect(pipe.transform(array, fn))
            .toEqual([{
                a: 4,
                b: 3,
                d: { e : 8 }
            },
            {
                a: 4,
                b: 5,
                d: { e : 5}
            }
        ]); 
    });
    
    it('Should return the objects where a is 4', () => {

       expect(pipe.transform(array, ['a', 4]))
            .toEqual([{
                a: 4,
                b: 3,
                d: { e : 8 }
            },
            {
                a: 4,
                b: 5,
                d: { e : 5}
            }
        ]); 
    });
    
    it('Should return the objects where d.e is 4', () => {

       expect(pipe.transform(array, ['d.e', 4]))
            .toEqual([{
                a: 2,
                b: 3,
                d: { e : 4 }
            },
            {
                a: 3,
                b: 1,
                d: { e : 4}
            }
        ]); 
    });
    
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a', null)).toEqual('a'); 
    });
    
//.........這裏部分代碼省略.........
開發者ID:josx,項目名稱:angular-pipes,代碼行數:101,代碼來源:where.pipe.spec.ts

示例5: describe

import {
  describe,
  ddescribe,
  expect,
  iit,
  it
} from '@angular/testing';
import {Usuario} from './usuario.model';

describe('Usuario', () => {
  it('should create an instance', () => {
    expect(new Usuario()).toBeTruthy();
  });
});
開發者ID:nerycabras,項目名稱:sportLeagueManagement,代碼行數:14,代碼來源:usuario.model.spec.ts

示例6: describe

describe('RandomPipe', () => {
    
    let pipe: RandomPipe;
    
    beforeEach(() => {
       pipe = new RandomPipe(); 
    });
    
    it ('Should return a random value between 5 and 10', () => {
       
       const result = pipe.transform(0, 5, 10);
       
       expect(result).toBeGreaterThan(5); 
       expect(result).toBeLessThan(10); 
    });
    
    it ('Should return a random value between 0 and 1', () => {
       
       const result = pipe.transform(0, 0, 1);
       
       expect(result).toBeGreaterThan(0); 
       expect(result).toBeLessThan(1); 
    });
    
    it ('Should return a random value between 1298 and 1300', () => {
       
       const result = pipe.transform(0, 1298, 1300);
       
       expect(result).toBeGreaterThan(1298); 
       expect(result).toBeLessThan(1300); 
    });
    
    
    it ('Should return the value unchanged', () => {
       
       expect(pipe.transform(0, 'a', 1)).toEqual(0); 
    });
    
    
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:40,代碼來源:random.pipe.spec.ts

示例7: describe

import { TemplatePipe } from '../../index';
        
import {describe, it, beforeEach, expect} from '@angular/testing';

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,代碼行數:30,代碼來源:template.pipe.spec.ts

示例8: describe

  describe,
  beforeEachProviders,
  TestComponentBuilder
} from '@angular/testing';

import {Component, provide} from '@angular/core';
import {BaseRequestOptions, Http} from '@angular/http';
import {MockBackend} from '@angular/http/testing';

// Load the implementations that should be tested
import {XLarge} from './x-large.directive';

describe('x-large directive', () => {
  // Create a test component to test directives
  @Component({
    template: '',
    directives: [ XLarge ]
  })
  class TestComponent {}

  it('should sent font-size to x-large', injectAsync([TestComponentBuilder], (tcb) => {
    return tcb.overrideTemplate(TestComponent, '<div x-large>Content</div>')
      .createAsync(TestComponent).then((fixture: any) => {
        fixture.detectChanges();
        let compiled = fixture.debugElement.nativeElement.children[0];
        expect(compiled.style.fontSize).toBe('x-large');
      });
  }));

});
開發者ID:jneveux,項目名稱:calculator,代碼行數:30,代碼來源:x-large.spec.ts

示例9: describe

import { EncodeURIPipe } from '../../index';
        
import {describe, it, beforeEach, expect} from '@angular/testing';

describe('EncodeURIPipe', () => {
    
    let pipe: EncodeURIPipe;
    
    beforeEach(() => {
       pipe = new EncodeURIPipe(); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform(1)).toEqual(1); 
    });
   
});
開發者ID:josx,項目名稱:angular-pipes,代碼行數:18,代碼來源:encode-uri.pipe.spec.ts

示例10: describe

import {describe, it, beforeEach, expect} from '@angular/testing';

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,代碼行數:31,代碼來源:sum.pipe.spec.ts


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