Skip to content

Commit

Permalink
Merge pull request #639 from simonihmig/support-arrays
Browse files Browse the repository at this point in the history
Support plain arrays
  • Loading branch information
ro0gr authored Feb 22, 2024
2 parents ecdfd33 + 602513d commit 52c86f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addon/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ import { assignDescriptors } from './-private/helpers';
function buildObject(node, blueprintKey, blueprint, defaultBuilder) {
let definition;

// Preserve plain arrays, prevent `Error: string values are not supported in page object definitions Key: "0"` error
if (Array.isArray(blueprint)) {
node[blueprintKey] = blueprint;
return;
}

// to allow page objects to exist in definitions, we store the definition that
// created the page object, allowing us to substitute a page object with its
// definition during creation
Expand Down
8 changes: 8 additions & 0 deletions test-app/tests/integration/string-properties-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,12 @@ Key: "stringProp"`)

assert.strictEqual(po.items[0]?.foo, 'bar');
});

test('allows plain arrays', function (assert) {
const po = create({
items: ['one', 'two', 'three'],
});

assert.deepEqual(po.items, ['one', 'two', 'three']);
});
});

0 comments on commit 52c86f5

Please sign in to comment.