Skip to content

Commit e9eac56

Browse files
committed
refactor: migrate extensions
1 parent cf13e7d commit e9eac56

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

extensions/check-error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CONSTANTS } from './constants.js';
22

3-
const { SPECIAL_PROP_VALUE, CORRECT_RESULT_MSG } = CONSTANTS;
3+
const { SPECIAL_PROP_VALUE, CORRECT_RESULT_MSG, INCORRECT_RESULT_MSG } = CONSTANTS;
44

55
export const checkForThrowingErrors = function (testsFuncs, expectedErrMsg) {
66
return testsFuncs.map(f => {
@@ -24,7 +24,7 @@ export const checkForNotThrowingErrors = function (testFuncs) {
2424
if (err._specialProp === SPECIAL_PROP_VALUE) {
2525
this.skip();
2626
} else {
27-
return
27+
return INCORRECT_RESULT_MSG;
2828
}
2929
}
3030
});

extensions/constants.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export const CONSTANTS = {
1+
const CONSTANTS = {
22
CORRECT_RESULT_MSG: 'CORRECT',
33
INCORRECT_RESULT_MSG: 'INCORRECT',
44
SPECIAL_PROP_VALUE: 'SP_NI'
5+
};
6+
7+
module.exports = {
8+
CONSTANTS
59
};

extensions/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { checkForThrowingErrors, checkForNotThrowingErrors } from './check-error.js';
2-
import { CONSTANTS } from './constants.js';
3-
import { testOptional } from './it-optional.js';
4-
import { NotImplementedError } from './not-implemented-error.js';
1+
const { checkForThrowingErrors, checkForNotThrowingErrors } = require('./check-error.js');
2+
const { CONSTANTS } = require('./constants.js');
3+
const { testOptional } = require('./it-optional.js');
4+
const { NotImplementedError } = require('./not-implemented-error.js');
55

6-
export {
6+
module.exports = {
77
checkForThrowingErrors,
88
checkForNotThrowingErrors,
99
CONSTANTS,

extensions/it-optional.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { CONSTANTS } from './constants.js';
1+
const { CONSTANTS } = require('./constants.js');
22

33
const { SPECIAL_PROP_VALUE } = CONSTANTS;
44

5-
export function testOptional(title, fn, isAsyncTest) {
5+
function testOptional(title, fn, isAsyncTest) {
66
if (isAsyncTest) {
77
it(title, function test(done) {
88
try {
@@ -28,4 +28,8 @@ export function testOptional(title, fn, isAsyncTest) {
2828
}
2929
});
3030
}
31-
}
31+
}
32+
33+
module.exports = {
34+
testOptional
35+
};

extensions/not-implemented-error.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { CONSTANTS } from './constants.js';
1+
const { CONSTANTS } = require('./constants.js');
22

33
const { SPECIAL_PROP_VALUE } = CONSTANTS;
44

5-
export class NotImplementedError extends Error {
5+
class NotImplementedError extends Error {
66
constructor(message) {
77
super(message);
88
this._specialProp = SPECIAL_PROP_VALUE;
99
}
10+
};
11+
12+
module.exports = {
13+
NotImplementedError
1014
};

0 commit comments

Comments
 (0)