Skip to content

Commit

Permalink
Add minimal unit tests for Concast class.
Browse files Browse the repository at this point in the history
The Concast class is heavily exercised by much of our test suite, so I
would not say it is currently untested, but I would love to expand on
these Concast-specific unit tests in the future.
  • Loading branch information
benjamn committed May 9, 2022
1 parent 372df30 commit 6c53754
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/utilities/observables/__tests__/Concast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { itAsync } from "../../../testing/core";
import { Observable } from "../Observable";
import { Concast } from "../Concast";

describe("Concast Observable (similar to Behavior Subject in RxJS)", () => {
itAsync("can concatenate other observables", (resolve, reject) => {
const concast = new Concast([
Observable.of(1, 2, 3),
Promise.resolve(Observable.of(4, 5)),
Observable.of(6, 7, 8, 9),
Promise.resolve().then(() => Observable.of(10)),
Observable.of(11),
]);

const results: number[] = [];
concast.subscribe({
next(num) {
results.push(num);
},

error: reject,

complete() {
concast.promise.then(finalResult => {
expect(results).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
expect(finalResult).toBe(11);
resolve();
}).catch(reject);
},
});
});
});

0 comments on commit 6c53754

Please sign in to comment.