Skip to content

Commit

Permalink
add a test fo rmongo
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames committed Jun 29, 2021
1 parent 43a39f5 commit a6a48f7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/functional/mongodb/basic/mongo-repository/mongo-repository.ts
Expand Up @@ -87,5 +87,29 @@ describe("mongodb > MongoRepository", () => {
})));

// todo: cover other methods as well
it("should be able to save and update mongo entities", () => Promise.all(connections.map(async connection => {
const postRepository = connection.getMongoRepository(Post);

// save few posts
const firstPost = new Post();
firstPost.title = "Post #1";
firstPost.text = "Everything about post #1";
await postRepository.save(firstPost);

const secondPost = new Post();
secondPost.title = "Post #2";
secondPost.text = "Everything about post #2";
await postRepository.save(secondPost);

// save few posts
firstPost.text = "Everything and more about post #1";
await postRepository.save(firstPost);

const loadedPosts = await postRepository.find();

loadedPosts.length.should.be.equal(2);
loadedPosts[0].text.should.be.equal("Everything and more about post #1");
loadedPosts[0].text.should.be.equal("Everything about post #2");

})));
});

0 comments on commit a6a48f7

Please sign in to comment.