diff --git a/packages/nuejs/test/client/test.css b/packages/nuejs/test/client/test.css
index c7d93b08..86eeb650 100644
--- a/packages/nuejs/test/client/test.css
+++ b/packages/nuejs/test/client/test.css
@@ -112,7 +112,7 @@ button:active {
/* grid */
.grid {
- grid-template-columns: repeat( auto-fit, minmax(320px, 1fr));
+ grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
display: grid;
gap: 2.2em;
}
@@ -122,7 +122,6 @@ button:active {
box-shadow: 1px 1px .3em #ddd;
border-radius: 4px;
padding: 2em;
- max-width: 350px;
}
diff --git a/packages/nuejs/test/compile.js b/packages/nuejs/test/compile.js
index ae819cd8..f18ac356 100644
--- a/packages/nuejs/test/compile.js
+++ b/packages/nuejs/test/compile.js
@@ -1,10 +1,27 @@
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
-import { join } from 'node:path'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
import { parse } from '../src/compile.js'
-import { getDirname } from './test-utils.js'
-const srcdir = getDirname(import.meta.url)
+const genIndex = (name) => `
+
+
+
+
+
${name}
+
+
+
+
+`
+
+const srcdir = dirname(fileURLToPath(import.meta.url))
// Ensure the dist directory exists
const distDir = join(srcdir, 'dist')
@@ -35,5 +52,7 @@ for (const { testPath, name } of testComponentDirs) {
const output = `export const lib = [${components.join(',')}]`
writeFileSync(outputPath, output)
+ writeFileSync(join(outputDir, 'index.html'), genIndex(name))
+
console.log(`Compiled ${name}: ${outputPath}`)
}
diff --git a/packages/nuejs/test/test-clicks/index.html b/packages/nuejs/test/test-clicks/index.html
deleted file mode 100644
index 56c90c04..00000000
--- a/packages/nuejs/test/test-clicks/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-Clicks Tests
-
-
-
-
\ No newline at end of file
diff --git a/packages/nuejs/test/test-fors/component.dhtml b/packages/nuejs/test/test-fors/component.dhtml
new file mode 100644
index 00000000..1baf50be
--- /dev/null
+++ b/packages/nuejs/test/test-fors/component.dhtml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/nuejs/test/test-fors/fors.test.js b/packages/nuejs/test/test-fors/fors.test.js
new file mode 100644
index 00000000..1bda7d51
--- /dev/null
+++ b/packages/nuejs/test/test-fors/fors.test.js
@@ -0,0 +1,84 @@
+import { mkConfigBase, mountTestComponent } from '../test-utils.js'
+
+const mkConfig = mkConfigBase(import.meta.url)
+function arr(parent) { return Array.from(parent.querySelectorAll('li')).map(e => e.textContent) }
+
+
+describe('Nue.js Fors Tests', () => {
+ test('Array', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-array'))
+
+ expect(arr(app.$el)).toEqual(['hello', 'world', '42'])
+
+ cleanup()
+ })
+
+ test('Unpacking Array', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-array-unpack'))
+
+ expect(arr(app.$el)).toEqual(['hello', '42'])
+
+ cleanup()
+ })
+
+ test('Numbered Array', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-array-numbered'))
+
+ expect(arr(app.$el)).toEqual(['0: hello', '1: world', '2: 42'])
+
+ cleanup()
+ })
+
+ test('Object Array', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-object-array'))
+
+ expect(arr(app.$el)).toEqual(['hello', 'world', '42'])
+
+ cleanup()
+ })
+
+ test('Array replaced', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-array-replace'))
+
+ expect(arr(app.$el)).toEqual(['hello'])
+ app.$el.querySelector('button').click()
+ expect(arr(app.$el)).toEqual(['world'])
+
+ cleanup()
+ })
+
+ test('Array funcs', async () => {
+ const { app, cleanup } = await mountTestComponent(mkConfig('test-for-array-funcs'))
+
+ expect(arr(app.$el)).toEqual(['hello', 'world'])
+
+ app.$refs.push.click()
+ app.$refs.push.click()
+ expect(arr(app.$el)).toEqual(['hello', 'world', '42', '42'])
+
+ app.$refs.pop.click()
+ expect(arr(app.$el)).toEqual(['hello', 'world', '42'])
+
+ app.$refs.unshift.click()
+ app.$refs.unshift.click()
+ expect(arr(app.$el)).toEqual(['answer', 'answer', 'hello', 'world', '42'])
+
+ app.$refs.shift.click()
+ expect(arr(app.$el)).toEqual(['answer', 'hello', 'world', '42'])
+
+ app.$refs.reverse.click()
+ expect(arr(app.$el)).toEqual(['42', 'world', 'hello', 'answer'])
+
+ app.$refs.remove.click()
+ expect(arr(app.$el)).toEqual(['42', 'world', 'answer'])
+
+ app.$refs.splice.click()
+ expect(arr(app.$el)).toEqual(['42', 'answer'])
+
+ app.$refs.push.click() // additional 42 at end for sort
+ app.$refs.sort.click()
+ expect(arr(app.$el)).toEqual(['42', '42', 'answer'])
+
+ cleanup()
+ })
+})
diff --git a/packages/nuejs/test/test-ifs/index.html b/packages/nuejs/test/test-ifs/index.html
deleted file mode 100644
index 5366b343..00000000
--- a/packages/nuejs/test/test-ifs/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-Ifs Tests
-
-
-
-
\ No newline at end of file
diff --git a/packages/nuejs/test/test-refs/index.html b/packages/nuejs/test/test-refs/index.html
deleted file mode 100644
index 9045e761..00000000
--- a/packages/nuejs/test/test-refs/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-Refs Tests
-
-
-
-
\ No newline at end of file
diff --git a/packages/nuejs/test/test-utils.js b/packages/nuejs/test/test-utils.js
index 2fec0489..77543630 100644
--- a/packages/nuejs/test/test-utils.js
+++ b/packages/nuejs/test/test-utils.js
@@ -7,15 +7,6 @@ import { createWindow } from 'domino'
import { parse } from '../src/compile.js'
-/**
- * Get directory from url
- * @param {Url} url - Pass `import.meta.url`
- * @returns {string} Directory path containing the current file
- */
-export function getDirname(url) {
- return dirname(fileURLToPath(url))
-}
-
/**
* Get directory path from url and return function for usage with {@linkcode mountTestComponent}
* @param {Url} url - `import.meta.url` to get the test directory
@@ -25,7 +16,7 @@ export function mkConfigBase(url) {
* @param {string} componentName
* @param {Object?} data
*/
- return (componentName, data) => ({ testPath: getDirname(url), componentName, data })
+ return (componentName, data) => ({ testPath: dirname(fileURLToPath(url)), componentName, data })
}