diff --git a/jest.config.js b/jest.config.js index 3a18665..b7c76ac 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { roots: ['/src/tests/'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx|js)$': 'ts-jest', }, testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], diff --git a/package-lock.json b/package-lock.json index 8bed291..4237629 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "standard-version": "^9.3.1", "ts-jest": "^27.0.5", "ts-node": "^10.2.1", - "typescript": "^4.4.3" + "typescript": "^4.5.5" }, "optionalDependencies": { "mongodb": "^4.1.2", @@ -978,6 +978,19 @@ "node": ">=10" } }, + "node_modules/@microsoft/api-extractor/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@microsoft/tsdoc": { "version": "0.13.2", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", @@ -7310,9 +7323,9 @@ } }, "node_modules/typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8455,6 +8468,12 @@ "requires": { "lru-cache": "^6.0.0" } + }, + "typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true } } }, @@ -13423,9 +13442,9 @@ } }, "typescript": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", - "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 058932b..4fde356 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "standard-version": "^9.3.1", "ts-jest": "^27.0.5", "ts-node": "^10.2.1", - "typescript": "^4.4.3" + "typescript": "^4.5.5" }, "optionalDependencies": { "mongodb": "^4.1.2", diff --git a/src/tests/repo/helper.ts b/src/tests/repo/helper.ts new file mode 100644 index 0000000..623620e --- /dev/null +++ b/src/tests/repo/helper.ts @@ -0,0 +1,42 @@ +import { Data } from '../../app/data' +import { Entity } from '../../app/entity' +import { RepoSQLite } from '../../app/repo/sqlite' +import { StorageSQLite } from '../../app/storage/sqlite' +import { Storage } from '../../app/storage' + +export class ItemData extends Data { + uniqKey(): string { + return 'uid' + } + + uid: string + title: string +} +export class ItemEntity extends Entity { + _getRepo(storage: Storage): ItemsRepo { + return new ItemsRepo(storage) + } + + _getVO(): ItemData { + return new ItemData() + } +} +export class ItemsRepo extends RepoSQLite { + Entity(): ItemEntity { + return new ItemEntity() + } + + Name(): string { + return 'items' + } + + async Create(): Promise { + const st = this._storage as StorageSQLite + await st?.db?.run(` + create table if not exists ${this.Name()} ( + uid varchar(255) not null unique, + title text null + ) + `) + } +} diff --git a/src/tests/repo/sqlite.test.ts b/src/tests/repo/sqlite.test.ts index 4012e8d..b0eb325 100644 --- a/src/tests/repo/sqlite.test.ts +++ b/src/tests/repo/sqlite.test.ts @@ -1,47 +1,6 @@ -import { Data } from '../../app/data' -import { Entity } from '../../app/entity' -import { Storage } from '../../app/storage' -import { Repo } from '../../app/repo' -import { RepoSQLite } from '../../app/repo/sqlite' import { StorageSQLite } from '../../app/storage/sqlite' import { assert } from 'chai' - -class ItemData extends Data { - uniqKey(): string { - return 'uid' - } - - uid: string - title: string -} -class ItemEntity extends Entity { - _getRepo(storage: Storage): Repo> { - return undefined - } - - _getVO(): ItemData { - return new ItemData() - } -} -class ItemsRepo extends RepoSQLite { - Entity(): ItemEntity { - return new ItemEntity() - } - - Name(): string { - return 'items' - } - - async Create(): Promise { - const st = this._storage as StorageSQLite - await st?.db?.run(` - create table if not exists ${this.Name()} ( - uid varchar(255) not null unique, - title text null - ) - `) - } -} +import { ItemData, ItemEntity, ItemsRepo } from './helper' describe('ItemsRepoSQLite', () => { const dsn = __dirname + `/sqlite.test.db`