-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import roblox-jest and use new expect in array tests (#35)
- Loading branch information
RoFlection Bot
committed
Feb 25, 2021
1 parent
f8531e9
commit 974f1ea
Showing
23 changed files
with
328 additions
and
259 deletions.
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
"lint": { | ||
"*": "disabled" | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,6 +6,4 @@ content_root = "src" | |
default_alias = "LuauPolyfill" | ||
|
||
[dev_dependencies] | ||
# TODO: Flip over to the jest-roblox repo whenever a release is ready, or if | ||
# there's a particular git branch we'd like to use | ||
TestEZ = "github.com/roblox/[email protected]" | ||
JestRoblox = "github.com/roblox/[email protected]" |
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 |
---|---|---|
@@ -1,59 +1,59 @@ | ||
-- Some tests are adapted from examples at: | ||
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat | ||
return function() | ||
local concat = require(script.Parent.Parent.concat) | ||
local Array = script.Parent.Parent | ||
local LuauPolyfill = Array.Parent | ||
local concat = require(Array.concat) | ||
|
||
local Packages = LuauPolyfill.Parent | ||
local JestRoblox = require(Packages.Dev.JestRoblox) | ||
local jestExpect = JestRoblox.Globals.expect | ||
|
||
it("concatenate arrays with single values", function() | ||
local expect: any = expect | ||
expect(concat({ 1 })).toEqual({ 1 }) | ||
expect(concat({ 1 }, { 2 })).toEqual({ 1, 2 }) | ||
expect(concat({ 1 }, { 2 }, { 3 })).toEqual({ 1, 2, 3 }) | ||
jestExpect(concat({ 1 })).toEqual({ 1 }) | ||
jestExpect(concat({ 1 }, { 2 })).toEqual({ 1, 2 }) | ||
jestExpect(concat({ 1 }, { 2 }, { 3 })).toEqual({ 1, 2, 3 }) | ||
end) | ||
|
||
it("concatenate arrays with multiple values", function() | ||
local expect: any = expect | ||
expect(concat({ 1 }, { 2, 3 })).toEqual({ 1, 2, 3 }) | ||
expect(concat({ 1, 2 }, { 3 })).toEqual({ 1, 2, 3 }) | ||
expect(concat({ 1, 2 }, { 3, 4 })).toEqual({ 1, 2, 3, 4 }) | ||
expect(concat({ 1, 2 }, { 3, 4 }, { 5, 6 })).toEqual({ 1, 2, 3, 4, 5, 6 }) | ||
jestExpect(concat({ 1 }, { 2, 3 })).toEqual({ 1, 2, 3 }) | ||
jestExpect(concat({ 1, 2 }, { 3 })).toEqual({ 1, 2, 3 }) | ||
jestExpect(concat({ 1, 2 }, { 3, 4 })).toEqual({ 1, 2, 3, 4 }) | ||
jestExpect(concat({ 1, 2 }, { 3, 4 }, { 5, 6 })).toEqual({ 1, 2, 3, 4, 5, 6 }) | ||
end) | ||
|
||
it("concatenate values", function() | ||
local expect: any = expect | ||
expect(concat(1)).toEqual({ 1 }) | ||
expect(concat(1, 2)).toEqual({ 1, 2 }) | ||
expect(concat(1, 2, 3)).toEqual({ 1, 2, 3 }) | ||
expect(concat(1, 2, 3, 4)).toEqual({ 1, 2, 3, 4 }) | ||
jestExpect(concat(1)).toEqual({ 1 }) | ||
jestExpect(concat(1, 2)).toEqual({ 1, 2 }) | ||
jestExpect(concat(1, 2, 3)).toEqual({ 1, 2, 3 }) | ||
jestExpect(concat(1, 2, 3, 4)).toEqual({ 1, 2, 3, 4 }) | ||
end) | ||
|
||
it("concatenate values and arrays combination", function() | ||
local expect: any = expect | ||
expect(concat(1, { 2 })).toEqual({ 1, 2 }) | ||
expect(concat({ 1 }, 2)).toEqual({ 1, 2 }) | ||
expect(concat({ 1 }, 2, { 3 })).toEqual({ 1, 2, 3 }) | ||
expect(concat({ 1, 2 }, 3, { 4 })).toEqual({ 1, 2, 3, 4 }) | ||
jestExpect(concat(1, { 2 })).toEqual({ 1, 2 }) | ||
jestExpect(concat({ 1 }, 2)).toEqual({ 1, 2 }) | ||
jestExpect(concat({ 1 }, 2, { 3 })).toEqual({ 1, 2, 3 }) | ||
jestExpect(concat({ 1, 2 }, 3, { 4 })).toEqual({ 1, 2, 3, 4 }) | ||
end) | ||
|
||
it("concatenates values to an array", function() | ||
local expect: any = expect | ||
local letters = { "a", "b", "c" } | ||
local alphaNumeric = concat(letters, 1, { 2, 3 }) | ||
expect(alphaNumeric).toEqual({ "a", "b", "c", 1, 2, 3 }) | ||
jestExpect(alphaNumeric).toEqual({ "a", "b", "c", 1, 2, 3 }) | ||
end) | ||
|
||
it("concatenates nested arrays", function() | ||
local expect: any = expect | ||
local num1 = { { 1 } } | ||
local num2 = { 2, { 3 } } | ||
local numbers = concat(num1, num2) | ||
expect(numbers).toEqual({ { 1 }, 2, { 3 } }) | ||
jestExpect(numbers).toEqual({ { 1 }, 2, { 3 } }) | ||
end) | ||
|
||
if _G.__DEV__ then | ||
it("throws when an object-like table value is passed", function() | ||
expect(function() | ||
jestExpect(function() | ||
concat({1, 2}, { a = true }) | ||
end).to.throw("Array.concat(...) only works with array-like tables but it received an object-like table") | ||
end).toThrow("Array.concat(...) only works with array-like tables but it received an object-like table") | ||
end) | ||
end | ||
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
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
Oops, something went wrong.