Skip to content

Commit 506649e

Browse files
committed
extract handle-result
1 parent 7cc5eba commit 506649e

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

lib/modules/tests/test-run/test-result.js renamed to lib/modules/tests/test-run/handle-result.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ var actions_1 = require('../actions');
44
function handleResult(result) {
55
store_1.default.dispatch(actions_1.testComplete(result));
66
}
7-
exports.handleResult = handleResult;
7+
Object.defineProperty(exports, "__esModule", { value: true });
8+
exports.default = handleResult;
89
;

lib/modules/tests/test-run/run.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
"use strict";
2-
var test_result_1 = require('./test-result');
3-
var fs_1 = require('fs');
4-
var path_1 = require('path');
52
var parse_loaders_1 = require('./parse-loaders');
3+
var handle_result_1 = require('./handle-result');
64
function runTaskTests(taskTests, dir, tutorial, taskPosition) {
75
var tests = taskTests;
86
if (tests && tests.length) {
97
var tutorialConfig = tutorial.config;
108
var output = parse_loaders_1.default(tests, tutorialConfig.testSuffix, tutorial, dir);
11-
var target = path_1.join(tutorialConfig.dir || dir, ".tmp" + tutorialConfig.testSuffix);
12-
fs_1.writeFileSync(target, output, 'utf8');
139
var config = {
1410
dir: dir,
1511
tutorialDir: tutorialConfig.dir,
1612
taskPosition: taskPosition
1713
};
18-
tutorialConfig.run(target, config, test_result_1.handleResult);
14+
tutorialConfig.run(output, config, handle_result_1.default);
1915
}
2016
return true;
2117
}

src/modules/tests/test-run/test-result.ts renamed to src/modules/tests/test-run/handle-result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import store from '../../../store';
22
import {testComplete} from '../actions';
33

44
// function is passed into the test runner and called on completion
5-
export function handleResult(result: Test.Result): void {
5+
export default function handleResult(result: Test.Result): void {
66
store.dispatch(testComplete(result));
77
};

src/modules/tests/test-run/run.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {handleResult} from './test-result';
2-
import {writeFileSync} from 'fs';
31
import {join} from 'path';
42
import parseLoaders from './parse-loaders';
3+
import handleResult from './handle-result';
54

65
export default function runTaskTests(
76
taskTests: string, dir: string, tutorial: CR.Tutorial, taskPosition: number
@@ -14,21 +13,14 @@ export default function runTaskTests(
1413
tests, tutorialConfig.testSuffix, tutorial, dir
1514
);
1615

17-
// write temporary test file in tutorial directory
18-
let target = join(
19-
tutorialConfig.dir || dir,
20-
`.tmp${tutorialConfig.testSuffix}`
21-
);
22-
writeFileSync(target, output, 'utf8');
23-
2416
const config: Test.Config = {
2517
dir,
2618
tutorialDir: tutorialConfig.dir,
2719
taskPosition
2820
};
2921

3022
// call test runner
31-
tutorialConfig.run(target, config, handleResult);
23+
tutorialConfig.run(output, config, handleResult);
3224
}
3325
return true;
3426
}

src/typings/cr/test.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ declare namespace Test {
1313
tutorialDir: string;
1414
taskPosition: number;
1515
}
16+
17+
interface Log {
18+
type: string;
19+
output: any;
20+
}
1621
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@
111111
"src/modules/tests/actions.ts",
112112
"src/modules/tests/index.ts",
113113
"src/modules/tests/task-position/index.ts",
114+
"src/modules/tests/test-run/handle-result.ts",
114115
"src/modules/tests/test-run/index.ts",
115116
"src/modules/tests/test-run/parse-loaders.ts",
116117
"src/modules/tests/test-run/run.ts",
117-
"src/modules/tests/test-run/test-result.ts",
118118
"src/modules/tests/types.ts",
119119
"src/modules/tutorial/actions.ts",
120120
"src/modules/tutorial/index.ts",

0 commit comments

Comments
 (0)