fix: обновил ts

This commit is contained in:
Nikita Dezzpil Orlov 2022-01-31 17:59:56 +03:00
parent aa38fae8cc
commit def5b75101
5 changed files with 71 additions and 51 deletions

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.default = { exports.default = {
roots: ['<rootDir>/src/tests/'], roots: ['<rootDir>/src/tests/'],
transform: { transform: {
'^.+\\.(ts|tsx)$': 'ts-jest', '^.+\\.(ts|tsx|js)$': 'ts-jest',
}, },
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],

33
package-lock.json generated
View File

@ -27,7 +27,7 @@
"standard-version": "^9.3.1", "standard-version": "^9.3.1",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"ts-node": "^10.2.1", "ts-node": "^10.2.1",
"typescript": "^4.4.3" "typescript": "^4.5.5"
}, },
"optionalDependencies": { "optionalDependencies": {
"mongodb": "^4.1.2", "mongodb": "^4.1.2",
@ -978,6 +978,19 @@
"node": ">=10" "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": { "node_modules/@microsoft/tsdoc": {
"version": "0.13.2", "version": "0.13.2",
"resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz",
@ -7310,9 +7323,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.4.3", "version": "4.5.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -8455,6 +8468,12 @@
"requires": { "requires": {
"lru-cache": "^6.0.0" "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": { "typescript": {
"version": "4.4.3", "version": "4.5.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {

View File

@ -46,7 +46,7 @@
"standard-version": "^9.3.1", "standard-version": "^9.3.1",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"ts-node": "^10.2.1", "ts-node": "^10.2.1",
"typescript": "^4.4.3" "typescript": "^4.5.5"
}, },
"optionalDependencies": { "optionalDependencies": {
"mongodb": "^4.1.2", "mongodb": "^4.1.2",

42
src/tests/repo/helper.ts Normal file
View File

@ -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<ItemData> {
_getRepo(storage: Storage): ItemsRepo {
return new ItemsRepo(storage)
}
_getVO(): ItemData {
return new ItemData()
}
}
export class ItemsRepo extends RepoSQLite<ItemEntity> {
Entity(): ItemEntity {
return new ItemEntity()
}
Name(): string {
return 'items'
}
async Create(): Promise<void> {
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
)
`)
}
}

View File

@ -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 { StorageSQLite } from '../../app/storage/sqlite'
import { assert } from 'chai' import { assert } from 'chai'
import { ItemData, ItemEntity, ItemsRepo } from './helper'
class ItemData extends Data {
uniqKey(): string {
return 'uid'
}
uid: string
title: string
}
class ItemEntity extends Entity<ItemData> {
_getRepo(storage: Storage): Repo<Entity<ItemData>> {
return undefined
}
_getVO(): ItemData {
return new ItemData()
}
}
class ItemsRepo extends RepoSQLite<ItemEntity> {
Entity(): ItemEntity {
return new ItemEntity()
}
Name(): string {
return 'items'
}
async Create(): Promise<void> {
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
)
`)
}
}
describe('ItemsRepoSQLite', () => { describe('ItemsRepoSQLite', () => {
const dsn = __dirname + `/sqlite.test.db` const dsn = __dirname + `/sqlite.test.db`