Skip to content

Commit

Permalink
Fix to allow objectAt always returns page object instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Jan 22, 2020
1 parent e50c75d commit 33d5913
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tests/acceptance/composition-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ test('allows compose', async function(assert) {
.clickOn('2')
.sum();
//click 3
await page.keys.numbers.objectAt(2)!.click()
await page.keys.numbers.objectAt(2).click()
//click =
await page.keys.operators.objectAt(3)!.click();
await page.keys.operators.objectAt(3).click();
assert.equal(page.screen.value, '15');

await page.screen.fillValue('45')
//click 6
await page.keys.numbers.objectAt(5)!.click();
await page.keys.numbers.objectAt(5).click();

assert.equal(page.screen.value, '456');
});
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/actions-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if (require.has('@ember/test-helpers')) {

await page
.numbers
.objectAt(0)!
.objectAt(0)
.click();

assert.equal(page.screen.text, '1');
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/-private/properties/collection-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ moduleForProperty('collection', function(test) {
<span>Ipsum</span>
`);

assert.equal(page.foo.objectAt(0)!.text, 'Lorem');
assert.equal(page.foo.objectAt(1)!.text, 'Ipsum');
assert.equal(page.foo.objectAt(0).text, 'Lorem');
assert.equal(page.foo.objectAt(1).text, 'Ipsum');
});

test('collects an array of items', async function(assert) {
Expand Down Expand Up @@ -135,7 +135,7 @@ moduleForProperty('collection', function(test) {
</div>
`);

assert.equal(page.foo.objectAt(0)!.text, 'Ipsum');
assert.equal(page.foo.objectAt(0).text, 'Ipsum');
});

test('looks for elements inside multiple scopes', async function(assert) {
Expand Down Expand Up @@ -174,7 +174,7 @@ moduleForProperty('collection', function(test) {
</ul>
`);

assert.equal(page.foo.objectAt(1)!.bar.text, 'Sit');
assert.equal(page.foo.objectAt(1).bar.text, 'Sit');
});

test('resets scope for items', async function(assert) {
Expand All @@ -194,7 +194,7 @@ moduleForProperty('collection', function(test) {
</div>
`);

assert.equal(page.foo.objectAt(0)!.text, 'Lorem');
assert.equal(page.foo.objectAt(0).text, 'Lorem');
});

test('sets correct scope to child collections', async function(assert) {
Expand All @@ -213,7 +213,7 @@ moduleForProperty('collection', function(test) {
<div class="scope"><span><em>Ipsum</em></span></div>
`);

assert.equal(page.foo.objectAt(0)!.bar.objectAt(0)!.text, 'Ipsum');
assert.equal(page.foo.objectAt(0).bar.objectAt(0).text, 'Ipsum');
});

test('iterates over scoped items with a for loop', async function(assert) {
Expand All @@ -234,7 +234,7 @@ moduleForProperty('collection', function(test) {
let textContents: string[] = [];

for (let i = 0; i < page.foo.length; i++) {
let item = page.foo.objectAt(i)!;
let item = page.foo.objectAt(i);
textContents.push(item.text);
}

Expand Down Expand Up @@ -338,7 +338,7 @@ moduleForProperty('collection', function(test) {
);

assert.equal(page.foo.length, 2);
assert.equal(page.foo.objectAt(0)!.text, 'Lorem');
assert.equal(page.foo.objectAt(0).text, 'Lorem');
});

test('objectAt returns an item', async function(assert) {
Expand All @@ -353,8 +353,8 @@ moduleForProperty('collection', function(test) {
<span>Ipsum</span>
`);

assert.equal(page.foo.objectAt(0)!.text, 'Lorem');
assert.equal(page.foo.objectAt(1)!.text, 'Ipsum');
assert.equal(page.foo.objectAt(0).text, 'Lorem');
assert.equal(page.foo.objectAt(1).text, 'Ipsum');
});

test('forEach works correctly', async function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ declare module 'ember-cli-page-object' {
forEach(callback: (c: Component<T>, i: number) => void): void;
map<S>(callback: (c: Component<T>) => S): S[];
mapBy(propName: keyof T | keyof DSL<T>): any[];
objectAt(i: number): Component<T>|undefined;
objectAt(i: number): Component<T>;
toArray(): Array<Component<T>>;
}
}
Expand Down

0 comments on commit 33d5913

Please sign in to comment.