-
Notifications
You must be signed in to change notification settings - Fork 33
/
RavenDB_11770.ts
73 lines (56 loc) · 2.16 KB
/
RavenDB_11770.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as assert from "assert";
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";
import {
IDocumentStore,
} from "../../src";
import { Company } from "../Assets/Entities";
import { delay } from "../../src/Utility/PromiseUtil";
describe("RavenDB_11770Test", function () {
let store: IDocumentStore;
beforeEach(async function () {
store = await testContext.getDocumentStore();
});
afterEach(async () =>
await disposeTestDocumentStore(store));
it("canGetRevisionsByDate", async () => {
const id = "users/1";
await testContext.setupRevisions(store, false, 100);
{
const session = store.openSession();
const company = Object.assign(new Company(), { name: "Fitzchak" });
await session.store(company, id);
await session.saveChanges();
}
await delay(2);
const fst = new Date();
for (let i = 0; i < 3; i++) {
{
const session = store.openSession();
const company = await session.load<Company>(id);
company.name = "Fitzchak" + i;
await session.saveChanges();
await delay(2);
}
}
const snd = new Date();
for (let i = 0; i < 3; i++) {
{
const session = store.openSession();
const company = await session.load<Company>(id);
company.name = "Oren" + i;
await session.saveChanges();
}
await delay(2);
}
{
const session = store.openSession();
const rev1 = await session.advanced.revisions.get<Company>(id, fst);
assert.ok(rev1);
assert.strictEqual(rev1.name, "Fitzchak");
const rev2 = await session.advanced.revisions.get<Company>(id, snd);
assert.strictEqual(rev2.name, "Fitzchak2");
const rev3 = await session.advanced.revisions.get<Company>(id, new Date());
assert.strictEqual(rev3.name, "Oren2");
}
});
});