Skip to content

Commit 4a5837b

Browse files
committed
Start to tests
1 parent fa48b1c commit 4a5837b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/integration/batch.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import makeServer from './drivers/default/server';
2+
import Post from '../stubs/models/post';
3+
import { Batch } from '../../src/batch';
4+
5+
let server: any;
6+
7+
beforeEach(() => {
8+
server = makeServer();
9+
});
10+
11+
afterEach(() => {
12+
server.shutdown();
13+
});
14+
15+
describe('Batch tests', () => {
16+
test('saving a couple of models', async () => {
17+
await Batch.store(
18+
[
19+
new Post({title: "item1", id: 10, created_at: "", updated_at: ""}),
20+
new Post({title: "item2", id: 12, created_at: "", updated_at: ""}),
21+
]
22+
)
23+
});
24+
25+
test('updating a couple of models', async () => {
26+
const post1 = await Post.$query().find(1);
27+
const post2 = await Post.$query().find(2);
28+
29+
post1.$attributes.title = "new title";
30+
post2.$attributes.title = "newer title";
31+
32+
await Batch.update(
33+
[
34+
post1, post2
35+
]
36+
)
37+
});
38+
});

0 commit comments

Comments
 (0)