diff --git a/packages/doenetml-worker/src/test/tagSpecific/map.test.ts b/packages/doenetml-worker/src/test/tagSpecific/map.test.ts index ceb78bf61..833030f3f 100644 --- a/packages/doenetml-worker/src/test/tagSpecific/map.test.ts +++ b/packages/doenetml-worker/src/test/tagSpecific/map.test.ts @@ -1856,4 +1856,59 @@ describe("Map tag tests", async () => { expect(stateVariables["/p1"].stateValues.isResponse).eq(true); expect(stateVariables["/p2"].stateValues.isResponse).eq(true); }); + + it("map iterates over lists", async () => { + let core = await createTestCore({ + doenetML: ` + x y + dog cat + 1 2 + true false + + + + $ml + + + + $nl + + + + $tl + + + + $bl + + `, + }); + + const stateVariables = await returnAllStateVariables(core); + + expect(stateVariables["/m1"].stateValues.value.tree).eqls([ + "*", + 2, + "x", + ]); + expect(stateVariables["/m2"].stateValues.value.tree).eqls([ + "*", + 2, + "y", + ]); + expect(stateVariables["/n1"].stateValues.value).eq(2); + expect(stateVariables["/n2"].stateValues.value).eq(4); + expect(stateVariables["/t1"].stateValues.value).eq("Hello dog!"); + expect(stateVariables["/t2"].stateValues.value).eq("Hello cat!"); + expect(stateVariables["/b1"].stateValues.value).eq(false); + expect(stateVariables["/b2"].stateValues.value).eq(true); + }); });