Skip to content

Commit

Permalink
chore: switch from jest to vitest (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 28, 2023
1 parent 8a0f2d4 commit f868ab0
Show file tree
Hide file tree
Showing 16 changed files with 2,595 additions and 4,601 deletions.
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
# cspell:ignore coverallsapp
6 changes: 0 additions & 6 deletions operators.js

This file was deleted.

6,407 changes: 2,176 additions & 4,231 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@
"name": "gensequence",
"version": "4.0.3",
"description": "Small library to simplify working with Generators and Iterators in Javascript / Typescript",
"type": "commonjs",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/esm/index.mjs"
}
},
"engines": {
"node": ">=14"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.3",
"@types/jest": "^28.1.8",
"@types/node": "^18.11.11",
"coveralls": "^3.1.1",
"jest": "^28.1.3",
"@vitest/coverage-istanbul": "^0.29.1",
"rimraf": "^4.1.1",
"ts-jest": "^28.0.8",
"typescript": "^4.9.4"
"ts2mjs": "^1.1.1",
"typescript": "^4.9.5",
"vitest": "^0.29.1"
},
"scripts": {
"prepublishOnly": "npm run clean-build",
"clean-build": "npm run clean && npm run build",
"clean": "rimraf dist",
"test": "jest",
"clean": "rimraf dist coverage",
"test": "vitest run",
"perf": "jest --testMatch '**/*.perf.ts'",
"build": "tsc -p .",
"watch": "tsc -w -p .",
"coverage": "npm test -- --coverage",
"coverage-coveralls": "cat coverage/lcov.info | coveralls",
"update-packages": "npx npm-check-updates -t minor -u && rimraf node_modules package-lock.json && npm i"
},
"repository": {
Expand Down
22 changes: 12 additions & 10 deletions src/AsyncGenSequence.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { describe, expect, test } from 'vitest';

import { asyncGenSequence } from './AsyncGenSequence';

describe('AsyncGenSequence Tests', () => {
test('tests reducing asynchronously a sequence w/o init', async () => {
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3, 4, 5])
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3, 4, 5]);
const gs = asyncGenSequence(asyncGenerator);
const result = await gs.reduceAsync((a, v) => a + v);
expect(result).toEqual(15);
});

test('tests reducing asynchronously a sequence with init', async () => {
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3, 4, 5])()
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3, 4, 5])();
const gs = asyncGenSequence(asyncGenerator);
const result = await gs.reduceAsync(async (a, v) => a + v, Promise.resolve(10));
expect(result).toEqual(25);
});

test('tests async iterator attribute', async () => {
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3])
const asyncGenerator = createAsyncGeneratorFor([1, 2, 3]);
const asyncIterator = asyncGenSequence(asyncGenerator)[Symbol.asyncIterator]();
const result1 = await asyncIterator.next()
const result2 = await asyncIterator.next()
const result3 = await asyncIterator.next()
const result4 = await asyncIterator.next()
const result1 = await asyncIterator.next();
const result2 = await asyncIterator.next();
const result3 = await asyncIterator.next();
const result4 = await asyncIterator.next();
expect(result1.value).toEqual(1);
expect(result1.done).toEqual(false);
expect(result2.value).toEqual(2);
Expand All @@ -36,7 +38,7 @@ describe('AsyncGenSequence Tests', () => {
function createAsyncGeneratorFor<T>(array: T[]) {
return async function* asyncGenerator() {
for (const i of array) {
yield i
yield i;
}
}
}
};
}

0 comments on commit f868ab0

Please sign in to comment.