local M=script.Parent.Parent local P=require(M.Dev.JestGlobals)local V=P.expect return function()local M beforeEach(function()M=_G.Observable end)describe("\099\111\110\099\097\116",function()it("\099\111\110\099\097\116\101\110\097\116\101\115 \116\104\101 \115\117\112\112\108\105\101\100 \079\098\115\101\114\118\097\098\108\101 \097\114\103\117\109\101\110\116\115",function()local P={};(((M.from({1;2;3,4})):concat(M.of(5,6,7))):forEach(function(M)table.insert(P,M)return#P end)):expect();(V(P)).toEqual({1;2;3;4;5;6,7})end)it("\099\097\110 \098\101 \117\115\101\100 \109\117\108\116\105\112\108\101 \116\105\109\101\115 \116\111 \112\114\111\100\117\099\101 \116\104\101 \115\097\109\101 \114\101\115\117\108\116\115",function()local P={}local b={}local K=(M.from({1;2;3,4})):concat(M.of(5,6,7));(K:forEach(function(M)table.insert(P,M)return#P end)):expect();(K:forEach(function(M)table.insert(b,M)return#b end)):expect();(V(P)).toEqual({1;2;3,4;5,6;7});(V(b)).toEqual({1,2;3;4,5;6,7})end)end)end
-- ROBLOX upstream https://github.com/zenparsing/zen-observable/blob/v0.8.15/test/concat.js

local rootWorkspace = script.Parent.Parent

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local jestExpect = JestGlobals.expect

return function()
	-- ROBLOX deviation: upstream a global variable is created in the test setup.
	-- A local variable is created to avoid using _G.Observable in every test
	local Observable
	beforeEach(function()
		Observable = _G.Observable
	end)
	describe("concat", function()
		it("concatenates the supplied Observable arguments", function()
			local list = {}
			Observable.from({ 1, 2, 3, 4 })
				:concat(Observable.of(5, 6, 7))
				:forEach(function(x)
					table.insert(list, x)
					return #list
				end)
				:expect()
			jestExpect(list).toEqual({ 1, 2, 3, 4, 5, 6, 7 })
		end)

		it("can be used multiple times to produce the same results", function()
			local list1 = {}
			local list2 = {}
			local concatenated = Observable.from({ 1, 2, 3, 4 }):concat(Observable.of(5, 6, 7))

			concatenated
				:forEach(function(x)
					table.insert(list1, x)
					return #list1
				end)
				:expect()

			concatenated
				:forEach(function(x)
					table.insert(list2, x)
					return #list2
				end)
				:expect()

			jestExpect(list1).toEqual({ 1, 2, 3, 4, 5, 6, 7 })
			jestExpect(list2).toEqual({ 1, 2, 3, 4, 5, 6, 7 })
		end)
	end)
end
