Replaced deprecated Connection
API in tests (#451)
This commit is contained in:
parent
8832cfae74
commit
30f4b45785
@ -1,4 +1,4 @@
|
|||||||
import { createConnection, Repository, In, Connection } from 'typeorm'
|
import { Repository, In, DataSource } from 'typeorm'
|
||||||
import {
|
import {
|
||||||
Paginated,
|
Paginated,
|
||||||
paginate,
|
paginate,
|
||||||
@ -17,7 +17,7 @@ import { CatHomeEntity } from './__tests__/cat-home.entity'
|
|||||||
import { clone } from 'lodash'
|
import { clone } from 'lodash'
|
||||||
|
|
||||||
describe('paginate', () => {
|
describe('paginate', () => {
|
||||||
let connection: Connection
|
let dataSource: DataSource
|
||||||
let catRepo: Repository<CatEntity>
|
let catRepo: Repository<CatEntity>
|
||||||
let catToyRepo: Repository<CatToyEntity>
|
let catToyRepo: Repository<CatToyEntity>
|
||||||
let catHomeRepo: Repository<CatHomeEntity>
|
let catHomeRepo: Repository<CatHomeEntity>
|
||||||
@ -26,16 +26,18 @@ describe('paginate', () => {
|
|||||||
let catHomes: CatHomeEntity[]
|
let catHomes: CatHomeEntity[]
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
connection = await createConnection({
|
dataSource = new DataSource({
|
||||||
type: 'sqlite',
|
type: 'sqlite',
|
||||||
database: ':memory:',
|
database: ':memory:',
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [CatEntity, CatToyEntity, CatHomeEntity],
|
entities: [CatEntity, CatToyEntity, CatHomeEntity],
|
||||||
})
|
})
|
||||||
catRepo = connection.getRepository(CatEntity)
|
await dataSource.initialize()
|
||||||
catToyRepo = connection.getRepository(CatToyEntity)
|
catRepo = dataSource.getRepository(CatEntity)
|
||||||
catHomeRepo = connection.getRepository(CatHomeEntity)
|
catToyRepo = dataSource.getRepository(CatToyEntity)
|
||||||
|
catHomeRepo = dataSource.getRepository(CatHomeEntity)
|
||||||
|
|
||||||
cats = await catRepo.save([
|
cats = await catRepo.save([
|
||||||
catRepo.create({ name: 'Milo', color: 'brown', age: 6, size: { height: 25, width: 10, length: 40 } }),
|
catRepo.create({ name: 'Milo', color: 'brown', age: 6, size: { height: 25, width: 10, length: 40 } }),
|
||||||
catRepo.create({ name: 'Garfield', color: 'ginger', age: 5, size: { height: 30, width: 15, length: 45 } }),
|
catRepo.create({ name: 'Garfield', color: 'ginger', age: 5, size: { height: 30, width: 15, length: 45 } }),
|
||||||
@ -98,7 +100,7 @@ describe('paginate', () => {
|
|||||||
path: '',
|
path: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryBuilder = await connection
|
const queryBuilder = await dataSource
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.select('cats')
|
.select('cats')
|
||||||
.from(CatEntity, 'cats')
|
.from(CatEntity, 'cats')
|
||||||
|
Loading…
Reference in New Issue
Block a user