-
Notifications
You must be signed in to change notification settings - Fork 6
/
storageSpec.js
114 lines (90 loc) · 3.16 KB
/
storageSpec.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
describe("Storage", function() {
var storage;
beforeEach(function() {
storage = getStorage(new TransientStorage());
});
afterEach(function() {
});
it("should be able to get a non null storage", function() {
expect(storage).not.toBeNull();
expect(storage).toBeDefined();
});
it("should be able to get a blank storage", function() {
expect(storage).not.toBeNull();
expect(storage).toBeDefined();
expect(storage.backend instanceof TransientStorage).toBeTruthy();
expect(storage.databank).not.toBeNull();
expect(storage.databank).toBeDefined();
});
it("should be able to store properties relations", function() {
var object = 'Unreal Engine';
var relation = 'website';
var name = 'http://unrealengine.com';
var real_name = "Unreal_Engine";
storage.storeProperty(object, relation, name);
var result = storage.queryProperty(object, relation);
expect(result.value).toEqual(name);
});
it("should be able to retrieve all properties", function() {
var data = [ { name: 'http://unrealengine.com',
relation: 'website' },
{ name: '3D',
relation: 'type' } ];
var object = 'Unreal Engine';
var real_name = "Unreal_Engine";
for (var i in data) {
storage.storeProperty(object, data[i].relation, data[i].name);
}
var result = storage.queryAllProperties(object);
expect(result instanceof Array).toBeTruthy();
expect(result.length).toEqual(2);
for (var i in data) {
expect(result).toContain(data[i]);
}
});
it("should be able to query databank for properties and fail properly", function() {
// TODO should add something to refresh databank between each test
var object = 'flower';
var name = 'Bert';
var relation = 'colour';
var result = storage.queryProperty(name,relation);
expect(result).toEqual(undefined);
});
it("should be able to store named entities", function() {
var object = 'robot';
var name = 'Robbie';
storage.storeEntity(object, name);
var result = storage.queryEntity(name);
expect(result.type).toEqual(object);
});
it("should be able to query databank", function() {
var object = 'robot';
var name = 'Robbie';
storage.storeEntity(object, name);
var result = storage.queryEntity(name);
expect(result.type).toEqual(object);
})
it("should be able to query databank and fail properly", function() {
// TODO should add something to refresh databank between each test
var object = 'flower';
var name = 'Bert';
var result = storage.queryEntity(name);
expect(result).toEqual(undefined);
});
it("should persist the transcript", function(){
fail();
});
it("can be cleared", function() {
var storage = getStorage(new TransientStorage());
expect(storage).not.toBeNull();
expect(storage).toBeDefined();
var object = 'robot';
var name = 'Robbie';
storage.storeEntity(object, name);
var result = storage.queryEntity(name);
expect(result.type).toEqual(object);
storage.clearDatabank();
var result = storage.queryEntity(name);
expect(result).toBeUndefined();
});
});