Skip to content

Commit

Permalink
chore: add questions test example
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny-117 committed Aug 14, 2024
1 parent 2c80d38 commit 9cb40cc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/node/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ program.command('test')
const file = generateTestCode(problem.fullName);
console.log('running test:', 'npx', 'mocha', file)
execa('npx', ['mocha',file]).stdout.pipe(process.stdout);

})

program.command('create')
Expand Down
6 changes: 1 addition & 5 deletions lib/node/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import path from 'path';
import fs, { read } from 'fs';
import {
fileURLToPath
} from 'url';

import fs from 'fs';
import {QUESTION_BASE, PLAYGROUND_BASE, CACHE_BASE} from './constants.mjs'

function readFile(path) {
Expand Down
1 change: 1 addition & 0 deletions questions/1-promise-all/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 实现一个Promise.all
5 changes: 5 additions & 0 deletions questions/1-promise-all/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function (MyPromise) {
MyPromise.all = function () {

}
}
17 changes: 17 additions & 0 deletions questions/1-promise-all/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
*
* @param {Mocha.MochaGlobals['describe']} describe
* @param {Mocha.MochaGlobals['it']} it
* @param {import('chai')['expect']} expect
* @param {() => any} code
*/
export default function test(describe, it, expect, code) {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
expect([1, 2, 3].indexOf(4)).to.equal(-1);
});
});
it('should take less than 500ms', function (done) {
expect(2).to.equal(200);
});
}

0 comments on commit 9cb40cc

Please sign in to comment.