diff --git a/lib/node/app.mjs b/lib/node/app.mjs index 0e3aada..dc01265 100644 --- a/lib/node/app.mjs +++ b/lib/node/app.mjs @@ -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') diff --git a/lib/node/utils.mjs b/lib/node/utils.mjs index 82e006e..8a4767e 100644 --- a/lib/node/utils.mjs +++ b/lib/node/utils.mjs @@ -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) { diff --git a/questions/1-promise-all/README.md b/questions/1-promise-all/README.md new file mode 100644 index 0000000..e5fb2d8 --- /dev/null +++ b/questions/1-promise-all/README.md @@ -0,0 +1 @@ +# 实现一个Promise.all diff --git a/questions/1-promise-all/template.js b/questions/1-promise-all/template.js new file mode 100644 index 0000000..3b2ccd8 --- /dev/null +++ b/questions/1-promise-all/template.js @@ -0,0 +1,5 @@ +export default function (MyPromise) { + MyPromise.all = function () { + + } +} \ No newline at end of file diff --git a/questions/1-promise-all/test.js b/questions/1-promise-all/test.js new file mode 100644 index 0000000..c409663 --- /dev/null +++ b/questions/1-promise-all/test.js @@ -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); + }); +} \ No newline at end of file