package tests import "core:testing" import "../src/core" import "../src/ui" @test core_dispose_state_clears_collections :: proc(t: ^testing.T) { state := core.new_initial_state() sheet_urls_dyn: [dynamic]string append(&sheet_urls_dyn, "x") chars_dyn: [dynamic]core.Character append(&chars_dyn, core.Character{name = "A", character_sheet_urls = sheet_urls_dyn[:]}) state.characters = chars_dyn[:] state.panel_images = make(map[string]core.Panel_Image) state.panel_images["p1"] = core.Panel_Image{url = "u"} layout_panels_dyn: [dynamic]core.Page_Layout_Panel append(&layout_panels_dyn, core.Page_Layout_Panel{panel_id = "p1"}) layouts_dyn: [dynamic]core.Page_Layout append(&layouts_dyn, core.Page_Layout{panels = layout_panels_dyn[:]}) state.page_layouts = layouts_dyn[:] state.speech_bubbles = make(map[string][]core.Speech_Bubble) bubbles_dyn: [dynamic]core.Speech_Bubble append(&bubbles_dyn, core.Speech_Bubble{id = "b1"}) state.speech_bubbles["p1"] = bubbles_dyn[:] steps_dyn: [dynamic]core.Workflow_Step append(&steps_dyn, core.Workflow_Step.Story_Input) state.workflow.completed_steps = steps_dyn[:] core.dispose_state(&state) testing.expect(t, len(state.characters) == 0, "characters should be cleared") testing.expect(t, len(state.panel_images) == 0, "panel_images should be cleared") testing.expect(t, len(state.page_layouts) == 0, "page_layouts should be cleared") testing.expect(t, len(state.speech_bubbles) == 0, "speech_bubbles should be cleared") testing.expect(t, len(state.workflow.completed_steps) == 0, "completed_steps should be cleared") } @test ui_dispose_controller_clears_jobs_and_state :: proc(t: ^testing.T) { state := core.new_initial_state() state.panel_images = make(map[string]core.Panel_Image) state.panel_images["p1"] = core.Panel_Image{url = "u"} controller := ui.new_controller(state) _ = ui.submit_job(&controller.jobs, .Generate_Script, "job") ui.dispose_controller(&controller) testing.expect(t, len(controller.jobs.jobs) == 0, "jobs should be cleared") testing.expect(t, len(controller.state.panel_images) == 0, "state maps should be cleared") }