add gs
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
return function()
|
||||
local makeActionCreator = require(script.Parent.makeActionCreator)
|
||||
|
||||
describe("the generated action creator", function()
|
||||
it("should throw if given an invalid arguments", function()
|
||||
expect(function()
|
||||
makeActionCreator(100)
|
||||
end).to.throw()
|
||||
expect(function()
|
||||
makeActionCreator("Test", 12)
|
||||
end).to.throw()
|
||||
end)
|
||||
|
||||
it("should generate a callable table with a 'name' field", function()
|
||||
local actionCreator = makeActionCreator("Action")
|
||||
|
||||
expect(type(actionCreator)).to.equal("table")
|
||||
expect(actionCreator.name).to.equal("Action")
|
||||
expect(actionCreator).never.to.throw()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("the action object generated by the action creator", function()
|
||||
it("should expect a matching number of inputs", function()
|
||||
local actionWithFields = makeActionCreator("AddItem", "id", "title")
|
||||
|
||||
expect(function()
|
||||
actionWithFields(10, "Apple", "extra arg")
|
||||
end).to.throw()
|
||||
expect(function()
|
||||
actionWithFields(10)
|
||||
end).to.throw()
|
||||
|
||||
expect(function()
|
||||
actionWithFields(10, "Orange")
|
||||
end).never.to.throw()
|
||||
end)
|
||||
|
||||
it("should correctly count trailing nils", function()
|
||||
local actionWithFields = makeActionCreator("SetProperty", "value", "default")
|
||||
|
||||
expect(function()
|
||||
actionWithFields("1", nil)
|
||||
end).never.to.throw()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user