Skip to content

Commit

Permalink
fix(dependency on 'rx'): Remove requires to 'rx' directly
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Sep 20, 2017
1 parent 623bf9e commit 71f7330
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/stryker/src/SandboxCoordinator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as os from 'os';
import { getLogger } from 'log4js';
import { Observable } from 'rx';
import { Observable } from 'rxjs';
import { Config } from 'stryker-api/config';
import { File } from 'stryker-api/core';
import { TestFramework } from 'stryker-api/test_framework';
Expand Down
11 changes: 11 additions & 0 deletions packages/stryker/src/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* These are fake dom type definitions that rxjs depends on
*/
interface EventTarget { }
interface NodeList { }
interface HTMLCollection { }
interface XMLHttpRequest { }
interface Event { }
interface MessageEvent { }
interface CloseEvent { }
interface WebSocket { }
10 changes: 5 additions & 5 deletions packages/stryker/src/process/MutationTestExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Sandbox from '../Sandbox';
import { Observable, Observer } from 'rx';
import { Observable, Observer } from 'rxjs';
import { RunResult, RunStatus, TestStatus } from 'stryker-api/test_runner';
import { MutantResult, MutantStatus } from 'stryker-api/report';
import { Config } from 'stryker-api/config';
Expand Down Expand Up @@ -31,11 +31,11 @@ export default class MutationTestExecutor {

private runInsideSandboxes(sandboxes: Observable<Sandbox>, transpiledMutants: Observable<TranspiledMutant>): Promise<MutantResult[]> {
let recycleObserver: Observer<Sandbox>;
const recycled = Observable.create<Sandbox>(observer => {
const recycled = new Observable<Sandbox>(observer => {
recycleObserver = observer;
});
function recycle(sandbox: { sandbox: Sandbox }) {
return recycleObserver.onNext(sandbox.sandbox);
function recycle(sandbox: { sandbox: Sandbox, result: MutantResult }) {
return recycleObserver.next(sandbox.sandbox);
}

return transpiledMutants
Expand All @@ -45,7 +45,7 @@ export default class MutationTestExecutor {
.map(({ result }) => result)
.do(reportResult(this.reporter))
.toArray()
.do(() => recycleObserver.onCompleted())
.do(() => recycleObserver.complete())
.do(reportAll(this.reporter))
.toPromise(Promise);
}
Expand Down
10 changes: 5 additions & 5 deletions packages/stryker/src/transpiler/MutantTranspiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observable } from 'rx';
import { Observable } from 'rxjs';
import { Config } from 'stryker-api/config';
import TranspilerFacade from './TranspilerFacade';
import TestableMutant from '../TestableMutant';
Expand Down Expand Up @@ -52,16 +52,16 @@ export default class MutantTranspiler {

transpileMutants(allMutants: TestableMutant[]): Observable<TranspiledMutant> {
const mutants = allMutants.slice();
return Observable.create<TranspiledMutant>(observer => {
return new Observable<TranspiledMutant>(observer => {
const nextMutant = () => {
const mutant = mutants.shift();
if (mutant) {
this.transpileMutant(mutant)
.then(transpileResult => observer.onNext({ mutant, transpileResult }))
.then(transpileResult => observer.next({ mutant, transpileResult }))
.then(nextMutant)
.catch(error => observer.onError(error));
.catch(error => observer.error(error));
} else {
observer.onCompleted();
observer.complete();
}
};
nextMutant();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { Observable } from 'rx';
import { Observable } from 'rxjs';
import * as _ from 'lodash';
import { Config } from 'stryker-api/config';
import { File } from 'stryker-api/core';
Expand Down Expand Up @@ -93,8 +93,8 @@ describe('MutationTestExecutor', () => {

firstSandbox = mock(Sandbox);
secondSandbox = mock(Sandbox);
mutantTranspilerMock.transpileMutants.returns(Observable.fromArray(transpiledMutants));
sandboxCoordinatorMock.streamSandboxes.returns(Observable.fromArray([firstSandbox, secondSandbox]));
mutantTranspilerMock.transpileMutants.returns(Observable.of(...transpiledMutants));
sandboxCoordinatorMock.streamSandboxes.returns(Observable.of(...[firstSandbox, secondSandbox]));

sut = new MutantTestExecutor(config(), inputFiles, transpiledFiles, testFrameworkMock, reporter);

Expand Down

0 comments on commit 71f7330

Please sign in to comment.