Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump chai from 4.3.10 to 5.0.0 in /framework #130

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 30 additions & 60 deletions framework/package-lock.json

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

3 changes: 1 addition & 2 deletions framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"@types/mock-fs": "^4.13.4",
"@types/needle": "^3.2.3",
"c8": "^9.1.0",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"chai": "^5.0.3",
"consolemock": "^1.1.0",
"eslint": "^8.55.0",
"mocha": "^10.2.0",
Expand Down
2 changes: 1 addition & 1 deletion framework/src/cli/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export default (args: string[], cwd: string,) => {
() => execSync('npm install', {
cwd: root,
},),
() => execSync('git init', {
() => execSync('git init --initial-branch=master', {
cwd: root,
},),
];
Expand Down
4 changes: 3 additions & 1 deletion framework/src/helper/middleware-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const resolve = (path: string,): string => {
return reqlib + '/src/middlewares/' + shortened + '.js';
}
if (path[FIRST] === '$') {
return shortened.replace(/\/([^/]+)$/u, '/src/middlewares/$1',) + '.js';
return reqlib + '/node_modules/'
+ shortened.replace(/\/([^/]+)$/u, '/src/middlewares/$1',)
+ '.js';
}
return path;
};
Expand Down
1 change: 1 addition & 0 deletions framework/src/storage/mysql-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const project: string = reqlib
export class MysqlStorage implements Storage {
private connection: Connection;

// eslint-disable-next-line max-params
constructor(
host: string,
password: string,
Expand Down
18 changes: 9 additions & 9 deletions framework/test/cli/bench.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import cli from '../../src/cli/bench.js';
import {
use as useChai,
expect,
} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import 'mocha';

useChai(chaiAsPromised,);

describe('cli', () => {
it('should be a function', () => {
expect(cli,).to.be.a('function',);
},);
it('cli() throw when given 0 total tasks', () => {
expect(cli([
'0',
'0',
],),).to.eventually.be.rejectedWith();
it('cli() throw when given 0 total tasks', async() => {
try {
await cli([
'0',
'0',
],);
} catch (e) {
expect(e,).to.be.an('Error',);
}
},);
},);
3 changes: 2 additions & 1 deletion framework/test/cli/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
import 'mocha';
import {
existsSync,
readFileSync, rmdirSync,
readFileSync,
rmdirSync,
} from 'fs';
import {
tmpdir,
Expand Down
3 changes: 0 additions & 3 deletions framework/test/executor.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import executor from '../src/executor.js';
import Thread from '../src/worker/thread.js';
import {
use as chaiUse,
expect,
} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import 'mocha';
import {
NullLogger,
Expand All @@ -29,7 +27,6 @@ import Counter from '../src/counter.js';
// eslint-disable-next-line @typescript-eslint/no-empty-function
const NOOP = () => {};
const NONE = 0;
chaiUse(chaiAsPromised,);

class FakeResult implements Result, ValidationResult, FinishedSet {

Expand Down
31 changes: 19 additions & 12 deletions framework/test/helper/function-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,25 @@ describe('helper/function-analyzer', () => {
expect(ret,).to.be.an('array',);
expect(ret,).to.deep.equal([],);
},);
it('should return an empty array when handling no params with wrapped body', () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const ret = analyze(() => ({}),);
expect(ret,).to.be.an('array',);
expect(ret,).to.deep.equal([],);
},);
it('should return an empty array when handling no params with direct return body', () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const ret = analyze(() => 'test',);
expect(ret,).to.be.an('array',);
expect(ret,).to.deep.equal([],);
},);
it(
'should return an empty array when handling no params with wrapped body',
() => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const ret = analyze(() => ({}),);
expect(ret,).to.be.an('array',);
expect(ret,).to.deep.equal([],);
},
);
it(
'should return an empty array when handling '
+ 'no params with direct return body',
() => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
const ret = analyze(() => 'test',);
expect(ret,).to.be.an('array',);
expect(ret,).to.deep.equal([],);
},
);
it('should return an array of params when handling one typed param', () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
const ret = analyze(function(/*Boolean*/myBoolean,) {},);
Expand Down
10 changes: 4 additions & 6 deletions framework/test/helper/job-creator.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import jobCreator from '../../src/helper/job-creator.js';
import {
expect, use as chaiUse,
expect,
} from 'chai';
import 'mocha';
import url from 'url';
import chaiAsPromised from 'chai-as-promised';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url,),);

chaiUse(chaiAsPromised,);
describe('helper/job-creator', () => {
it('should be a string', () => {
expect(jobCreator,).to.be.a('function',);
},);
it('should be match expectations', () => {
const result = jobCreator(__dirname + '../../fixtures',);
expect(result,).to.eventually.deep.equal({
it('should be match expectations', async() => {
const result = await jobCreator(__dirname + '../../fixtures',);
expect(result,).to.deep.equal({
'after': [],
'afterEach': [],
'afterTask': [],
Expand Down
37 changes: 19 additions & 18 deletions framework/test/helper/middleware-loader.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import loader from '../../src/helper/middleware-loader.js';
import {
expect,
use as chaiUse,
} from 'chai';
import 'mocha';
import chaiAsPromised from 'chai-as-promised';
import url from 'url';
import {
realpathSync,
} from 'fs';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url,),);

const basedir = realpathSync(__dirname + '../..',);
chaiUse(chaiAsPromised,);

describe('helper/middleware-loader', () => {
it('should be a string', () => {
expect(loader,).to.be.a('function',);
},);
it('should load by absolute path', () => {
expect(loader(__dirname + '../../src/middlewares/cookie',),)
.to.eventually.be.a('function',);
it('should load by absolute path', async() => {
expect(await loader(__dirname + '../../src/middlewares/cookie',),)
.to.be.a('function',);
},);
it('should load by ^-path', () => {
expect(loader('^cookie',),).to.eventually.be.a('function',);
it('should load by ^-path', async() => {
expect(await loader('^cookie',),).to.be.a('function',);
},);
it('should load by ^-path and skip the default key', () => {
expect(loader('^../main',),).to.eventually.be.a('function',);
it('should load by ^-path and skip the default key', async() => {
expect(await loader('^encoding',),).to.be.a('function',);
},);
it('should load by #-path', () => {
expect(loader('#cookie',),).to.eventually.be.a('function',);
it('should load by #-path', async() => {
expect(await loader('#cookie',),).to.be.a('function',);
},);
it('should load by $-path', () => {
expect(loader('$needle/cookie',),).to.be.rejectedWith(
`Cannot find module '${ basedir }`
+ '/node_modules/needle/src/middlewares/cookie\' '
+ `imported from ${ basedir }/src/helper/include-default.ts`,
);
it('should load by $-path', async() => {
try {
await loader('$needle/cookie',);
// eslint-disable-next-line no-unused-expressions
expect(false,).to.be.true;
} catch (e) {
expect(`${ e }`,).to.equal(`Error: Cannot find module '${ basedir }`
+ '/node_modules/needle/src/middlewares/cookie.js\' '
+ `imported from ${ basedir }/src/helper/include-default.ts`,);
}
},);
},);