From 13e24f15ef8467513d01a21d61f2acf7e3e7f7d9 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Sun, 29 Jul 2018 08:44:34 +1000 Subject: [PATCH] chore(dtslint): add find tests --- spec-dtslint/operators/find-spec.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec-dtslint/operators/find-spec.ts diff --git a/spec-dtslint/operators/find-spec.ts b/spec-dtslint/operators/find-spec.ts new file mode 100644 index 00000000000..674806947b7 --- /dev/null +++ b/spec-dtslint/operators/find-spec.ts @@ -0,0 +1,26 @@ +import { of } from 'rxjs'; +import { find } from 'rxjs/operators'; + +it('should support a user-defined type guard', () => { + const o = of('foo').pipe(find((s: string): s is 'foo' => true)); // $ExpectType Observable<"foo" | undefined> +}); + +it('should support a user-defined type guard that takes an index', () => { + const o = of('foo').pipe(find((s, index): s is 'foo' => true)); // $ExpectType Observable<"foo" | undefined> +}); + +it('should support a user-defined type guard that takes an index and the source', () => { + const o = of('foo').pipe(find((s, index): s is 'foo' => true)); // $ExpectType Observable<"foo" | undefined> +}); + +it('should support a predicate', () => { + const o = of('foo').pipe(find(s => true)); // $ExpectType Observable +}); + +it('should support a predicate that takes an index', () => { + const o = of('foo').pipe(find((s, index) => true)); // $ExpectType Observable +}); + +it('should support a predicate that takes an index and the source', () => { + const o = of('foo').pipe(find((s, index, source) => true)); // $ExpectType Observable +});