Skip to content

Commit 34da166

Browse files
committed
tests: Simplify test() arguments
1 parent 229899a commit 34da166

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/tests/debug-tools-test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,26 +438,28 @@ Object.keys(cases).forEach(caseName => {
438438
describe(caseName, () => {
439439
let ep = 0;
440440

441-
cases[caseName].fixtures.forEach(assertionName => {
442-
if (cases[caseName].only) {
441+
let testcase = cases[caseName];
442+
443+
testcase.fixtures.forEach(assertionName => {
444+
if (testcase.only) {
443445
it.only(assertionName, () => {
444-
test(caseName, cases, assertionName, ep);
446+
test(testcase, assertionName, ep);
445447
});
446-
} else if (cases[caseName].skip) {
448+
} else if (testcase.skip) {
447449
it.skip(assertionName, () => {});
448450
} else {
449451
it(assertionName, () => {
450-
test(caseName, cases, assertionName, ep);
452+
test(testcase, assertionName, ep);
451453
});
452454
}
453455
});
454456
});
455457
});
456458

457459

458-
function test(caseName, cases, assertionName, ep) {
460+
function test(testcase, assertionName, ep) {
459461
let sample = fs.readFileSync(`./fixtures/${assertionName}/sample.js`, 'utf-8');
460-
let options = cases[caseName].transformOptions;
462+
let options = testcase.transformOptions;
461463
let expectationPath = `./fixtures/${assertionName}/expectation.js`;
462464
let expectationExists = fs.existsSync(expectationPath);
463465

@@ -468,6 +470,6 @@ function test(caseName, cases, assertionName, ep) {
468470

469471
} else {
470472
let fn = () => transform(sample, options);
471-
expect(fn).to.throw(new RegExp(cases[caseName].errors[ep++]));
473+
expect(fn).to.throw(new RegExp(testcase.errors[ep++]));
472474
}
473475
}

0 commit comments

Comments
 (0)