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


TypeScript testing.it函数代码示例

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


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

示例1: describe

describe('MapPipe', () => {
    
    let pipe: SomePipe;
    
    const fn = function (item) {
        return item === 2;
    };
    
    beforeEach(() => {
       pipe = new SomePipe(); 
    });
    
    it('Should return true', () => {
       
       const array = [0, 1, 2, 3];
       
       expect(pipe.transform(array, fn)).toEqual(true); 
       expect(array).toEqual([0, 1, 2, 3]); // Check integrity
    });
    
    it('Should return false', () => {
       
       expect(pipe.transform([1,3], fn)).toEqual(false); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a', null)).toEqual('a'); 
    });
    
})
开发者ID:josx,项目名称:angular-pipes,代码行数:31,代码来源:some.pipe.spec.ts

示例2: describe

describe('TailPipe', () => {
    
    let pipe: TailPipe;
    
    beforeEach(() => {
       pipe = new TailPipe(); 
    });
    
    it('Should return []', () => {
       
       expect(pipe.transform([])).toEqual([]); 
    });
    
    it('Should return [2]', () => {
       
       expect(pipe.transform([1, 2])).toEqual([2]); 
    });
    
    it ('Should return [2, 3]', () => {
       
       expect(pipe.transform([1, 2, 3])).toEqual([2, 3]); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a')).toEqual('a'); 
    });
    
});
开发者ID:josx,项目名称:angular-pipes,代码行数:29,代码来源:tail.pipe.spec.ts

示例3: describe

describe('CapitalizePipe', () => {
    
    let pipe: CapitalizePipe;
    
    beforeEach(() => {
       pipe = new CapitalizePipe(); 
    });
    
    it('Should returned the capitalized string', () => {
       
       expect(pipe.transform('abcd', false)).toEqual('Abcd');
    });
    
    it('Should returned the capitalized string #2', () => {
       
       expect(pipe.transform('abcd aa', false)).toEqual('Abcd aa');
    });
    
    it('Should returned the capitalized string #3', () => {
       
       expect(pipe.transform('abCD aA', false)).toEqual('Abcd aa');
    });
    
    it('Should returned the capitalized string #4', () => {
       
       expect(pipe.transform('abCD aA', true)).toEqual('Abcd Aa');
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform(1, null)).toEqual(1); 
    });
   
});
开发者ID:josx,项目名称:angular-pipes,代码行数:34,代码来源:capitalize.pipe.spec.ts

示例4: describe

describe('FloorPipe', () => {
    
    let pipe: FloorPipe;
    
    beforeEach(() => {
       pipe = new FloorPipe(); 
    });
    
    it('Should return 3', () => {
        
        expect(pipe.transform(3.4, 0)).toEqual(3);
    });
    
    it('Should return 1', () => {
        
        expect(pipe.transform(1, 0)).toEqual(1);
    });
    
    it('Should return 0', () => {
        
        expect(pipe.transform(0.65, 0)).toEqual(0);
    });
    
    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); 
    });
});
开发者ID:josx,项目名称:angular-pipes,代码行数:34,代码来源:floor.pipe.spec.ts

示例5: describe

describe('TestPipe', () => {
    
    let pipe: TestPipe;
    
    beforeEach(() => {
       pipe = new TestPipe(); 
    });
    
    
    it('Should return true', () => {
       
        const result = pipe.transform('abc', /a/g);
        expect(result).toEqual(true);
    });
    
    it('Should return false', () => {
       
        const result = pipe.transform('abc', /d/g);
        expect(result).toEqual(false);
    });
    
    
    // Just use test function ...
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform(1, null, null)).toEqual(1); 
    });
   
});
开发者ID:josx,项目名称:angular-pipes,代码行数:30,代码来源:test.pipe.spec.ts

示例6: describe

describe('IsObjectPipe', () => {
    
    let pipe: IsObjectPipe;
    
    beforeEach(() => {
       pipe = new IsObjectPipe(); 
    });
    
    it('Should return true', () => {
        
        expect(pipe.transform({})).toEqual(true);
    });
    
    it('Should return false', () => {
        
        expect(pipe.transform(1)).toEqual(false);
    });
    
    it('Should return true #2', () => {
        
        expect(pipe.transform([])).toEqual(true);
    });
    
    it('Should return false #3', () => {
        
        expect(pipe.transform('a')).toEqual(false);
    });
});
开发者ID:josx,项目名称:angular-pipes,代码行数:28,代码来源:types.pipe.spec.ts

示例7: describe

describe('JoinPipe ', () => {
    
    let pipe: JoinPipe;
    
    beforeEach(() => {
       pipe = new JoinPipe (); 
    });
    
    it('Should return "abcd"', () => {
       
       expect(pipe.transform(['a', 'b', 'c', 'd'], '')).toEqual('abcd'); 
    });
    
    it('Should return abc123', () => {
       
       expect(pipe.transform(['a', 'b', 'c', 1, 2, 3], '')).toEqual('abc123'); 
    });
    
    it ('Should return 1a2a3', () => {
       
       expect(pipe.transform([1, 2, 3], 'a')).toEqual('1a2a3'); 
    });
    
    it('Should return the value unchanged', () => {
       
       expect(pipe.transform('a', '')).toEqual('a'); 
    });
    
});
开发者ID:josx,项目名称:angular-pipes,代码行数:29,代码来源:join.pipe.spec.ts

示例8: describe

describe('RangePipe', () => {
    
    let pipe: RangePipe;
    
    beforeEach(() => {
       pipe = new RangePipe(); 
    });
    
    it('Should return a range from 1 to 10', () => {
       
       expect(pipe.transform([], 10, 1)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 
    });
    
    it('Should return a range from 0 to 4', () => {
       
       expect(pipe.transform([], 5, 0)).toEqual([0, 1, 2, 3, 4]); 
    });
    
    it('Should return a range from -2 to +2', () => {
       
       expect(pipe.transform([], 5, -2)).toEqual([-2, -1, 0, 1, 2]); 
    });
    
    
    it ('Should return a range from 0 to 18 with a step of 2', () => {
       
       expect(pipe.transform([], 10, 0, 2)).toEqual([0, 2, 4, 6, 8, 10, 12, 14, 16, 18]);
    });
})
开发者ID:josx,项目名称:angular-pipes,代码行数:29,代码来源:range.pipe.spec.ts

示例9: 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

示例10: 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


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