forked from w3tecch/typeorm-seeding
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove factories option from config
- Loading branch information
1 parent
7aa66a7
commit 870a23d
Showing
5 changed files
with
35 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Connection } from 'typeorm' | ||
import { configureConnection, fetchConnection, Seeder } from '../src' | ||
import { User } from './entities/User.entity' | ||
import { UserSeeder } from './seeders/User.seeder' | ||
|
||
describe(Seeder, () => { | ||
let connection: Connection | ||
const userSeeder = new UserSeeder() | ||
|
||
beforeAll(async () => { | ||
configureConnection({ connection: 'memory' }) | ||
connection = await fetchConnection() | ||
|
||
await connection.synchronize() | ||
}) | ||
|
||
afterAll(async () => { | ||
await connection.dropDatabase() | ||
await connection.close() | ||
}) | ||
|
||
describe(Seeder.prototype.run, () => { | ||
test('Should seed users', async () => { | ||
await userSeeder.run() | ||
|
||
const totalItems = await connection.createEntityManager().count(User) | ||
expect(totalItems).toBe(10) | ||
}) | ||
}) | ||
}) |