Skip to content

Commit

Permalink
fix(marbles): Return what func returns.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Mar 5, 2018
1 parent bceb7db commit dde5031
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions fixtures/jest/passing-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ cases("should support cases", (m, c) => {
e: "-|"
}
});

test("it should support promises", marbles((m) => {

return Promise.resolve().then(() => expect(typeof m).toEqual("object"));
}));
6 changes: 6 additions & 0 deletions fixtures/mocha/passing-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
/*tslint:disable:object-literal-sort-keys*/

import { expect } from "chai";
import { cases, marbles } from "../../dist/mocha";

import "rxjs/add/operator/delay";
Expand Down Expand Up @@ -196,4 +197,9 @@ describe("rxjs-marbles", () => {
e: "-|"
}
});

it("should support promises", marbles((m) => {

return Promise.resolve().then(() => expect(m).to.be.an("object"));
}));
});
4 changes: 2 additions & 2 deletions source/ava/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export function cases(name: string, func: any, cases: any): void {
}, cases);
}

export function marbles(func: (m: Context, t: TestContext) => void): any {
export function marbles(func: (m: Context, t: TestContext) => any): any {

return _marbles<TestContext>((m, t) => {
m.configure({
assert: t.truthy.bind(t),
assertDeepEqual: t.deepEqual.bind(t)
});
func(m, t);
return func(m, t);
});
}
4 changes: 2 additions & 2 deletions source/jest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function cases(name: string, func: any, cases: any): void {
});
}

export function marbles(func: (m: Context, ...rest: any[]) => void): any {
export function marbles(func: (m: Context, ...rest: any[]) => any): any {

return _marbles((m: Context, ...rest: any[]) => {
m.configure({
assertDeepEqual: (a, e) => expect(a).toEqual(e),
frameworkMatcher: true
});
func(m, ...rest);
return func(m, ...rest);
});
}
6 changes: 4 additions & 2 deletions source/marbles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export function marbles(func: (context: Context, ...rest: any[]) => any): (...re
get("frameworkMatcher")
));
const context = new Context(scheduler);
func(context, first, ...rest);
const result = func(context, first, ...rest);
context.teardown();
return result;
};
}
return (...rest: any[]) => {
Expand All @@ -36,7 +37,8 @@ export function marbles(func: (context: Context, ...rest: any[]) => any): (...re
get("frameworkMatcher")
));
const context = new Context(scheduler);
func(context, ...rest);
const result = func(context, ...rest);
context.teardown();
return result;
};
}
4 changes: 2 additions & 2 deletions source/tape/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export function cases(name: string, func: any, cases: any): void {
}, cases);
}

export function marbles(func: (m: Context, t: tape.Test) => void): any {
export function marbles(func: (m: Context, t: tape.Test) => any): any {

return _marbles<tape.Test>((m, t) => {
m.configure({
assert: t.ok.bind(t),
assertDeepEqual: t.deepEqual.bind(t)
});
func(m, t);
return func(m, t);
});
}

0 comments on commit dde5031

Please sign in to comment.