Skip to content

Commit c387a48

Browse files
committed
failing test for export default plus decorator
If a class is the default export from its module *and* if it has at least one decorated property or method, the classic-decorator babel plugin never sees it, which means it fails to get any of the runtime assertions.
1 parent ba9aadd commit c387a48

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// this gets imported directly into the test suite. It's in a separate file
2+
// because the bad behavior seems to depend specifically on `export default
3+
// class` plus a decorated property.
4+
5+
import Component from '@ember/component';
6+
import { inject } from '@ember/service'
7+
8+
export default class Example extends Component {
9+
@inject router;
10+
}
11+

tests/unit/classic-decorator-test.js

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import EmberObject from '@ember/object';
44
import Controller from '@ember/controller';
55
import classic from 'ember-classic-decorator';
66
import { DEBUG } from '@glimmer/env';
7+
import BugComponent from 'dummy/components/bug-case';
78

89
module('@classic', () => {
910
if (DEBUG) {
@@ -129,6 +130,14 @@ module('@classic', () => {
129130
FooController.reopenClass({});
130131
}, /You attempted to use the .reopen\(\) method on the FooController class/);
131132
});
133+
134+
test('throws without the decorator when combining export default and a decorated property', assert => {
135+
assert.throws(() => {
136+
// The BugComponent lives in a separate file because the bug only
137+
// manifests when combining `export default` with decorators.
138+
BugComponent.reopenClass({});
139+
}, /You attempted to use the .reopen\(\) method on the @ember\/component class/);
140+
});
132141
});
133142
});
134143
} else {

0 commit comments

Comments
 (0)