Skip to content

Commit d649487

Browse files
committed
breaking change: test load & run
1 parent 5922761 commit d649487

File tree

10 files changed

+24
-21
lines changed

10 files changed

+24
-21
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
src/*.js
33
test/**/*.ts
4-
lib/.tmp.js
4+
.tmp/

lib/index.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ var settings = {
66
dir: null,
77
tutorial: null,
88
tests: '',
9-
step: 0,
9+
pagePosition: 0,
1010
testPath: '',
1111
};
12-
exports.combineTests = function (options) {
12+
function load(options) {
1313
options.testPath = testPath_1.default(options);
1414
settings = Object.assign(settings, options);
1515
writeTests_1.default(options);
16-
};
17-
function start(_a) {
16+
}
17+
exports.load = load;
18+
;
19+
function run(_a) {
1820
var taskPosition = _a.taskPosition, handleResult = _a.handleResult;
1921
var dir = settings.dir;
2022
runner_1.default({
@@ -23,5 +25,4 @@ function start(_a) {
2325
handleResult: handleResult,
2426
});
2527
}
26-
Object.defineProperty(exports, "__esModule", { value: true });
27-
exports.default = start;
28+
exports.run = run;

lib/testPath.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"use strict";
22
var path_1 = require('path');
33
function tmpTestName(_a) {
4-
var tutorial = _a.tutorial, step = _a.step;
5-
if (!tutorial || !tutorial.name || !tutorial.version || !step) {
4+
var tutorial = _a.tutorial, pagePosition = _a.pagePosition;
5+
console.log(tutorial, tutorial.name, tutorial.version, pagePosition);
6+
if (!tutorial || !tutorial.name || !tutorial.version || typeof pagePosition !== 'number') {
67
console.log('Error creating temporary test name');
78
}
8-
return path_1.join(__dirname, '..', '..', '.tmp', tutorial.name, tutorial.version, step + '.js');
9+
return path_1.join(__dirname, '..', '.tmp', tutorial.name + "__" + tutorial.version + "__" + pagePosition + ".js");
910
}
1011
Object.defineProperty(exports, "__esModule", { value: true });
1112
exports.default = tmpTestName;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"use strict";
2-
var babelRegister = "require(\"babel-register\")({\"plugins\": [[\"transform-es2015-modules-commonjs\", {\"strict\": true,\"loose\": true}]]});";
2+
var babelRegister = "require(\"babel-register\")({\"plugins\": [[\"transform-es2015-modules-commonjs\", {\"strict\": true,\"loose\": true}]]});\n\n";
33
Object.defineProperty(exports, "__esModule", { value: true });
44
exports.default = babelRegister;
File renamed without changes.

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ let settings: CombineTestsOptions = {
66
dir: null,
77
tutorial: null,
88
tests: '',
9-
step: 0,
9+
pagePosition: 0,
1010
testPath: '',
1111
};
1212

13-
export const combineTests = (options: CombineTestsOptions) => {
13+
export function load(options: CombineTestsOptions) {
1414
options.testPath = getTestPath(options);
1515
settings = Object.assign(settings, options);
1616
writeTests(options);
1717
};
1818

19-
export default function start({ taskPosition, handleResult }) {
19+
export function run({ taskPosition, handleResult }) {
2020
const { dir } = settings;
2121
runner({
2222
dir,

src/testPath.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { join } from 'path';
22

3-
export default function tmpTestName({tutorial, step}): string {
4-
if (!tutorial || !tutorial.name || !tutorial.version || !step) {
3+
export default function tmpTestName({tutorial, pagePosition}): string {
4+
console.log(tutorial, tutorial.name, tutorial.version, pagePosition);
5+
if (!tutorial || !tutorial.name || !tutorial.version || typeof pagePosition !== 'number') {
56
console.log('Error creating temporary test name');
67
}
78
return join(
8-
__dirname, '..', '..', '.tmp',
9-
tutorial.name, tutorial.version, step + '.js'
9+
__dirname, '..', '.tmp',
10+
`${tutorial.name}__${tutorial.version}__${pagePosition}.js`
1011
);
1112
}

src/typings/tsd.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ interface CombineTestsOptions {
1313
version: string;
1414
};
1515
tests: string;
16-
step: number;
16+
pagePosition: number;
1717
testPath: string;
1818
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
const babelRegister = `require("babel-register")({"plugins": [["transform-es2015-modules-commonjs", {"strict": true,"loose": true}]]});`;
1+
const babelRegister = `require("babel-register")({"plugins": [["transform-es2015-modules-commonjs", {"strict": true,"loose": true}]]});\n\n`;
22
export default babelRegister;

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"src/typings/process-console-log/index.d.ts",
3636
"src/typings/set/set.d.ts",
3737
"src/typings/tsd.d.ts",
38-
"src/writeTests/compiler.ts",
3938
"src/writeTests/helpers/babel-register.ts",
39+
"src/writeTests/helpers/compiler.ts",
4040
"src/writeTests/helpers/exists.ts",
4141
"src/writeTests/import-paths.ts",
4242
"src/writeTests/index.ts"

0 commit comments

Comments
 (0)