\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d3')).toHaveText('42')\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "def",
"name": "can install a function on an element and use in children w/ return value",
"html": "
",
"body": "\n\t\tawait html(\n\t\t\t\"
\" +\n\t\t\t\"
\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText('42')\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "def",
"name": "can install a function on an element and use me symbol correctly",
"html": "
\");\n\t\tawait expect(find('div')).toHaveText(\"content\");\n\t\tawait find('div').dispatchEvent('click');\n\t\tawait expect(find('div')).toHaveText(\"\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can create an array literal",
"html": "",
"body": "\n\t\tconst result = await run(\"[1, 2, 3]\")\n\t\texpect(result).toEqual([1, 2, 3])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of first values in an array",
"html": "",
"body": "\n\t\tawait html(``)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"0,1,2,3\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of last values in an array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t``\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"3,4,5\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of last values in an array WITHOUT EXTRA SPACES",
"html": "",
"body": "\n\t\tawait html(``)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"3,4,5\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of middle values in an array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t``\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"2,3\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of middle values in an array WITHOUT EXTRA SPACES",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t``\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"2,3\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can get the range of middle values in an array using an expression",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t``\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"2,3,4\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can index an array value",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"10\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can index an array value at the beginning of the array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"10\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can index an array value at the end of the array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"30\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can index an array value in the middle of the array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"20\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "can index an array value with an expression",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t''\n\t\t)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"C\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "errors when index exceeds array length",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\t// Original test just catches error and logs it; verify no crash\n\t\tawait find('#d1').dispatchEvent('click')\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayIndex",
"name": "errors when indexed value is not an array",
"html": "",
"body": "\n\t\tawait html(\n\t\t\t\"\"\n\t\t)\n\t\t// Original test just catches error and logs it; verify no crash\n\t\tawait find('#d1').dispatchEvent('click')\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/arrayLiteral",
"name": "arrays can contain expressions",
"html": "",
"body": "\n\t\texpect(await run(\"[1 + 1, 2 * 3, 10 - 5]\")).toEqual([2, 6, 5])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "arrays containing objects work",
"html": "",
"body": "\n\t\texpect(await run(\"[{a: 1}, {b: 2}]\")).toEqual([{a: 1}, {b: 2}])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "deeply nested array literals work",
"html": "",
"body": "\n\t\texpect(await run(\"[[[1]], [[2, 3]]]\")).toEqual([[[1]], [[2, 3]]])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "empty array literals work",
"html": "",
"body": "\n\t\tconst result = await run(\"[]\")\n\t\texpect(result).toEqual([])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "mixed-type array literal works",
"html": "",
"body": "\n\t\texpect(await run(\"[1, 'two', true, null]\")).toEqual([1, 'two', true, null])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "multi element array literal works",
"html": "",
"body": "\n\t\tconst result = await run(\"[true, false]\")\n\t\texpect(result).toEqual([true, false])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "nested array literals work",
"html": "",
"body": "\n\t\texpect(await run(\"[[1, 2], [3, 4]]\")).toEqual([[1, 2], [3, 4]])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/arrayLiteral",
"name": "one element array literal works",
"html": "",
"body": "\n\t\tconst result = await run(\"[true]\")\n\t\texpect(result).toEqual([true])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "can accept custom conversions",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\t_hyperscript.config.conversions[\"Foo\"] = function (val) {\n\t\t\t\treturn \"foo\" + val\n\t\t\t}\n\t\t\tconst r = _hyperscript(\"1 as Foo\")\n\t\t\tdelete _hyperscript.config.conversions.Foo\n\t\t\treturn r\n\t\t})\n\t\texpect(result).toBe(\"foo1\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "can accept custom dynamic conversions",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst myConversion = function (conversion, val) {\n\t\t\t\tif (conversion.indexOf(\"Foo:\") === 0) {\n\t\t\t\t\tconst arg = conversion.split(\":\")[1]\n\t\t\t\t\treturn arg + val\n\t\t\t\t}\n\t\t\t}\n\t\t\t_hyperscript.config.conversions.dynamicResolvers.push(myConversion)\n\t\t\tconst r = _hyperscript(\"1 as Foo:Bar\")\n\t\t\t_hyperscript.config.conversions.dynamicResolvers.pop()\n\t\t\treturn r\n\t\t})\n\t\texpect(result).toBe(\"Bar1\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "can use the a modifier if you like",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst r = _hyperscript(\"1 as a Date\")\n\t\t\treturn r.getTime()\n\t\t})\n\t\texpect(result).toBe(new Date(1).getTime())\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "can use the an modifier if you'd like",
"html": "",
"body": "\n\t\tconst result = await run('\\'{\"foo\":\"bar\"}\\' as an Object')\n\t\texpect(result[\"foo\"]).toBe(\"bar\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "collects duplicate text inputs into an array",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.tag).toEqual([\"alpha\", \"beta\", \"gamma\"])\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a NodeList into HTML",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst fragment = document.createDocumentFragment()\n\t\t\tlet d = document.createElement(\"div\")\n\t\t\td.id = \"first\"\n\t\t\td.innerText = \"With Text\"\n\t\t\tfragment.appendChild(d)\n\t\t\td = document.createElement(\"span\")\n\t\t\td.id = \"second\"\n\t\t\tfragment.appendChild(d)\n\t\t\td = document.createElement(\"i\")\n\t\t\td.id = \"third\"\n\t\t\tfragment.appendChild(d)\n\t\t\treturn _hyperscript(\"nodeList as HTML\", { locals: { nodeList: fragment.childNodes } })\n\t\t})\n\t\texpect(result).toBe(`
With Text
`)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a complete form into Values",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t
\n\t\t\t\t\tCatches elements nested deeply within the DOM tree\n\t\t\t\t\t \n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\tWorks with Textareas\n\t\t\t\t\n\t\t\t\tWorks with Single Select Boxes\n\t\t\t\t\n\t\t\t\tWorks with Multi-Select Boxes\n\t\t\t\t\n\t\t\t\tWorks with Radio Buttons\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tWorks with Checkboxes\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.firstName).toBe(\"John\")\n\t\texpect(result.lastName).toBe(\"Connor\")\n\t\texpect(result.phone).toBe(\"555-1212\")\n\t\texpect(result.aboutMe).toBe(\"It began on a warm summer day in 1969...\")\n\t\texpect(result.animal).toBe(\"dog\")\n\t\texpect(result.spiritAnimal[0]).toBe(\"dog\")\n\t\texpect(result.spiritAnimal[1]).toBe(\"raccoon\")\n\t\texpect(result.coolOrNaw).toBe(\"Cool\")\n\t\texpect(result.gender[0]).toBe(\"Male\")\n\t\texpect(result.gender[1]).toBe(\"Female\")\n\t\texpect(result.gender[2]).toBe(\"Other\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a form element into Values",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t \n\t\t\t\t \n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.firstName).toBe(\"John\")\n\t\texpect(result.lastName).toBe(\"Connor\")\n\t\texpect(result.areaCode).toBe(\"213\")\n\t\texpect(result.phone).toBe(\"555-1212\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a form element into Values | FormEncoded",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t \n\t\t\t\t \n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
`\n\t\t\treturn _hyperscript(\"x as Values | FormEncoded\", { locals: { x: node } })\n\t\t})\n\t\texpect(result).toBe('firstName=John&lastName=Connor&areaCode=213&phone=555-1212')\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a form element into Values | JSONString",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t \n\t\t\t\t \n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
`\n\t\t\treturn _hyperscript(\"x as Values | JSONString\", { locals: { x: node } })\n\t\t})\n\t\texpect(result).toBe('{\"firstName\":\"John\",\"lastName\":\"Connor\",\"areaCode\":\"213\",\"phone\":\"555-1212\"}')\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts a query selector into Values",
"html": " as Values into my.customData\">\n\t\t\t \n\t\t\t \n\t\t\t\n\t\t\t\n\t\t
",
"body": "\n\t\tawait html(` as Values into my.customData\">\n\t\t\t \n\t\t\t \n\t\t\t\n\t\t\t\n\t\t
`)\n\t\tawait find('#qsdiv').dispatchEvent('click')\n\t\tconst data = await evaluate(() => {\n\t\t\tconst div = document.getElementById('qsdiv')\n\t\t\treturn {\n\t\t\t\tfirstName: div.customData?.firstName,\n\t\t\t\tlastName: div.customData?.lastName,\n\t\t\t\tareaCode: div.customData?.areaCode,\n\t\t\t\tphone: div.customData?.phone,\n\t\t\t}\n\t\t})\n\t\texpect(data.firstName).toBe(\"John\")\n\t\texpect(data.lastName).toBe(\"Connor\")\n\t\texpect(data.areaCode).toBe(\"213\")\n\t\texpect(data.phone).toBeUndefined()\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/asExpression",
"name": "converts an array into HTML",
"html": "",
"body": "\n\t\tconst result = await run(\"d as HTML\", { locals: { d: [\"this-\", \"is-\", \"html\"] } })\n\t\texpect(result).toBe(`this-is-html`)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts an element into HTML",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst d1 = document.createElement(\"div\")\n\t\t\td1.id = \"myDiv\"\n\t\t\td1.innerText = \"With Text\"\n\t\t\treturn _hyperscript(\"d as HTML\", { locals: { d: d1 } })\n\t\t})\n\t\texpect(result).toBe(`
With Text
`)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts an input element into Values",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"input\")\n\t\t\tnode.name = \"test-name\"\n\t\t\tnode.value = \"test-value\"\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result[\"test-name\"]).toBe(\"test-value\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts array as Reversed",
"html": "",
"body": "\n\t\tconst result = await run(\"[1,2,3] as Reversed\", {})\n\t\texpect(result).toEqual([3, 2, 1])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts array as Set",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst r = _hyperscript(\"[1,2,2,3] as Set\")\n\t\t\treturn { isSet: r instanceof Set, size: r.size }\n\t\t})\n\t\texpect(result.isSet).toBe(true)\n\t\texpect(result.size).toBe(3)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts array as Unique",
"html": "",
"body": "\n\t\tconst result = await run(\"[1,2,2,3,3] as Unique\", {})\n\t\texpect(result).toEqual([1, 2, 3])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts arrays into fragments",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = [document.createElement(\"p\"), \"\"]\n\t\t\tconst r = _hyperscript(\"value as Fragment\", { locals: { value } })\n\t\t\treturn {\n\t\t\t\tchildElementCount: r.childElementCount,\n\t\t\t\tfirstChildTag: r.firstChild.tagName,\n\t\t\t\tlastChildTag: r.lastChild.tagName,\n\t\t\t}\n\t\t})\n\t\texpect(result.childElementCount).toBe(2)\n\t\texpect(result.firstChildTag).toBe(\"P\")\n\t\texpect(result.lastChildTag).toBe(\"P\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts checkboxes into a Value correctly",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.gender[0]).toBe(\"Male\")\n\t\texpect(result.gender[1]).toBe(\"Female\")\n\t\texpect(result.gender[2]).toBe(\"Other\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts elements into fragments",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = document.createElement(\"p\")\n\t\t\tconst r = _hyperscript(\"value as Fragment\", { locals: { value } })\n\t\t\treturn { childElementCount: r.childElementCount, firstChildTag: r.firstChild.tagName }\n\t\t})\n\t\texpect(result.childElementCount).toBe(1)\n\t\texpect(result.firstChildTag).toBe(\"P\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts multiple selects into a Value correctly",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.animal[0]).toBe(\"dog\")\n\t\texpect(result.animal[1]).toBe(\"raccoon\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts multiple selects with programmatically changed selections",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t`\n\t\t\tvar select = node.querySelector(\"select\")\n\t\t\tselect.options[0].selected = false // deselect dog\n\t\t\tselect.options[1].selected = true // select cat\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.animal[0]).toBe(\"cat\")\n\t\texpect(result.animal[1]).toBe(\"raccoon\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts nested array as Flat",
"html": "",
"body": "\n\t\tconst result = await run(\"[[1,2],[3,4]] as Flat\", {})\n\t\texpect(result).toEqual([1, 2, 3, 4])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts null as null",
"html": "",
"body": "\n\t\tconst result = await run(\"null as String\")\n\t\texpect(result).toBeNull()\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts numbers things 'HTML'",
"html": "",
"body": "\n\t\tconst result = await run(\"value as HTML\", { locals: { value: 123 } })\n\t\texpect(result).toBe(\"123\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts object as Entries",
"html": "",
"body": "\n\t\tconst result = await run(\"{a:1} as Entries\", {})\n\t\texpect(result).toEqual([[\"a\", 1]])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts object as Keys",
"html": "",
"body": "\n\t\tconst result = await run(\"{a:1, b:2} as Keys\", {})\n\t\texpect(result).toEqual([\"a\", \"b\"])\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts object as Map",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst r = _hyperscript(\"{a:1, b:2} as Map\")\n\t\t\treturn { isMap: r instanceof Map, a: r.get(\"a\"), size: r.size }\n\t\t})\n\t\texpect(result.isMap).toBe(true)\n\t\texpect(result.a).toBe(1)\n\t\texpect(result.size).toBe(2)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts radio buttons into a Value correctly",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst node = document.createElement(\"form\")\n\t\t\tnode.innerHTML = `\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
`\n\t\t\treturn _hyperscript(\"x as Values\", { locals: { x: node } })\n\t\t})\n\t\texpect(result.gender).toBe(\"Male\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts string as Object",
"html": "",
"body": "\n\t\tconst result = await run('\\'{\"foo\":\"bar\"}\\' as Object')\n\t\texpect(result[\"foo\"]).toBe(\"bar\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts strings into fragments",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst r = _hyperscript(\"value as Fragment\", { locals: { value: \"\" } })\n\t\t\treturn { childElementCount: r.childElementCount, firstChildTag: r.firstChild.tagName }\n\t\t})\n\t\texpect(result.childElementCount).toBe(1)\n\t\texpect(result.firstChildTag).toBe(\"P\")\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts value as Boolean",
"html": "",
"body": "\n\t\texpect(await run(\"1 as Boolean\")).toBe(true)\n\t\texpect(await run(\"0 as Boolean\")).toBe(false)\n\t\texpect(await run(\"'' as Boolean\")).toBe(false)\n\t\texpect(await run(\"'hello' as Boolean\")).toBe(true)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as Date",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst r = _hyperscript(\"1 as Date\")\n\t\t\treturn r.getTime()\n\t\t})\n\t\texpect(result).toBe(new Date(1).getTime())\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/asExpression",
"name": "converts value as Fixed",
"html": "",
"body": "\n\t\tlet result = await run(\"'10.4' as Fixed\")\n\t\texpect(result).toBe('10')\n\t\tresult = await run(\"'10.4899' as Fixed:2\")\n\t\texpect(result).toBe('10.49')\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as Float",
"html": "",
"body": "\n\t\tlet result = await run(\"'10' as Float\")\n\t\texpect(result).toBe(10)\n\t\tresult = await run(\"'10.4' as Float\")\n\t\texpect(result).toBe(10.4)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as Int",
"html": "",
"body": "\n\t\tlet result = await run(\"'10' as Int\")\n\t\texpect(result).toBe(10)\n\t\tresult = await run(\"'10.4' as Int\")\n\t\texpect(result).toBe(10)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as JSONString",
"html": "",
"body": "\n\t\tconst result = await run(\"{foo:'bar'} as JSONString\")\n\t\texpect(result).toBe('{\"foo\":\"bar\"}')\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as Number",
"html": "",
"body": "\n\t\tlet result = await run(\"'10' as Number\")\n\t\texpect(result).toBe(10)\n\t\tresult = await run(\"'10.4' as Number\")\n\t\texpect(result).toBe(10.4)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as Object",
"html": "",
"body": "\n\t\tconst result = await run(\"x as Object\", { locals: { x: { foo: \"bar\" } } })\n\t\texpect(result[\"foo\"]).toBe(\"bar\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "converts value as String",
"html": "",
"body": "\n\t\tlet result = await run(\"10 as String\")\n\t\texpect(result).toBe(\"10\")\n\t\tresult = await run(\"true as String\")\n\t\texpect(result).toBe(\"true\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "parses string as JSON to object",
"html": "",
"body": "\n\t\tconst result = await run('\\'{\"foo\":\"bar\"}\\' as JSON')\n\t\texpect(result[\"foo\"]).toBe(\"bar\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/asExpression",
"name": "pipe operator chains conversions",
"html": "",
"body": "\n\t\tconst result = await run(\"{foo:'bar'} as JSONString | JSON\")\n\t\texpect(result[\"foo\"]).toBe(\"bar\")\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/assignableElements",
"name": "hyperscript in replacement content is initialized",
"html": "
old
",
"body": "\n\t\tawait html(\n\t\t\t\"
old
\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('#go').dispatchEvent('click');\n\t\tawait expect(find('#target')).toHaveText(\"new\");\n\t\tawait find('#target').dispatchEvent('click');\n\t\tawait expect(find('#target')).toHaveText(\"clicked\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/assignableElements",
"name": "put into still works as innerHTML",
"html": "
old
",
"body": "\n\t\tawait html(\n\t\t\t\"
old
\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('button').dispatchEvent('click');\n\t\tawait expect(find('#target')).toHaveText(\"new\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/assignableElements",
"name": "set #id replaces element with HTML string",
"html": "
old
",
"body": "\n\t\tawait html(\n\t\t\t\"
old
\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('button').dispatchEvent('click');\n\t\tawait expect(find('#target')).toHaveText(\"new\");\n\t\tvar tag = await evaluate(() => document.querySelector('#target').tagName);\n\t\texpect(tag).toBe(\"SPAN\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/assignableElements",
"name": "set #id replaces element with another element",
"html": "
\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('button').dispatchEvent('click');\n\t\tvar order = await evaluate(() =>\n\t\t\tArray.from(document.querySelector('#container').children).map(e => e.textContent.trim())\n\t\t);\n\t\texpect(order).toEqual([\"B\", \"A\"]);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be put as symbol",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be put as symbol w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be put indirectly",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"put 'blue' into x[@data-foo]\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be put indirectly w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"put 'blue' into x@data-foo\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set as prop",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"set x[@data-foo] to 'blue'\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set as prop w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"set x@data-foo to 'blue'\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set as symbol",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set as symbol w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set indirectly",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"set [@data-foo] of x to 'blue'\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set indirectly w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait evaluate(() => {\n\t\t\tconst div = document.getElementById('arDiv')\n\t\t\t_hyperscript(\"set @data-foo of x to 'blue'\", { locals: { x: div } })\n\t\t})\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set through possessive",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can be set through possessive w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value in quotes used in add commands",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value in quotes used in add commands w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value in quotes with spaces used in add commands",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue green\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value in quotes with spaces used in add commands w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue green\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value used in add commands",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef can have value used in add commands w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#arDiv').dispatchEvent('click')\n\t\tconst value = await evaluate(() => document.getElementById('arDiv').getAttribute(\"data-foo\"))\n\t\texpect(value).toBe(\"blue\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef with dashes name works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst value = await evaluate(() => _hyperscript(\"[@data-foo]\", { me: document.getElementById('arDiv') }))\n\t\texpect(value).toBe(\"c1\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef with dashes name works w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst value = await evaluate(() => _hyperscript(\"@data-foo\", { me: document.getElementById('arDiv') }))\n\t\texpect(value).toBe(\"c1\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef with no value works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst value = await evaluate(() => _hyperscript(\"[@foo]\", { me: document.getElementById('arDiv') }))\n\t\texpect(value).toBe(\"c1\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/attributeRef",
"name": "attributeRef with no value works w/ short syntax",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst value = await evaluate(() => _hyperscript(\"@foo\", { me: document.getElementById('arDiv') }))\n\t\texpect(value).toBe(\"c1\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/beep!",
"name": "beeps a basic value",
"html": "",
"body": "\n\t\tconst logs = []\n\t\tpage.on('console', async msg => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(await Promise.all(msg.args().map(a => a.jsonValue())))\n\t\t\t}\n\t\t})\n\t\tawait html(\"\")\n\t\tawait page.locator('#work-area div').dispatchEvent('click')\n\t\tawait expect.poll(() => logs.length).toBeGreaterThan(0)\n\t\texpect(logs[0]).toEqual(['///_ BEEP! The expression (10) evaluates to:', 10, 'of type Number'])\n\t",
"async": true,
"complexity": "promise"
},
{
"category": "expressions/beep!",
"name": "beeps a formatted string value",
"html": "",
"body": "\n\t\tconst logs = []\n\t\tpage.on('console', async msg => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(await Promise.all(msg.args().map(a => a.jsonValue())))\n\t\t\t}\n\t\t})\n\t\tawait html(\"\")\n\t\tawait page.locator('#work-area div').dispatchEvent('click')\n\t\tawait expect.poll(() => logs.length).toBeGreaterThan(0)\n\t\texpect(logs[0]).toEqual(['///_ BEEP! The expression (\"foo\") evaluates to:', '\"foo\"', 'of type String'])\n\t",
"async": true,
"complexity": "promise"
},
{
"category": "expressions/beep!",
"name": "beeps a null value",
"html": "",
"body": "\n\t\tconst logs = []\n\t\tpage.on('console', async msg => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(await Promise.all(msg.args().map(a => a.jsonValue())))\n\t\t\t}\n\t\t})\n\t\tawait html(\"\")\n\t\tawait page.locator('#work-area div').dispatchEvent('click')\n\t\tawait expect.poll(() => logs.length).toBeGreaterThan(0)\n\t\texpect(logs[0]).toEqual(['///_ BEEP! The expression (null) evaluates to:', null, 'of type object (null)'])\n\t",
"async": true,
"complexity": "promise"
},
{
"category": "expressions/beep!",
"name": "beeps the result of an ElementCollection",
"html": "",
"body": "\n\t\tconst logs = []\n\t\tpage.on('console', async msg => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(await Promise.all(msg.args().map(a => a.jsonValue().catch(() => '[Element]'))))\n\t\t\t}\n\t\t})\n\t\tawait html(\"\")\n\t\tawait page.locator('#work-area div.foo').dispatchEvent('click')\n\t\tawait expect.poll(() => logs.length).toBeGreaterThan(0)\n\t\t// The first two entries are the message and an element (which serializes as an object)\n\t\texpect(logs[0][0]).toBe('///_ BEEP! The expression (.foo) evaluates to:')\n\t\texpect(logs[0][2]).toBe('of type ElementCollection')\n\t",
"async": true,
"complexity": "promise"
},
{
"category": "expressions/beep!",
"name": "can be cancelled",
"html": "",
"body": "\n\t\tconst logs = []\n\t\tpage.on('console', async msg => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tconst text = msg.text()\n\t\t\t\tif (text.includes('BEEP')) {\n\t\t\t\t\tlogs.push(text)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tawait html(\"\")\n\t\tawait page.locator('#work-area div').dispatchEvent('click')\n\t\t// Wait a bit to ensure no beep logs appear\n\t\tawait page.waitForTimeout(100)\n\t\texpect(logs.length).toBe(0)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/beep!",
"name": "can capture information from event",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#beepDiv').dispatchEvent('click')\n\t\tawait expect.poll(() => evaluate(() => document.getElementById('beepDiv').getAttribute(\"data-value\"))).toBe(\"foo\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/blockLiteral",
"name": "basic block literals work",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst fn = _hyperscript(\"\\\\-> true\")\n\t\t\treturn fn()\n\t\t})\n\t\texpect(result).toBe(true)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/blockLiteral",
"name": "basic identity works",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst fn = _hyperscript(\"\\\\ x -> x\")\n\t\t\treturn fn(true)\n\t\t})\n\t\texpect(result).toBe(true)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/blockLiteral",
"name": "basic two arg identity works",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst fn = _hyperscript(\"\\\\ x, y -> y\")\n\t\t\treturn fn(false, true)\n\t\t})\n\t\texpect(result).toBe(true)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/blockLiteral",
"name": "can map an array",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\treturn _hyperscript(\"['a', 'ab', 'abc'].map(\\\\ s -> s.length )\")\n\t\t})\n\t\texpect(result).toEqual([1, 2, 3])\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/boolean",
"name": "false boolean literals work",
"html": "",
"body": "\n\t\tconst result = await run(\"false\")\n\t\texpect(result).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/boolean",
"name": "true boolean literals work",
"html": "",
"body": "\n\t\tconst result = await run(\"true\")\n\t\texpect(result).toBe(true)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/classRef",
"name": "basic classRef works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".c1\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "basic classRef works w no match",
"html": "",
"body": "\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".badClassThatDoesNotHaveAnyElements\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(0)\n\t",
"async": true,
"complexity": "eval-only"
},
{
"category": "expressions/classRef",
"name": "colon class ref works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".c1:foo\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "dashed class ref works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".c1-foo\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "leading minus class ref works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".-c1\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "multiple colon class ref works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".c1:foo:bar\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "slashes in class references work",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".-c1\\\\/22\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "tailwind insanity in class references work",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".group-\\\\[:nth-of-type\\\\(3\\\\)_\\\\&\\\\]:block\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/classRef",
"name": "template classRef works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tconst result = await evaluate(() => {\n\t\t\tconst value = _hyperscript(\".{'c1'}\")\n\t\t\treturn Array.from(value).length\n\t\t})\n\t\texpect(result).toBe(1)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/closest",
"name": "attributes can be looked up and referred to in same expression",
"html": "
",
"body": "\n\t\tawait html(\"
\")\n\t\tawait expect(find('#d1')).toHaveText(\"\")\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect(find('#d1')).toHaveText(\"bar\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/closest",
"name": "attributes can be set via the closest expression",
"html": "
",
"body": "\n\t\tawait html(\"
\")\n\t\tlet value = await evaluate(() => document.getElementById('outerDiv').getAttribute(\"foo\"))\n\t\texpect(value).toBe(\"bar\")\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect.poll(() => evaluate(() => document.getElementById('outerDiv').getAttribute(\"foo\"))).toBe(\"doh\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/closest",
"name": "attributes can be set via the closest expression 2",
"html": "
where it is not me on click put :others.length into #out\">
",
"body": "\n\t\tawait html(\n\t\t\t\"
\" +\n\t\t\t\"\" +\n\t\t\t\"\" +\n\t\t\t\" in the closest
where it is not me \" +\n\t\t\t\"on click put :others.length into #out\\\">\" +\n\t\t\t\"
\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('#master').click();\n\t\tawait expect(find('#out')).toHaveText(\"2\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/closest",
"name": "closest with to modifier still works after parse change",
"html": "
\")\n\t\tlet value = await evaluate(() => document.getElementById('outerDiv').getAttribute(\"foo\"))\n\t\texpect(value).toBe(\"bar\")\n\t\tawait find('#div2').dispatchEvent('click')\n\t\tawait expect.poll(() => evaluate(() => document.getElementById('outerDiv').getAttribute(\"foo\"))).toBe(\"doh\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/closest",
"name": "returns an array where appropriate",
"html": "
",
"body": "\n\t\tawait html(\n\t\t\t\"
\" +\n\t\t\t\"
\"\n\t\t)\n\t\tlet hasDoh = await evaluate(() => document.getElementById('d2').classList.contains(\"doh\"))\n\t\texpect(hasDoh).toBe(false)\n\t\thasDoh = await evaluate(() => document.getElementById('d3').classList.contains(\"doh\"))\n\t\texpect(hasDoh).toBe(false)\n\t\tawait find('#d1').dispatchEvent('click')\n\t\tawait expect.poll(() => evaluate(() => document.getElementById('d2').classList.contains(\"doh\"))).toBe(true)\n\t\tawait expect.poll(() => evaluate(() => document.getElementById('d3').classList.contains(\"doh\"))).toBe(true)\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "filters an array by condition",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"a\", active: true}, {name: \"b\", active: false}, {name: \"c\", active: true}]\n\t\t\tthen return arr where its active`);\n\t\texpect(result.map(x => x.name)).toEqual([\"a\", \"c\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "filters with comparison",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [1, 2, 3, 4, 5]\n\t\t\tthen return arr where it > 3`);\n\t\texpect(result).toEqual([4, 5]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "full select-all pattern with multiple on features",
"html": "\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
in the closest
where it is not me\n\t\t\t\t on change\n\t\t\t\t set checked of the :checkboxes to my checked\n\t\t\t\t on change from the closest
\n\t\t\t\t if no :checkboxes where it is checked\n\t\t\t\t set my indeterminate to false\n\t\t\t\t set my checked to false\n\t\t\t\t else if no :checkboxes where it is not checked\n\t\t\t\t set my indeterminate to false\n\t\t\t\t set my checked to true\n\t\t\t\t else\n\t\t\t\t set my indeterminate to true\n\t\t\t\t end\">
\n\t\t\t
\n\t\t",
"body": "\n\t\tawait html(`\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
in the closest
where it is not me\n\t\t\t\t on change\n\t\t\t\t set checked of the :checkboxes to my checked\n\t\t\t\t on change from the closest
\n\t\t\t\t if no :checkboxes where it is checked\n\t\t\t\t set my indeterminate to false\n\t\t\t\t set my checked to false\n\t\t\t\t else if no :checkboxes where it is not checked\n\t\t\t\t set my indeterminate to false\n\t\t\t\t set my checked to true\n\t\t\t\t else\n\t\t\t\t set my indeterminate to true\n\t\t\t\t end\">
\n\t\t\t
\n\t\t`);\n\t\t// master check should check all\n\t\tawait find('#master').click();\n\t\tawait expect.poll(() => find('.cb').first().isChecked()).toBe(true);\n\t\t// uncheck one child - master should become indeterminate\n\t\tawait find('.cb').first().click();\n\t\tvar indet = await evaluate(() => document.querySelector('#master').indeterminate);\n\t\texpect(indet).toBe(true);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "joined by on null returns null",
"html": "",
"body": "\n\t\tvar result = await run(`set x to null then return x joined by ','`);\n\t\texpect(result).toBeNull();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "mapped to on null returns null",
"html": "",
"body": "\n\t\tvar result = await run(`set x to null then return x mapped to (it * 2)`);\n\t\texpect(result).toBeNull();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "maps to a property",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"Alice\"}, {name: \"Bob\"}]\n\t\t\tthen return arr mapped to its name`);\n\t\texpect(result).toEqual([\"Alice\", \"Bob\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "maps with an expression",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [1, 2, 3]\n\t\t\tthen return arr mapped to (it * 2)`);\n\t\texpect(result).toEqual([2, 4, 6]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "sorted by binds after in without parens",
"html": "
C
A
B
",
"body": "\n\t\tawait html(\n\t\t\t\"
C
A
B
\"\n\t\t);\n\t\tvar result = await run(\" in #list where its textContent is not 'A'\");\n\t\texpect(result.length).toBe(2);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "sorted by on null returns null",
"html": "",
"body": "\n\t\tvar result = await run(`set x to null then return x sorted by it`);\n\t\texpect(result).toBeNull();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "sorted by then mapped to",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"Charlie\", age: 30}, {name: \"Alice\", age: 20}]\n\t\t\tthen return arr sorted by its age mapped to its name`);\n\t\texpect(result).toEqual([\"Alice\", \"Charlie\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "sorts by a property",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"Charlie\"}, {name: \"Alice\"}, {name: \"Bob\"}]\n\t\t\tthen return arr sorted by its name`);\n\t\texpect(result.map(x => x.name)).toEqual([\"Alice\", \"Bob\", \"Charlie\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "sorts descending",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [3, 1, 2]\n\t\t\tthen return arr sorted by it descending`);\n\t\texpect(result).toEqual([3, 2, 1]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "sorts numbers by a computed key",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"b\", age: 30}, {name: \"a\", age: 20}, {name: \"c\", age: 25}]\n\t\t\tthen return arr sorted by its age`);\n\t\texpect(result.map(x => x.name)).toEqual([\"a\", \"c\", \"b\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "split by on null returns null",
"html": "",
"body": "\n\t\tvar result = await run(`set x to null then return x split by ','\\n`);\n\t\texpect(result).toBeNull();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "the result inside where refers to previous command result, not current element",
"html": "",
"body": "\n\t\tvar result = await run(`get 3\n\t\t\tthen set arr to [1, 2, 3, 4, 5]\n\t\t\tthen return arr where it > the result`);\n\t\texpect(result).toEqual([4, 5]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where after in with mapped to",
"html": "
A
B
C
",
"body": "\n\t\tawait html(\n\t\t\t\"
A
B
C
\"\n\t\t);\n\t\tvar result = await run(\n\t\t\t\" in #items where it matches .yes mapped to its textContent\"\n\t\t);\n\t\texpect(result).toEqual([\"A\", \"C\"]);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where binds after in on closest",
"html": "
ABC
in #box) where it matches .a then put result.length into me\">go (parens) in #box where it matches .a then put result.length into me\">go",
"body": "\n\t\tawait html(\n\t\t\t\"
ABC
\" +\n\t\t\t\" in #box) where it matches .a then put result.length into me\\\">go (parens)\" +\n\t\t\t\" in #box where it matches .a then put result.length into me\\\">go\"\n\t\t);\n\t\tawait find('button').first().click();\n\t\tawait expect(find('button').first()).toHaveText(\"2\");\n\t\tawait find('#b2').click();\n\t\tawait expect(find('#b2')).toHaveText(\"2\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where binds after in without parens",
"html": "
ABC
",
"body": "\n\t\tawait html(\n\t\t\t\"
\" +\n\t\t\t\"ABC\" +\n\t\t\t\"
\"\n\t\t);\n\t\tvar result = await run(\" in #container where it matches .a\");\n\t\texpect(result.length).toBe(2);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where binds after property access",
"html": "",
"body": "\n\t\tvar result = await run(\"obj.items where it > 2\", {\n\t\t\tlocals: { obj: { items: [1, 2, 3, 4] } }\n\t\t});\n\t\texpect(result).toEqual([3, 4]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where in component init followed by on feature",
"html": "\n\t\t\t
AB
\n\t\t\t in #box where it matches .a\n\t\t\t\t on click put :items.length into me\">\n\t\t\t\t\n\t\t\t\n\t\t\tgo\n\t\t",
"body": "\n\t\tawait html(`\n\t\t\t
AB
\n\t\t\t in #box where it matches .a\n\t\t\t\t on click put :items.length into me\">\n\t\t\t\t\n\t\t\t\n\t\t\tgo\n\t\t`);\n\t\tawait find('test-where-comp').click();\n\t\tawait expect(find('test-where-comp')).toHaveText(\"1\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where in init followed by on feature",
"html": "
AB
in #box where it matches .a on click put :items.length into me\">go",
"body": "\n\t\tawait html(\n\t\t\t\"
AB
\" +\n\t\t\t\" in #box where it matches .a \" +\n\t\t\t\"on click put :items.length into me\\\">go\"\n\t\t);\n\t\tawait find('button').click();\n\t\tawait expect(find('button')).toHaveText(\"1\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where on null returns null",
"html": "",
"body": "\n\t\tvar result = await run(`set x to null then return x where it > 1`);\n\t\texpect(result).toBeNull();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where on undefined returns undefined",
"html": "",
"body": "\n\t\tvar result = await run(`return doesNotExist where it > 1`);\n\t\texpect(result).toBeUndefined();\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where then mapped to",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"Alice\", active: true}, {name: \"Bob\", active: false}, {name: \"Charlie\", active: true}]\n\t\t\tthen return arr where its active mapped to its name`);\n\t\texpect(result).toEqual([\"Alice\", \"Charlie\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where then sorted by then mapped to",
"html": "",
"body": "\n\t\tvar result = await run(`set arr to [{name: \"Charlie\", active: true, age: 30}, {name: \"Alice\", active: false, age: 20}, {name: \"Bob\", active: true, age: 25}]\n\t\t\tthen return arr where its active sorted by its age mapped to its name`);\n\t\texpect(result).toEqual([\"Bob\", \"Charlie\"]);\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/collectionExpressions",
"name": "where with is not me followed by on feature",
"html": "\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
in the closest
where it is not me\n\t\t\t\t on change set checked of the :checkboxes to my checked\">
\n\t\t\t
\n\t\t",
"body": "\n\t\tawait html(`\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
in the closest
where it is not me\n\t\t\t\t on change set checked of the :checkboxes to my checked\">
\n\t\t\t
\n\t\t`);\n\t\tawait find('#master').click();\n\t\tawait expect.poll(() => find('.cb').first().isChecked()).toBe(true);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "where with is not me in component template",
"html": "\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t",
"body": "\n\t\tawait html(`\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t`);\n\t\tvar attr = await evaluate(() => document.querySelector('test-where-me input')?.getAttribute('_'));\n\t\tconsole.log(\"ATTR:\", attr);\n\t\tawait find('test-where-me input').click();\n\t\tawait expect.poll(() => find('.cb').first().isChecked()).toBe(true);\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/collectionExpressions",
"name": "works with DOM elements",
"html": "
A
B
C
",
"body": "\n\t\tawait html(\n\t\t\t\"
A
B
C
\" +\n\t\t\t\"\" +\n\t\t\t\"\"\n\t\t);\n\t\tawait find('button').click();\n\t\tawait expect(find('#out')).toHaveText(\"AC\");\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/comparisonOperator",
"name": "I am between works",
"html": "",
"body": "\n\t\texpect(await run(\"I am between 1 and 10\", { me: 5 })).toBe(true)\n\t\texpect(await run(\"I am between 1 and 10\", { me: 0 })).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "I am in works",
"html": "",
"body": "\n\t\texpect(await run(\"I am in [1, 2]\", { me: 1 })).toBe(true)\n\t\texpect(await run(\"I am in [1, 2]\", { me: 2 })).toBe(true)\n\t\texpect(await run(\"I am in [1, 2]\", { me: 3 })).toBe(false)\n\t\texpect(await run(\"I am in null\", { me: null })).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "I am not between works",
"html": "",
"body": "\n\t\texpect(await run(\"I am not between 1 and 10\", { me: 5 })).toBe(false)\n\t\texpect(await run(\"I am not between 1 and 10\", { me: 0 })).toBe(true)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "I am not in works",
"html": "",
"body": "\n\t\texpect(await run(\"I am not in [1, 2]\", { me: 1 })).toBe(false)\n\t\texpect(await run(\"I am not in [1, 2]\", { me: 2 })).toBe(false)\n\t\texpect(await run(\"I am not in [1, 2]\", { me: 3 })).toBe(true)\n\t\texpect(await run(\"I am not in null\", { me: null })).toBe(true)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "I precede works",
"html": "",
"body": "\n\t\tawait html(\"\")\n\t\tawait find('#a').dispatchEvent('click')\n\t\tawait expect(find('#a')).toHaveText(\"yes\")\n\t",
"async": true,
"complexity": "simple"
},
{
"category": "expressions/comparisonOperator",
"name": "am works as alias for is",
"html": "",
"body": "\n\t\texpect(await run(\"2 am 2\")).toBe(true)\n\t\texpect(await run(\"2 am 1\")).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "between works with strings",
"html": "",
"body": "\n\t\texpect(await run(\"'b' is between 'a' and 'c'\")).toBe(true)\n\t\texpect(await run(\"'d' is between 'a' and 'c'\")).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "contains ignoring case works",
"html": "",
"body": "\n\t\texpect(await run(\"'Hello World' contains 'hello' ignoring case\")).toBe(true)\n\t\texpect(await run(\"'Hello World' contains 'WORLD' ignoring case\")).toBe(true)\n\t\texpect(await run(\"'Hello World' contains 'missing' ignoring case\")).toBe(false)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "contains works with arrays",
"html": "",
"body": "\n\t\texpect(await run(\"I contain that\", { me: [1, 2, 3], locals: { that: 1 } })).toBe(true)\n\t\texpect(await run(\"that contains me\", { me: 1, locals: { that: [1, 2, 3] } })).toBe(true)\n\t",
"async": true,
"complexity": "run-eval"
},
{
"category": "expressions/comparisonOperator",
"name": "contains works with css literals",
"html": "