Skip to content

Commit 96bcff0

Browse files
committed
feat: tests
1 parent 89e2076 commit 96bcff0

30 files changed

+1008
-2849
lines changed

.mocharc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"diff": true,
3+
"opts": false,
4+
"package": "./package.json",
5+
"reporter": "spec",
6+
"slow": 75,
7+
"timeout": 0,
8+
"ui": "bdd",
9+
"require": "./test/register.cjs",
10+
"recursive": true,
11+
"watch-files": ["./src/**/*.ts"],
12+
"spec": "src/**/*.test.ts"
13+
}

.prettierrc.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: "none",
4+
singleQuote: false,
5+
printWidth: 120,
6+
tabWidth: 2
7+
};

eslint.config.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// @ts-check
22

33
import eslint from "@eslint/js";
4-
import jest from "eslint-plugin-jest";
54
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
65
import tseslint from "typescript-eslint";
76

87
export default tseslint.config(
98
{
10-
ignores: ["lib", "node_modules", "coverage", "docs"],
9+
ignores: ["lib", "node_modules", "coverage", "docs"]
1110
},
1211
eslint.configs.recommended,
1312
eslintPluginPrettierRecommended,
14-
jest.configs["flat/recommended"],
1513
...tseslint.configs.recommended,
1614
tseslint.configs.eslintRecommended,
1715
{
@@ -25,10 +23,10 @@ export default tseslint.config(
2523
caughtErrorsIgnorePattern: "^_",
2624
destructuredArrayIgnorePattern: "^_",
2725
varsIgnorePattern: "^_",
28-
ignoreRestSiblings: true,
29-
},
26+
ignoreRestSiblings: true
27+
}
3028
],
31-
"no-undef": "off",
32-
},
33-
},
29+
"no-undef": "off"
30+
}
31+
}
3432
);

jest.config.js

Lines changed: 0 additions & 192 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,35 @@
3838
"lib"
3939
],
4040
"devDependencies": {
41+
"@commitlint/cli": "^19.5.0",
42+
"@commitlint/config-conventional": "^19.5.0",
4143
"@eslint/js": "^9.12.0",
44+
"@testdeck/mocha": "^0.3.3",
45+
"@types/chai": "^5.0.0",
4246
"@types/eslint__js": "^8.42.3",
43-
"@types/jest": "^29.5.13",
44-
"@types/jsdom": "^21.1.7",
47+
"@types/mocha": "^10.0.9",
4548
"@types/node": "<21.0.0",
46-
"@types/sharp": "^0.32.0",
49+
"@types/source-map-support": "^0.5.10",
50+
"chai": "^5.1.1",
4751
"clean-package": "^2.2.0",
4852
"eslint": "^9.12.0",
4953
"eslint-config-prettier": "^9.1.0",
50-
"eslint-plugin-jest": "^28.8.3",
5154
"eslint-plugin-prettier": "^5.2.1",
5255
"husky": "^9.1.6",
53-
"jest": "^29.7.0",
56+
"mocha": "^10.7.3",
5457
"npm-check-updates": "^17.1.4",
5558
"prettier": "^3.3.3",
5659
"rimraf": "^6.0.1",
60+
"source-map-support": "^0.5.21",
5761
"standard-version": "^9.5.0",
58-
"ts-jest": "^29.2.5",
62+
"ts-node": "^10.9.2",
5963
"typedoc": "^0.26.10",
6064
"typescript": "^5.6.3",
6165
"typescript-eslint": "^8.10.0"
6266
},
6367
"scripts": {
6468
"build": "rimraf lib && tsc",
65-
"test": "jest",
69+
"test": "mocha -p",
6670
"lint": "prettier -w . && eslint . --fix",
6771
"prepublishOnly": "npm run build",
6872
"prepare": "husky",

src/image/GIFImage.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,7 @@ export class GIFImage {
163163
out.writeByte((i >>> 8) & 0xff);
164164
}
165165

166-
private writeBytes(
167-
out: OutputStream,
168-
bytes: number[],
169-
off: number,
170-
len: number,
171-
) {
166+
private writeBytes(out: OutputStream, bytes: number[], off: number, len: number) {
172167
for (let i = 0; i < len; i += 1) {
173168
out.writeByte(bytes[i + off]);
174169
}

src/io/Base64.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ export class Base64 {
3030
public static decode(data: number[]): number[] {
3131
const bout = new ByteArrayOutputStream();
3232
try {
33-
const istream = new Base64DecodeInputStream(
34-
new ByteArrayInputStream(data),
35-
);
33+
const istream = new Base64DecodeInputStream(new ByteArrayInputStream(data));
3634
try {
3735
let b: number;
3836
while ((b = istream.readByte()) != -1) {

src/io/Base64DecodeInputStream.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ export class Base64DecodeInputStream extends InputStream {
4040
}
4141

4242
private static isWhitespace(c: number): boolean {
43-
return (
44-
c == "\v".charCodeAt(0) ||
45-
c == "\t".charCodeAt(0) ||
46-
c == "\r".charCodeAt(0) ||
47-
c == "\n".charCodeAt(0)
48-
);
43+
return c == "\v".charCodeAt(0) || c == "\t".charCodeAt(0) || c == "\r".charCodeAt(0) || c == "\n".charCodeAt(0);
4944
}
5045

5146
private static decode(c: number): number {

src/qr-code.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import { suite, test } from "@testdeck/mocha";
2+
import { expect } from "chai";
13
import * as index from "./qr-code.js";
24

3-
describe("Index", () => {
4-
it.each([
5-
"ErrorCorrectionLevel",
6-
"Mode",
7-
"QRCode",
8-
"QRCodeMinimal",
9-
"QRUtil",
10-
"stringToBytes_SJIS",
11-
"stringToBytes_UTF8",
12-
])("The module should export certain submodules", (moduleName) => {
13-
expect(Object.keys(index)).toContain(moduleName);
14-
});
15-
});
5+
@suite("Index")
6+
export class IndexTest {
7+
@test("The module should export certain submodules")
8+
exportsAll() {
9+
[
10+
"ErrorCorrectionLevel",
11+
"Mode",
12+
"QRCode",
13+
"QRCodeMinimal",
14+
"QRUtil",
15+
"stringToBytes_SJIS",
16+
"stringToBytes_UTF8"
17+
].forEach((moduleName) => expect(Object.keys(index)).to.contain(moduleName));
18+
}
19+
}

src/qr-code.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
//---------------------------------------------------------------------
2+
//
3+
// QR Code Generator for TypeScript
4+
//
5+
// Copyright (c) 2015 Kazuhiko Arase
6+
//
7+
// URL: http://www.d-project.com/
8+
//
9+
// Licensed under the MIT license:
10+
// http://www.opensource.org/licenses/mit-license.php
11+
//
12+
// The word 'QR Code' is registered trademark of
13+
// DENSO WAVE INCORPORATED
14+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
15+
//
16+
//---------------------------------------------------------------------
17+
118
export { QRCode } from "./qrcode/QRCode.js";
2-
export {
3-
ErrorCorrectionLevel,
4-
Mode,
5-
QRCodeMinimal,
6-
TypeNumber,
7-
} from "./qrcode/QRCodeMinimal.js";
19+
export { ErrorCorrectionLevel, Mode, QRCodeMinimal, TypeNumber } from "./qrcode/QRCodeMinimal.js";
820
export { QRUtil } from "./qrcode/QRUtil.js";
921
export { stringToBytes_SJIS } from "./text/stringToBytes_SJIS.js";
1022
export { stringToBytes_UTF8 } from "./text/stringToBytes_UTF8.js";

0 commit comments

Comments
 (0)