(author: Author, mock: Mock)
| 203 | } |
| 204 | |
| 205 | async function assert(author: Author, mock: Mock) { |
| 206 | expect(mock.mock.calls).toMatchSnapshot(); |
| 207 | mock.mockReset(); |
| 208 | await orm.em.flush(); |
| 209 | expect(mock).not.toHaveBeenCalled(); |
| 210 | |
| 211 | author.age = 123; |
| 212 | await orm.em.flush(); |
| 213 | expect(mock).toHaveBeenCalled(); |
| 214 | |
| 215 | orm.em.clear(); |
| 216 | const authors = await orm.em.find(Author, {}, { orderBy: { email: 'asc' } }); |
| 217 | expect(authors).toHaveLength(3); |
| 218 | |
| 219 | mock.mockReset(); |
| 220 | authors[1].age = 321; |
| 221 | const author12 = await orm.em.upsert(authors[0]); // exists |
| 222 | const author22 = await orm.em.upsert(authors[1]); // exists |
| 223 | const author32 = await orm.em.upsert(authors[2]); // exists |
| 224 | expect(author12).toBe(authors[0]); |
| 225 | expect(author22).toBe(authors[1]); |
| 226 | expect(author32).toBe(authors[2]); |
| 227 | expect(author22.age).toBe(321); |
| 228 | await orm.em.refresh(author22); |
| 229 | expect(author22.age).toBe(321); |
| 230 | |
| 231 | expect(orm.em.getUnitOfWork().getIdentityMap().keys()).toHaveLength(3); |
| 232 | } |
| 233 | |
| 234 | async function assertFooBars(fooBars: FooBar[], mock: Mock) { |
| 235 | expect(mock.mock.calls).toMatchSnapshot(); |
no test coverage detected