add gs
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"language": {
|
||||
"mode": "nonstrict"
|
||||
},
|
||||
"lint": {
|
||||
"ImplicitReturn": "fatal"
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
local SetFriendCount = require(CorePackages.AppTempCommon.LuaApp.Actions.SetFriendCount)
|
||||
|
||||
return function(state, action)
|
||||
state = state or 0
|
||||
|
||||
if action.type == SetFriendCount.name then
|
||||
state = action.count
|
||||
end
|
||||
|
||||
return state
|
||||
end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
return function()
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
local FriendCount = require(CorePackages.AppTempCommon.LuaChat.Reducers.FriendCount)
|
||||
local SetFriendCount = require(CorePackages.AppTempCommon.LuaApp.Actions.SetFriendCount)
|
||||
|
||||
it("should be zero by default", function()
|
||||
local state = FriendCount(nil, {})
|
||||
|
||||
expect(state).to.equal(0)
|
||||
end)
|
||||
|
||||
it("should respond to SetFriendCount", function()
|
||||
local state = FriendCount(nil, {})
|
||||
state = FriendCount(state, SetFriendCount(520))
|
||||
|
||||
expect(state).to.equal(520)
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Common = CorePackages.AppTempCommon.Common
|
||||
local LuaChat = CorePackages.AppTempCommon.LuaChat
|
||||
|
||||
local ReceivedMultiplePlaceInfos = require(LuaChat.Actions.ReceivedMultiplePlaceInfos)
|
||||
|
||||
local Immutable = require(Common.Immutable)
|
||||
|
||||
return function(state, action)
|
||||
state = state or {}
|
||||
if action.type == ReceivedMultiplePlaceInfos.name then
|
||||
|
||||
local newInfos = {}
|
||||
for _, placeInfo in ipairs(action.placeInfos) do
|
||||
newInfos[placeInfo.placeId] = placeInfo
|
||||
end
|
||||
|
||||
state = Immutable.JoinDictionaries(state, newInfos)
|
||||
end
|
||||
return state
|
||||
end
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
return function()
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local LuaApp = CorePackages.AppTempCommon.LuaApp
|
||||
local LuaChat = CorePackages.AppTempCommon.LuaChat
|
||||
|
||||
local MockId = require(LuaApp.MockId)
|
||||
local ReceivedMultiplePlaceInfos = require(LuaChat.Actions.ReceivedMultiplePlaceInfos)
|
||||
|
||||
local PlaceInfosReducer = require(script.Parent.PlaceInfos)
|
||||
|
||||
describe("initial state", function()
|
||||
it("should return an initial table when passed nil", function()
|
||||
local state = PlaceInfosReducer(nil, {})
|
||||
expect(state).to.be.a("table")
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("ReceivedMultiplePlaceInfos", function()
|
||||
it("should add place info to the store", function()
|
||||
local state = PlaceInfosReducer(nil, {})
|
||||
|
||||
local placeId = MockId()
|
||||
local returnedPlaceInfo = ReceivedMultiplePlaceInfos({
|
||||
{
|
||||
placeId = placeId,
|
||||
imageToken = "image-token",
|
||||
},
|
||||
})
|
||||
|
||||
state = PlaceInfosReducer(state, returnedPlaceInfo)
|
||||
|
||||
expect(state[placeId]).to.equal(returnedPlaceInfo.placeInfos[1])
|
||||
end)
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user