@quenty/observablecollection 12.19.4-canary.544.d46888c.0 → 12.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/package.json +15 -15
- package/src/Shared/ObservableCountingMap.spec.lua +29 -32
- package/src/Shared/ObservableList.spec.lua +88 -91
- package/src/Shared/ObservableMap.spec.lua +48 -51
- package/src/Shared/ObservableMapList.spec.lua +13 -16
- package/src/Shared/SortedList/ObservableSortedList.spec.lua +33 -36
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [12.19.4
|
|
6
|
+
## [12.19.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@12.19.3...@quenty/observablecollection@12.19.4) (2025-03-31)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @quenty/observablecollection
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/observablecollection",
|
|
3
|
-
"version": "12.19.4
|
|
3
|
+
"version": "12.19.4",
|
|
4
4
|
"description": "A set of observable collections, such as sets, maps, sorted lists, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"Quenty"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/baseobject": "10.8.0",
|
|
31
|
-
"@quenty/brio": "14.16.2
|
|
32
|
-
"@quenty/ducktype": "5.8.1",
|
|
33
|
-
"@quenty/loader": "10.8.0",
|
|
34
|
-
"@quenty/maid": "3.4.0",
|
|
35
|
-
"@quenty/promise": "10.10.1",
|
|
36
|
-
"@quenty/rx": "13.16.2
|
|
37
|
-
"@quenty/signal": "7.10.0",
|
|
38
|
-
"@quenty/steputils": "3.5.3",
|
|
39
|
-
"@quenty/symbol": "3.4.0",
|
|
40
|
-
"@quenty/table": "3.7.1",
|
|
41
|
-
"@quenty/valueobject": "13.16.2
|
|
30
|
+
"@quenty/baseobject": "^10.8.0",
|
|
31
|
+
"@quenty/brio": "^14.16.2",
|
|
32
|
+
"@quenty/ducktype": "^5.8.1",
|
|
33
|
+
"@quenty/loader": "^10.8.0",
|
|
34
|
+
"@quenty/maid": "^3.4.0",
|
|
35
|
+
"@quenty/promise": "^10.10.1",
|
|
36
|
+
"@quenty/rx": "^13.16.2",
|
|
37
|
+
"@quenty/signal": "^7.10.0",
|
|
38
|
+
"@quenty/steputils": "^3.5.3",
|
|
39
|
+
"@quenty/symbol": "^3.4.0",
|
|
40
|
+
"@quenty/table": "^3.7.1",
|
|
41
|
+
"@quenty/valueobject": "^13.16.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@quenty/blend": "12.17.2
|
|
44
|
+
"@quenty/blend": "^12.17.2"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "af926ec08f523833f37d22477c72dca034219823"
|
|
50
50
|
}
|
|
@@ -4,38 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
6
|
|
|
7
|
-
local Jest = require("Jest")
|
|
8
7
|
local ObservableCountingMap = require("ObservableCountingMap")
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
local
|
|
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
|
-
it("should clean up", function()
|
|
39
|
-
observableCountingMap:Destroy()
|
|
9
|
+
return function()
|
|
10
|
+
describe("ObservableCountingMap.new()", function()
|
|
11
|
+
local observableCountingMap = ObservableCountingMap.new()
|
|
12
|
+
|
|
13
|
+
it("should return 0 for unset values", function()
|
|
14
|
+
expect(observableCountingMap:Get("a")).to.equal(0)
|
|
15
|
+
expect(observableCountingMap:GetTotalKeyCount()).to.equal(0)
|
|
16
|
+
end)
|
|
17
|
+
|
|
18
|
+
it("should allow you to add to a value", function()
|
|
19
|
+
expect(observableCountingMap:Get("a")).to.equal(0)
|
|
20
|
+
expect(observableCountingMap:GetTotalKeyCount()).to.equal(0)
|
|
21
|
+
observableCountingMap:Add("a", 5)
|
|
22
|
+
expect(observableCountingMap:Get("a")).to.equal(5)
|
|
23
|
+
expect(observableCountingMap:GetTotalKeyCount()).to.equal(1)
|
|
24
|
+
end)
|
|
25
|
+
|
|
26
|
+
it("should allow you to add to a value that is already defined", function()
|
|
27
|
+
expect(observableCountingMap:Get("a")).to.equal(5)
|
|
28
|
+
expect(observableCountingMap:GetTotalKeyCount()).to.equal(1)
|
|
29
|
+
observableCountingMap:Add("a", 5)
|
|
30
|
+
expect(observableCountingMap:Get("a")).to.equal(10)
|
|
31
|
+
expect(observableCountingMap:GetTotalKeyCount()).to.equal(1)
|
|
32
|
+
end)
|
|
33
|
+
|
|
34
|
+
it("should clean up", function()
|
|
35
|
+
observableCountingMap:Destroy()
|
|
36
|
+
end)
|
|
40
37
|
end)
|
|
41
|
-
end
|
|
38
|
+
end
|
|
@@ -4,130 +4,127 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
6
|
|
|
7
|
-
local Jest = require("Jest")
|
|
8
7
|
local ObservableList = require("ObservableList")
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
local
|
|
9
|
+
return function()
|
|
10
|
+
describe("ObservableList.new()", function()
|
|
11
|
+
local observableList = ObservableList.new()
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
it("should return nil for unset values", function()
|
|
18
|
-
expect(observableList:Get(1)).toEqual(nil)
|
|
19
|
-
end)
|
|
13
|
+
it("should return nil for unset values", function()
|
|
14
|
+
expect(observableList:Get(1)).to.equal(nil)
|
|
15
|
+
end)
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
it("should allow inserting an value", function()
|
|
18
|
+
expect(observableList:GetCount()).to.equal(0)
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
observableList:Add("a")
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
expect(observableList:Get(1)).to.equal("a")
|
|
23
|
+
expect(observableList:GetCount()).to.equal(1)
|
|
24
|
+
end)
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
it("should allow negative queries", function()
|
|
27
|
+
expect(observableList:Get(-1)).to.equal("a")
|
|
28
|
+
expect(observableList:Get(-2)).to.equal(nil)
|
|
29
|
+
end)
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
it("should allow false as a value", function()
|
|
32
|
+
expect(observableList:Get(2)).to.equal(nil)
|
|
33
|
+
observableList:Add(false)
|
|
34
|
+
expect(observableList:Get(2)).to.equal(false)
|
|
35
|
+
end)
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
it("should allow negative queries after false", function()
|
|
38
|
+
expect(observableList:Get(1)).to.equal("a")
|
|
39
|
+
expect(observableList:Get(2)).to.equal(false)
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
end)
|
|
48
|
-
|
|
49
|
-
it("should fire off events for a specific key", function()
|
|
50
|
-
local seen = {}
|
|
51
|
-
local sub = observableList:ObserveIndex(1):Subscribe(function(value)
|
|
52
|
-
table.insert(seen, value)
|
|
41
|
+
expect(observableList:Get(-1)).to.equal(false)
|
|
42
|
+
expect(observableList:Get(-2)).to.equal("a")
|
|
53
43
|
end)
|
|
54
|
-
observableList:InsertAt("c", 1)
|
|
55
44
|
|
|
56
|
-
|
|
45
|
+
it("should fire off events for a specific key", function()
|
|
46
|
+
local seen = {}
|
|
47
|
+
local sub = observableList:ObserveIndex(1):Subscribe(function(value)
|
|
48
|
+
table.insert(seen, value)
|
|
49
|
+
end)
|
|
50
|
+
observableList:InsertAt("c", 1)
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
expect(seen[1]).toEqual(1)
|
|
60
|
-
expect(seen[2]).toEqual(2)
|
|
61
|
-
end)
|
|
52
|
+
sub:Destroy()
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
table.insert(seen, value)
|
|
54
|
+
expect(#seen).to.equal(2)
|
|
55
|
+
expect(seen[1]).to.equal(1)
|
|
56
|
+
expect(seen[2]).to.equal(2)
|
|
67
57
|
end)
|
|
68
|
-
observableList:Add("a")
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
it("should fire off events for all keys", function()
|
|
60
|
+
local seen = {}
|
|
61
|
+
local sub = observableList:ObserveItemsBrio():Subscribe(function(value)
|
|
62
|
+
table.insert(seen, value)
|
|
63
|
+
end)
|
|
64
|
+
observableList:Add("a")
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
expect(#seen).to.equal(4)
|
|
67
|
+
expect(seen[4]:GetValue()).to.equal("a")
|
|
68
|
+
expect(seen[4]:IsDead()).to.equal(false)
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
expect(seen[4]:IsDead()).toEqual(true)
|
|
78
|
-
end)
|
|
70
|
+
sub:Destroy()
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
local sub = observableList:ObserveAtIndex(1):Subscribe(function(value)
|
|
83
|
-
table.insert(seen, value)
|
|
72
|
+
expect(#seen).to.equal(4)
|
|
73
|
+
expect(seen[4]:IsDead()).to.equal(true)
|
|
84
74
|
end)
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
it("it should be able to observe a specific key", function()
|
|
77
|
+
local seen = {}
|
|
78
|
+
local sub = observableList:ObserveAtIndex(1):Subscribe(function(value)
|
|
79
|
+
table.insert(seen, value)
|
|
80
|
+
end)
|
|
88
81
|
|
|
89
|
-
|
|
82
|
+
local originalList = observableList:GetList()
|
|
83
|
+
expect(originalList[1]).to.equal("c")
|
|
90
84
|
|
|
91
|
-
|
|
85
|
+
observableList:InsertAt("dragon", 1)
|
|
92
86
|
|
|
93
|
-
|
|
94
|
-
expect(seen[1]).toEqual("c")
|
|
95
|
-
expect(seen[2]).toEqual("dragon")
|
|
96
|
-
end)
|
|
87
|
+
sub:Destroy()
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
table.insert(seen, value)
|
|
89
|
+
expect(#seen).to.equal(2)
|
|
90
|
+
expect(seen[1]).to.equal("c")
|
|
91
|
+
expect(seen[2]).to.equal("dragon")
|
|
102
92
|
end)
|
|
103
93
|
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
it("it should be able to observe a specific negative key", function()
|
|
95
|
+
local seen = {}
|
|
96
|
+
local sub = observableList:ObserveAtIndex(-1):Subscribe(function(value)
|
|
97
|
+
table.insert(seen, value)
|
|
98
|
+
end)
|
|
106
99
|
|
|
107
|
-
|
|
100
|
+
local originalList = observableList:GetList()
|
|
101
|
+
expect(originalList[#originalList]).to.equal("a")
|
|
108
102
|
|
|
109
|
-
|
|
103
|
+
observableList:Add("fire")
|
|
110
104
|
|
|
111
|
-
|
|
112
|
-
expect(seen[1]).toEqual("a")
|
|
113
|
-
expect(seen[2]).toEqual("fire")
|
|
114
|
-
end)
|
|
105
|
+
sub:Destroy()
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
table.insert(seen, value)
|
|
107
|
+
expect(#seen).to.equal(2)
|
|
108
|
+
expect(seen[1]).to.equal("a")
|
|
109
|
+
expect(seen[2]).to.equal("fire")
|
|
120
110
|
end)
|
|
121
|
-
observableList:RemoveAt(1)
|
|
122
111
|
|
|
123
|
-
|
|
112
|
+
it("should fire off events on removal", function()
|
|
113
|
+
local seen = {}
|
|
114
|
+
local sub = observableList:ObserveIndex(2):Subscribe(function(value)
|
|
115
|
+
table.insert(seen, value)
|
|
116
|
+
end)
|
|
117
|
+
observableList:RemoveAt(1)
|
|
124
118
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
sub:Destroy()
|
|
120
|
+
|
|
121
|
+
expect(#seen).to.equal(2)
|
|
122
|
+
expect(seen[1]).to.equal(2)
|
|
123
|
+
expect(seen[2]).to.equal(1)
|
|
124
|
+
end)
|
|
129
125
|
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
it("should clean up", function()
|
|
127
|
+
observableList:Destroy()
|
|
128
|
+
end)
|
|
132
129
|
end)
|
|
133
|
-
end
|
|
130
|
+
end
|
|
@@ -4,74 +4,71 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
6
|
|
|
7
|
-
local Jest = require("Jest")
|
|
8
7
|
local ObservableMap = require("ObservableMap")
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
local
|
|
9
|
+
return function()
|
|
10
|
+
describe("ObservableMap.new()", function()
|
|
11
|
+
local observableMap = ObservableMap.new()
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
it("should return nil for unset values", function()
|
|
18
|
-
expect(observableMap:Get("a")).toEqual(nil)
|
|
19
|
-
end)
|
|
13
|
+
it("should return nil for unset values", function()
|
|
14
|
+
expect(observableMap:Get("a")).to.equal(nil)
|
|
15
|
+
end)
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
it("should allow setting a value", function()
|
|
18
|
+
expect(observableMap:GetCount()).to.equal(0)
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
observableMap:Set("a", "Hello World")
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
it("should overwrite values", function()
|
|
31
|
-
expect(observableMap:Get("a")).toEqual("Hello World")
|
|
22
|
+
expect(observableMap:Get("a")).to.equal("Hello World")
|
|
23
|
+
expect(observableMap:GetCount()).to.equal(1)
|
|
24
|
+
end)
|
|
32
25
|
|
|
33
|
-
|
|
26
|
+
it("should overwrite values", function()
|
|
27
|
+
expect(observableMap:Get("a")).to.equal("Hello World")
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
end)
|
|
29
|
+
observableMap:Set("a", "Hello World 2")
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
observableMap:Set(false, "Hello")
|
|
41
|
-
expect(observableMap:Get(false)).toEqual("Hello")
|
|
42
|
-
end)
|
|
31
|
+
expect(observableMap:Get("a")).to.equal("Hello World 2")
|
|
32
|
+
end)
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
it("should allow false as a key", function()
|
|
35
|
+
expect(observableMap:Get(false)).to.equal(nil)
|
|
36
|
+
observableMap:Set(false, "Hello")
|
|
37
|
+
expect(observableMap:Get(false)).to.equal("Hello")
|
|
48
38
|
end)
|
|
49
|
-
observableMap:Set("c", "Hello")
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
it("should fire off events for a specific key", function()
|
|
41
|
+
local seen = {}
|
|
42
|
+
local sub = observableMap:ObserveValueForKey("c"):Subscribe(function(value)
|
|
43
|
+
table.insert(seen, value)
|
|
44
|
+
end)
|
|
45
|
+
observableMap:Set("c", "Hello")
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
expect(seen[1]).toEqual("Hello")
|
|
55
|
-
end)
|
|
47
|
+
sub:Destroy()
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
local sub = observableMap:ObserveValuesBrio():Subscribe(function(value)
|
|
60
|
-
table.insert(seen, value)
|
|
49
|
+
expect(#seen).to.equal(1)
|
|
50
|
+
expect(seen[1]).to.equal("Hello")
|
|
61
51
|
end)
|
|
62
|
-
observableMap:Set("d", "Hello")
|
|
63
52
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
it("should fire off events for all keys", function()
|
|
54
|
+
local seen = {}
|
|
55
|
+
local sub = observableMap:ObserveValuesBrio():Subscribe(function(value)
|
|
56
|
+
table.insert(seen, value)
|
|
57
|
+
end)
|
|
58
|
+
observableMap:Set("d", "Hello")
|
|
67
59
|
|
|
68
|
-
|
|
60
|
+
expect(#seen).to.equal(4)
|
|
61
|
+
expect(seen[4]:GetValue()).to.equal("Hello")
|
|
62
|
+
expect(seen[4]:IsDead()).to.equal(false)
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
expect(seen[4]:IsDead()).toEqual(true)
|
|
72
|
-
end)
|
|
64
|
+
sub:Destroy()
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
expect(#seen).to.equal(4)
|
|
67
|
+
expect(seen[4]:IsDead()).to.equal(true)
|
|
68
|
+
end)
|
|
69
|
+
|
|
70
|
+
it("should clean up", function()
|
|
71
|
+
observableMap:Destroy()
|
|
72
|
+
end)
|
|
76
73
|
end)
|
|
77
|
-
end
|
|
74
|
+
end
|
|
@@ -4,24 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
6
|
|
|
7
|
-
local Jest = require("Jest")
|
|
8
7
|
local ObservableMapList = require("ObservableMapList")
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
local
|
|
9
|
+
return function()
|
|
10
|
+
describe("ObservableMapList.new()", function()
|
|
11
|
+
local observableMapList = ObservableMapList.new()
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
it("should return nil for unset values", function()
|
|
14
|
+
expect(observableMapList:GetAtListIndex("dragon", 1)).to.equal(nil)
|
|
15
|
+
end)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
it("should allow additions", function()
|
|
18
|
+
observableMapList:Add("hello", "dragon")
|
|
19
|
+
expect(observableMapList:GetAtListIndex("dragon", 1)).to.equal("hello")
|
|
20
|
+
expect(observableMapList:GetAtListIndex("dragon", -1)).to.equal("hello")
|
|
21
|
+
expect(observableMapList:GetAtListIndex("fire", 1)).to.equal(nil)
|
|
22
|
+
end)
|
|
19
23
|
end)
|
|
20
|
-
|
|
21
|
-
it("should allow additions", function()
|
|
22
|
-
observableMapList:Add("hello", "dragon")
|
|
23
|
-
expect(observableMapList:GetAtListIndex("dragon", 1)).toEqual("hello")
|
|
24
|
-
expect(observableMapList:GetAtListIndex("dragon", -1)).toEqual("hello")
|
|
25
|
-
expect(observableMapList:GetAtListIndex("fire", 1)).toEqual(nil)
|
|
26
|
-
end)
|
|
27
|
-
end)
|
|
24
|
+
end
|
|
@@ -4,56 +4,53 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
6
|
|
|
7
|
-
local Jest = require("Jest")
|
|
8
7
|
local ObservableSortedList = require("ObservableSortedList")
|
|
9
8
|
local Rx = require("Rx")
|
|
10
9
|
local StepUtils = require("StepUtils")
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
local
|
|
11
|
+
return function()
|
|
12
|
+
describe("ObservableSortedList.new()", function()
|
|
13
|
+
local observableSortedList = ObservableSortedList.new()
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
it("should return nil for unset values", function()
|
|
16
|
+
expect(observableSortedList:Get(1)).to.equal(nil)
|
|
17
|
+
end)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end)
|
|
22
|
-
|
|
23
|
-
it("should allow inserting an value", function()
|
|
24
|
-
expect(observableSortedList:GetCount()).toEqual(0)
|
|
19
|
+
it("should allow inserting an value", function()
|
|
20
|
+
expect(observableSortedList:GetCount()).to.equal(0)
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
observableSortedList:Add("b", Rx.of("b"))
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
StepUtils.deferWait()
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
expect(observableSortedList:Get(1)).to.equal("b")
|
|
27
|
+
expect(observableSortedList:GetCount()).to.equal(1)
|
|
28
|
+
end)
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
it("should sort the items", function()
|
|
31
|
+
expect(observableSortedList:GetCount()).to.equal(1)
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
observableSortedList:Add("a", Rx.of("a"))
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
StepUtils.deferWait()
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
expect(observableSortedList:Get(1)).to.equal("a")
|
|
38
|
+
expect(observableSortedList:Get(2)).to.equal("b")
|
|
39
|
+
expect(observableSortedList:GetCount()).to.equal(2)
|
|
40
|
+
end)
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
it("should add in order if number is the same", function()
|
|
43
|
+
observableSortedList = ObservableSortedList.new()
|
|
44
|
+
observableSortedList:Add("a", Rx.of(0))
|
|
45
|
+
observableSortedList:Add("b", Rx.of(0))
|
|
46
|
+
observableSortedList:Add("c", Rx.of(0))
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
StepUtils.deferWait()
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
expect(observableSortedList:Get(1)).to.equal("a")
|
|
51
|
+
expect(observableSortedList:Get(2)).to.equal("b")
|
|
52
|
+
expect(observableSortedList:Get(3)).to.equal("c")
|
|
53
|
+
expect(observableSortedList:GetCount()).to.equal(3)
|
|
54
|
+
end)
|
|
58
55
|
end)
|
|
59
|
-
end
|
|
56
|
+
end
|