@ -8,7 +8,7 @@
|
||||
|
||||
import {CommonModule, SlicePipe} from '@angular/common';
|
||||
import {Component} from '@angular/core';
|
||||
import {TestBed, async} from '@angular/core/testing';
|
||||
import {async, TestBed} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
{
|
||||
@ -24,24 +24,32 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
});
|
||||
|
||||
describe('supports', () => {
|
||||
it('should support strings', () => { expect(() => pipe.transform(str, 0)).not.toThrow(); });
|
||||
it('should support lists', () => { expect(() => pipe.transform(list, 0)).not.toThrow(); });
|
||||
it('should support readonly lists',
|
||||
() => { expect(() => pipe.transform(list as ReadonlyArray<number>, 0)).not.toThrow(); });
|
||||
it('should support strings', () => {
|
||||
expect(() => pipe.transform(str, 0)).not.toThrow();
|
||||
});
|
||||
it('should support lists', () => {
|
||||
expect(() => pipe.transform(list, 0)).not.toThrow();
|
||||
});
|
||||
it('should support readonly lists', () => {
|
||||
expect(() => pipe.transform(list as ReadonlyArray<number>, 0)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
// this would not compile
|
||||
// so we cast as `any` to check that it throws for unsupported objects
|
||||
() => { expect(() => pipe.transform({} as any, 0)).toThrow(); });
|
||||
() => {
|
||||
expect(() => pipe.transform({} as any, 0)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('transform', () => {
|
||||
it('should return null if the value is null', () => {
|
||||
expect(pipe.transform(null, 1)).toBe(null);
|
||||
});
|
||||
|
||||
it('should return null if the value is null',
|
||||
() => { expect(pipe.transform(null, 1)).toBe(null); });
|
||||
|
||||
it('should return undefined if the value is undefined',
|
||||
() => { expect(pipe.transform(undefined, 1)).toBe(undefined); });
|
||||
it('should return undefined if the value is undefined', () => {
|
||||
expect(pipe.transform(undefined, 1)).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should return all items after START index when START is positive and END is omitted',
|
||||
() => {
|
||||
@ -85,11 +93,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
expect(pipe.transform(list, 2)).toEqual([3, 4, 5]);
|
||||
expect(list).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('integration', () => {
|
||||
|
||||
@Component({selector: 'test-comp', template: '{{(data | slice:1).join(",") }}'})
|
||||
class TestComp {
|
||||
data: any;
|
||||
|
Reference in New Issue
Block a user