Skip to content

Commit

Permalink
chore: add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
fupengl committed Sep 16, 2020
1 parent 91ae62e commit 206c07a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
lib/
typings/
tsconfig.tsbuildinfo
/coverage/
Empty file removed __tests__/.gitkeep
Empty file.
23 changes: 23 additions & 0 deletions __tests__/uuid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { uuid } from '../src';

// https://github.com/afram/is-uuid/blob/master/lib/is-uuid.js
const uuidReg = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

describe('uuid', () => {
test('valid', () => {
expect(uuidReg.test(uuid())).toBe(true);
});

test('Generate 10000 unique', () => {
expect(
Array.from(
Array(10000)
.fill(0)
.reduce((acc) => {
acc.add(uuid());
return acc;
}, new Set()),
).length,
).toBe(10000);
});
});
13 changes: 2 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/promise/mapLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function mapLimit<V>(input: any, limit: number, iteratee: any): Promise<V[
}
};

const allExecutors = [];
const allExecutors: Promise<any>[] = [];
for (let j = 0; j < limit; ++j) {
allExecutors.push(execute());
}
Expand Down
12 changes: 2 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
"declarationDir": "typings",
"lib": ["ESNext", "DOM"]
},
"exclude": [
"__tests__",
"node_modules",
"dist",
"tests",
"jest",
"**/*.test.ts",
"**/*.spec.ts",
"typings"
]
"include": ["./src"],
"exclude": ["__tests__"]
}

0 comments on commit 206c07a

Please sign in to comment.