feat: tests

This commit is contained in:
2023-04-21 12:08:35 +02:00
parent 8cb9285462
commit d8c79256c9
140 changed files with 2100 additions and 2693 deletions

View File

@@ -3,18 +3,9 @@
"branches": 90,
"check-coverage": true,
"exclude": [],
"extension": [
".ts"
],
"extension": [".ts"],
"functions": 95,
"include": [
"src/protocol/route.ts",
"src/things/abstract/thing.ts",
"src/things/abstract/thing-that-can-be-offered.ts",
"src/things/abstract/thing-with-categories.ts",
"src/translator.ts",
"src/guards.ts"
],
"include": ["src/**/*.ts"],
"lines": 95,
"per-file": true,
"reporter": [
@@ -22,8 +13,6 @@
"html",
"text-summary"
],
"require": [
"ts-node/register"
],
"require": ["ts-node/register"],
"statements": 95
}

View File

@@ -20,11 +20,11 @@
},
"scripts": {
"build": "tsup --dts",
"format": "prettier .",
"format:fix": "prettier --write .",
"format": "prettier . --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "eslint --ext .ts src/",
"lint:fix": "eslint --fix --ext .ts src/",
"test": "nyc mocha 'test/**/*.spec.ts'"
"test": "c8 mocha"
},
"dependencies": {
"@openstapps/gitlab-api": "workspace:*",
@@ -33,15 +33,12 @@
"commander": "10.0.0",
"date-fns": "2.29.3",
"glob": "10.2.1",
"mustache": "4.2.0",
"tmp": "0.2.1"
"mustache": "4.2.0"
},
"devDependencies": {
"@openstapps/eslint-config": "workspace:*",
"@openstapps/nyc-config": "workspace:*",
"@openstapps/prettier-config": "workspace:*",
"@openstapps/tsconfig": "workspace:*",
"@testdeck/mocha": "0.3.3",
"@types/chai": "4.3.4",
"@types/chai-as-promised": "7.1.5",
"@types/glob": "8.0.1",
@@ -52,7 +49,7 @@
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"mocha": "10.2.0",
"nyc": "15.1.0",
"c8": "7.13.0",
"ts-node": "10.9.1",
"tsup": "6.7.0",
"typescript": "4.8.4"
@@ -72,8 +69,5 @@
"extends": [
"@openstapps"
]
},
"nyc": {
"extends": "@openstapps/nyc-config"
}
}

View File

@@ -13,9 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import {AddLogLevel} from '@openstapps/logger/lib/transformations/add-log-level.js';
import {Colorize} from '@openstapps/logger/lib/transformations/colorize.js';
import {Logger, AddLogLevel, Colorize} from '@openstapps/logger';
import {Command} from 'commander';
import {existsSync, readFileSync} from 'fs';
import path from 'path';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Label} from '@openstapps/gitlab-api/lib/types.js';
import {Label} from '@openstapps/gitlab-api';
import setHours from 'date-fns/setHours';
import nextThursday from 'date-fns/nextThursday';
import previousThursday from 'date-fns/previousThursday';

View File

@@ -12,15 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {
Api,
AccessLevel,
MembershipScope,
MergeRequestMergeStatus,
MergeRequestState,
Scope,
User,
} from '@openstapps/gitlab-api/lib/types.js';
} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import {WebClient} from '@slack/web-api';
import {GROUPS, MAX_DEPTH_FOR_REMINDER, NOTE_PREFIX, SLACK_CHANNEL} from '../configuration.js';

View File

@@ -12,15 +12,15 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {
Api,
Issue,
IssueState,
MembershipScope,
MergeRequestState,
Project,
User,
} from '@openstapps/gitlab-api/lib/types.js';
} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import mustache from 'mustache';
import path from 'path';

View File

@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {
Api,
AccessLevel,
IssueState,
MembershipScope,
@@ -21,7 +21,7 @@ import {
Milestone,
Project,
Scope,
} from '@openstapps/gitlab-api/lib/types.js';
} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import {getProjects} from '../common.js';
import {

View File

@@ -12,8 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {IssueState, Scope} from '@openstapps/gitlab-api/lib/types.js';
import {Api, IssueState, Scope} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import {GROUPS, LAST_MEETING, NOTE_PREFIX} from '../configuration.js';
import isBefore from 'date-fns/isBefore';

View File

@@ -1,43 +1,26 @@
import * as chai from 'chai';
import {expect} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {execSync} from 'child_process';
import {suite, test} from '@testdeck/mocha';
import {join} from 'path';
import {dirSync} from 'tmp';
import path from 'path';
import {getUsedVersion, getUsedVersionMajorMinor} from '../src/tasks/get-used-version.js';
chai.use(chaiAsPromised);
chai.should();
@suite()
export class GetUsedVersionsSpec {
@test
async 'does not depend on core'() {
return getUsedVersion(join(__dirname, '..'), '@openstapps/core').should.eventually.be.rejected;
}
describe('Verify Versions', function () {
it('should not depend on core', async function () {
await getUsedVersion(process.cwd(), '@openstapps/core').should.eventually.be.rejected;
});
@test
async 'not a Node.js project'() {
return getUsedVersion(__dirname, '@openstapps/core').should.eventually.be.rejected;
}
it('should not be a Node.js project', async function () {
await getUsedVersion(path.resolve(process.cwd(), '..'), '@openstapps/core').should.eventually.be.rejected;
});
@test
async 'has no dependencies'() {
const temporaryDirectory = dirSync();
it('should get used version', async function () {
expect(await getUsedVersion(process.cwd(), 'mustache')).to.be.equal('4.2.0');
});
execSync(`cd ${temporaryDirectory.name}; npm init -y`);
await getUsedVersion(temporaryDirectory.name, '@openstapps/core').should.eventually.be.rejected;
}
@test
async 'get used version'() {
expect(await getUsedVersion(join(__dirname, '..'), '@krlwlfrt/async-pool')).to.be.equal('0.4.1');
}
@test
async 'get used version major minor'() {
expect(await getUsedVersionMajorMinor(join(__dirname, '..'), '@krlwlfrt/async-pool')).to.be.equal('0.4');
}
}
it('should get used version major minor', async function () {
expect(await getUsedVersionMajorMinor(process.cwd(), 'mustache')).to.be.equal('4.2');
});
});

View File

@@ -25,5 +25,8 @@
"strict": true,
"target": "ES2021"
},
"exclude": ["../../../app.js", "../../../lib/", "../../../test/"]
"ts-node": {
"transpileOnly": true
},
"exclude": ["../../../app.js", "../../../lib/"]
}