local D=script.Parent.Parent.Parent local w=require(D.JestGlobals)local W=w.expect local c=w.test local a=w.describe local o=w.beforeEach local C=w.afterEach local t=require(script.Parent.Parent.config)local V=t.configure local L=t.getConfig a("\099\111\110\102\105\103\117\114\097\116\105\111\110 \065\080\073",function()local D o(function()V(function(w)D=w return{}end)end)C(function()V(D)end)o(function()V({other=123})end)a("\103\101\116\067\111\110\102\105\103",function()c("\114\101\116\117\114\110\115 \101\120\105\115\116\105\110\103 \099\111\110\102\105\103\117\114\097\116\105\111\110",function()local D=L();(W(D.testIdAttribute)).toEqual("\100\097\116\097-\116\101\115\116\105\100")end)end)a("\099\111\110\102\105\103\117\114\101",function()c("\109\101\114\103\101\115 \097 \100\101\108\116\097 \114\097\116\104\101\114 \116\104\097\110 \114\101\112\108\097\099\105\110\103 \116\104\101 \119\104\111\108\101 \099\111\110\102\105\103",function()local D=L();(W(D)).toMatchObject({testIdAttribute="\100\097\116\097-\116\101\115\116\105\100"})end)c("\111\118\101\114\114\105\100\101\115 \101\120\105\115\116\105\110\103 \118\097\108\117\101\115",function()V({testIdAttribute="\110\101\119-\105\100"})local D=L();(W(D.testIdAttribute)).toEqual("\110\101\119-\105\100")end)c("\112\097\115\115\101\115 \101\120\105\115\116\105\110\103 \099\111\110\102\105\103 \111\117\116 \116\111 \099\111\110\102\105\103 \102\117\110\099\116\105\111\110",function()V(function(D)return{testIdAttribute=("\037\115-\100\101\114\105\118\101\100"):format(tostring(D.testIdAttribute))}end)local D=L();(W(D)).toMatchObject({testIdAttribute="\100\097\116\097-\116\101\115\116\105\100-\100\101\114\105\118\101\100"})end)end)end)return{}
-- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/config.js

local Packages = script.Parent.Parent.Parent

local JestGlobals = require(Packages.JestGlobals)
local expect = JestGlobals.expect
local test = JestGlobals.test
local describe = JestGlobals.describe
local beforeEach = JestGlobals.beforeEach
local afterEach = JestGlobals.afterEach

local configModule = require(script.Parent.Parent.config)
local configure = configModule.configure
local getConfig = configModule.getConfig

describe("configuration API", function()
	local originalConfig
	beforeEach(function()
		-- Grab the existing configuration so we can restore
		-- it at the end of the test
		configure(function(existingConfig)
			originalConfig = existingConfig -- Don't change the existing config
			return {}
		end)
	end)
	afterEach(function()
		configure(originalConfig)
	end)
	beforeEach(function()
		configure({ other = 123 })
	end)
	describe("getConfig", function()
		test("returns existing configuration", function()
			local conf = getConfig()
			expect(conf.testIdAttribute).toEqual("data-testid")
		end)
	end)
	describe("configure", function()
		test("merges a delta rather than replacing the whole config", function()
			local conf = getConfig()
			expect(conf).toMatchObject({ testIdAttribute = "data-testid" })
		end)
		test("overrides existing values", function()
			configure({ testIdAttribute = "new-id" })
			local conf = getConfig()
			expect(conf.testIdAttribute).toEqual("new-id")
		end)
		test("passes existing config out to config function", function()
			-- Create a new config key based on the value of an existing one
			configure(function(existingConfig)
				return {
					testIdAttribute = ("%s-derived"):format(tostring(existingConfig.testIdAttribute)),
				}
			end)
			local conf = getConfig() -- The new value should be there, and existing values should be
			-- untouched
			expect(conf).toMatchObject({ testIdAttribute = "data-testid-derived" })
		end)
	end)
end)

return {}
