当前位置: 首页>>代码示例>>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;未经允许,请勿转载。