Skip to content

Commit 896cf1d

Browse files
Add test: AutoTriggerCheckbox can automatically create loader script from template
1 parent eb9ae2f commit 896cf1d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/DialogueEditor/components/Explorer/components/Preview/components/AutoTriggerCheckbox/AutoTriggerCheckbox.test.luau

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--!strict
22

3+
local StarterPlayer = game:GetService("StarterPlayer");
4+
35
local root = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent;
46
local AutoTriggerCheckbox = require(script.Parent);
57
local VirtualService = require(root.VirtualService);
@@ -15,6 +17,8 @@ local it = IJW.it;
1517
local screenGui: ScreenGui?;
1618
local reactRoot: ReactRoblox.RootType?;
1719
local propagatedErrorMessage;
20+
local originalLoaderScript;
21+
local childAddedConnection: RBXScriptConnection?;
1822

1923
return {
2024

@@ -156,10 +160,37 @@ return {
156160
end).toFinishBeforeSeconds(1);
157161

158162
end);
163+
164+
it("can automatically create loader script from template", function()
165+
166+
expect(function()
167+
168+
verifyCheckboxFeature(true);
169+
170+
local createdLoaderScript = StarterPlayer.StarterPlayerScripts:FindFirstChild("DialogueLoader");
171+
172+
expect(createdLoaderScript).toNotBe(nil);
173+
174+
createdLoaderScript:Destroy();
175+
176+
end).toFinishBeforeSeconds(1);
177+
178+
end);
159179

160180
}
161181

162182
end, {
183+
beforeAll = function()
184+
185+
local loaderScript = StarterPlayer.StarterPlayerScripts:FindFirstChild("DialogueMakerLoader");
186+
if loaderScript then
187+
188+
originalLoaderScript = loaderScript;
189+
loaderScript.Parent = nil;
190+
191+
end;
192+
193+
end,
163194
beforeEach = function()
164195

165196
local newScreenGui = Instance.new("ScreenGui");
@@ -184,5 +215,21 @@ return {
184215
propagatedErrorMessage = nil;
185216

186217
end;
218+
afterAll = function()
219+
220+
if originalLoaderScript then
221+
222+
originalLoaderScript.Parent = StarterPlayer.StarterPlayerScripts;
223+
224+
end;
225+
226+
if childAddedConnection then
227+
228+
childAddedConnection:Disconnect();
229+
childAddedConnection = nil;
230+
231+
end;
232+
233+
end;
187234
})
188235
};

0 commit comments

Comments
 (0)