Skip to content

Commit 52c86f5

Browse files
authored
Merge pull request #639 from simonihmig/support-arrays
Support plain arrays
2 parents ecdfd33 + 602513d commit 52c86f5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

addon/src/create.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ import { assignDescriptors } from './-private/helpers';
5050
function buildObject(node, blueprintKey, blueprint, defaultBuilder) {
5151
let definition;
5252

53+
// Preserve plain arrays, prevent `Error: string values are not supported in page object definitions Key: "0"` error
54+
if (Array.isArray(blueprint)) {
55+
node[blueprintKey] = blueprint;
56+
return;
57+
}
58+
5359
// to allow page objects to exist in definitions, we store the definition that
5460
// created the page object, allowing us to substitute a page object with its
5561
// definition during creation

test-app/tests/integration/string-properties-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,12 @@ Key: "stringProp"`)
8989

9090
assert.strictEqual(po.items[0]?.foo, 'bar');
9191
});
92+
93+
test('allows plain arrays', function (assert) {
94+
const po = create({
95+
items: ['one', 'two', 'three'],
96+
});
97+
98+
assert.deepEqual(po.items, ['one', 'two', 'three']);
99+
});
92100
});

0 commit comments

Comments
 (0)