Skip to content

Commit

Permalink
Show warning when using legacy collection without itemScope
Browse files Browse the repository at this point in the history
  • Loading branch information
san650 committed Feb 4, 2018
1 parent beeac86 commit c9aa460
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addon/-private/properties/collection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deprecate } from '@ember/application/deprecations';
import { warn } from '@ember/debug';

import { collection as mainCollection } from './collection/main';
import { collection as legacyCollection } from './collection/legacy';
Expand Down Expand Up @@ -123,5 +124,13 @@ export function collection(scopeOrDefinition, definitionOrNothing) {
url: 'https://gist.github.com/san650/17174e4b7b1fd80b049a47eb456a7cdc#file-old-collection-api-js',
});

warn(
'Legacy page object collection definition is invalid. Please, make sure you include a `itemScope` selector.',
scopeOrDefinition.itemScope,
{
id: 'ember-cli-page-object.legacy-collection-missing-item-scope'
}
);

return legacyCollection(scopeOrDefinition);
}
9 changes: 9 additions & 0 deletions tests/integration/deprecations/legacy-collection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ test("doesn't show a deprecation warning when first parameter is a string", func

assert.expectNoDeprecation();
});

test('shows a warning on invalid legacy collection definitions', function(assert) {
assert.expectWarning(function() {
create({
foo: collection({
})
});
}, 'Legacy page object collection definition is invalid. Please, make sure you include a `itemScope` selector.');
});

0 comments on commit c9aa460

Please sign in to comment.