-
Notifications
You must be signed in to change notification settings - Fork 33
/
DeleteTest.ts
54 lines (38 loc) · 1.48 KB
/
DeleteTest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import * as assert from "assert";
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";
import {
IDocumentStore,
} from "../../src";
import { User } from "../Assets/Entities";
describe("session.delete()", function () {
let store: IDocumentStore;
beforeEach(async function () {
store = await testContext.getDocumentStore();
});
afterEach(async () =>
await disposeTestDocumentStore(store));
it("can delete document by entity", async () => {
const session = store.openSession();
let user: User = Object.assign(new User(), { name: "RavenDB" });
await session.store(user, "users/1");
await session.saveChanges();
user = await session.load<User>("users/1");
assert.ok(user);
await session.delete(user);
await session.saveChanges();
const nullUser = await session.load("users/1");
assert.ok(!nullUser);
});
it("can delete document by id", async () => {
const session = store.openSession();
let user: User = Object.assign(new User(), { name: "RavenDB" });
await session.store(user, "users/1");
await session.saveChanges();
user = await session.load<User>("users/1");
assert.ok(user);
await session.delete("users/1");
await session.saveChanges();
const nullUser = await session.load("users/1");
assert.ok(!nullUser);
});
});