Last active
October 4, 2019 15:34
-
-
Save radzserg/0326d77347f6685d9aa113da13fb3b7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const di: IDIContainer = configureTestDI(); | |
| const knex = di.get<Knex>(APP_DEP.DB); | |
| const dbSeeder = di.get<DbSeeder>(APP_DEP.TEST_DB_SEEDER); | |
| const repo = new PostsRepo(knex); | |
| describe("PostsRepo", () => { | |
| // to speed up our tests and do not trash test DB | |
| // we will run test in the transaction and roll it back after execution | |
| beforeEach(async () => { | |
| await knex.raw("BEGIN"); | |
| }); | |
| afterEach(async () => { | |
| await knex.raw("ROLLBACK"); | |
| }); | |
| it("updates existing post", async () => { | |
| await dbSeeder.insert("post", { id: 12, title: "title1" }); | |
| repo.updatePost(12, { title: "title 2" }); | |
| const [updatedPost] = await knex("posts").where({ id: 12 }); | |
| expect(updatedPost.title).toEqual("title 2"); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment