-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[tools] | ||
rojo = { source = "rojo-rbx/rojo", version = "=7.0.0" } | ||
run-in-roblox = { source = "rojo-rbx/run-in-roblox", version = "0.3.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
local TestEZ = require(ReplicatedStorage.rbxts.testez.src) | ||
|
||
local results = TestEZ.TestBootstrap:run({ | ||
ReplicatedStorage.Tests | ||
}) | ||
|
||
if (#results.errors > 0 or results.failureCount > 0) then | ||
error("Tests failed!") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "mock-tests", | ||
"tree": { | ||
"$className": "DataModel", | ||
"ReplicatedStorage": { | ||
"$className": "ReplicatedStorage", | ||
"MockMemoryStore": { | ||
"$path": "./lib" | ||
}, | ||
"Tests": { | ||
"$path": "./tests" | ||
}, | ||
"rbxts": { | ||
"$path": "node_modules/@rbxts" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
local MockMemoryStoreService = require(game:GetService("ReplicatedStorage").MockMemoryStore) | ||
|
||
|
||
|
||
return function () | ||
it("Should retrieve the same map", function() | ||
local TestSortedMap = MockMemoryStoreService:GetSortedMap("TestSortedMap") | ||
expect(TestSortedMap).to.be.ok() | ||
|
||
local TestSortedMap2 = MockMemoryStoreService:GetSortedMap("TestSortedMap") | ||
expect(TestSortedMap2).to.equal(TestSortedMap) -- Should be same reference | ||
end) | ||
|
||
it("Should correctly use GetAsync/SetAsync", function() | ||
local TEST_VALUE = 10 | ||
|
||
local TestSortedMap = MockMemoryStoreService:GetSortedMap("TestSortedMap") | ||
expect(TestSortedMap:SetAsync("TestSet", TEST_VALUE, 30)).to.equal(false) -- false because new value, not update. | ||
|
||
expect(TestSortedMap:GetAsync("TestSet")).to.equal(TEST_VALUE) | ||
|
||
expect(TestSortedMap:SetAsync("TestSet", TEST_VALUE + 5, 30)).to.equal(true) -- true, because updating existing value | ||
end) | ||
|
||
it("Should correctly use UpdateAsync", function() | ||
local TEST_VALUE = 32 | ||
|
||
local TestSortedMap = MockMemoryStoreService:GetSortedMap("TestSortedMap") | ||
|
||
-- This should return a value, since we've returned a value | ||
local value = TestSortedMap:UpdateAsync("TestUpdateKey", function(value) | ||
expect(value).to.be.equal(nil) -- value shouldn't be set since it's y'know, not set yet. | ||
return TEST_VALUE | ||
end, 20) | ||
|
||
-- Should have returned TEST_VALUE | ||
expect(value).to.be.equal(TEST_VALUE) | ||
|
||
local nilValue = TestSortedMap:UpdateAsync("TestUpdateKey", function(value) | ||
expect(value).to.equal(TEST_VALUE) | ||
return nil | ||
end, 20) | ||
|
||
-- Should be nil since we didn't transform | ||
expect(nilValue).to.equal(nil) | ||
end) | ||
|
||
it("Should correctly use RemoveAsync", function() | ||
local TEST_VALUE = 32 | ||
local TestSortedMap = MockMemoryStoreService:GetSortedMap("TestSortedMap") | ||
|
||
expect(TestSortedMap:SetAsync("RemoveMe", TEST_VALUE, 30)).to.equal(false) -- new value, again | ||
|
||
TestSortedMap:RemoveAsync("RemoveMe") | ||
expect(TestSortedMap:GetAsync("RemoveMe")).to.equal(nil) | ||
end) | ||
end |