Skip to content

Commit 8325c6d

Browse files
committed
fix ember 6 tests
1 parent bf2c4cc commit 8325c6d

File tree

2 files changed

+52
-41
lines changed

2 files changed

+52
-41
lines changed
Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1-
/* eslint-disable ember/no-actions-hash, ember/no-classic-classes, prettier/prettier */
1+
/* eslint-disable ember/classic-decorator-no-classic-methods */
22
import Controller from '@ember/controller';
3-
import { set } from '@ember/object';
3+
import { set, action } from '@ember/object';
44

5-
export default Controller.extend({
6-
isShowingModal: false,
7-
isShowingSidebarContent: false,
8-
sidebarId: 'sidebar',
9-
isInPlace: false,
10-
isTestingDocumentTitle: false,
11-
favicon: "http://emberjs.com/images/favicon.png",
12-
isShowingOverlay: true,
13-
actions: {
14-
toggleModal() {
15-
this.toggleProperty('isShowingModal');
16-
},
17-
toggleSidebarContent() {
18-
this.toggleProperty('isShowingSidebarContent');
19-
},
20-
switchSidebars() {
21-
var otherSidebarId = this.sidebarId === 'sidebar' ? 'othersidebar' : 'sidebar';
22-
set(this, 'sidebarId', otherSidebarId);
23-
},
24-
toggleInPlace() {
25-
this.toggleProperty('isInPlace');
26-
},
27-
toggleTitle() {
28-
this.toggleProperty('isTestingDocumentTitle');
29-
},
30-
toggleOverlay() {
31-
this.toggleProperty('isShowingOverlay');
32-
}
5+
export default class IndexController extends Controller {
6+
isShowingModal = false;
7+
isShowingSidebarContent = false;
8+
sidebarId = 'sidebar';
9+
isInPlace = false;
10+
isTestingDocumentTitle = false;
11+
favicon = 'http://emberjs.com/images/favicon.png';
12+
isShowingOverlay = true;
13+
14+
@action
15+
toggleModal() {
16+
this.toggleProperty('isShowingModal');
17+
}
18+
19+
@action
20+
toggleSidebarContent() {
21+
this.toggleProperty('isShowingSidebarContent');
22+
}
23+
24+
@action
25+
switchSidebars() {
26+
var otherSidebarId =
27+
this.sidebarId === 'sidebar' ? 'othersidebar' : 'sidebar';
28+
set(this, 'sidebarId', otherSidebarId);
29+
}
30+
31+
@action
32+
toggleInPlace() {
33+
this.toggleProperty('isInPlace');
34+
}
35+
36+
@action
37+
toggleTitle() {
38+
this.toggleProperty('isTestingDocumentTitle');
39+
}
40+
41+
@action
42+
toggleOverlay() {
43+
this.toggleProperty('isShowingOverlay');
3344
}
34-
});
45+
}

tests/dummy/app/templates/index.hbs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,30 @@
3131
that inject Ember into the <code>head</code> of the page.
3232
</p>
3333

34-
<button type="button" id="toggle-title" {{action 'toggleTitle'}}>Toggle Title</button>
34+
<button type="button" id="toggle-title" {{on "click" this.toggleTitle}}>Toggle Title</button>
3535
<label>
3636
Favicon: <Input @value={{this.favicon}} class="favicon" />
3737
</label>
3838

3939
<div class='example' id='example-modal'>
4040
<h2>Modal Example</h2>
4141
{{!-- BEGIN-SNIPPET modal --}}
42-
<button type="button" {{action 'toggleModal'}}>Toggle Modal</button>
42+
<button type="button" {{on "click" this.toggleModal}}>Toggle Modal</button>
4343
{{#current-user as |user|}}
4444
<label>
4545
Username: <Input @value={{user.username}} class="username" />
4646
</label>
4747
{{#if this.isShowingModal}}
4848
{{#ember-wormhole to='modals'}}
4949
{{#if this.isShowingOverlay}}
50-
<div role="button" class="overlay" {{action 'toggleModal'}}></div>
50+
<div role="button" class="overlay" {{on "click" this.toggleModal}}></div>
5151
{{/if}}
5252
<div class="dialog">
5353
<h1>Hi, I'm a simple modal dialog</h1>
5454
<p>Here we have some content which is bound from the context
5555
where the wormhole component was used: "{{user.username}}"</p>
56-
<button type="button" {{action 'toggleModal'}}>Close</button>
57-
<button type="button" {{action 'toggleOverlay'}}>Toggle Overlay</button>
56+
<button type="button" {{on "click" this.toggleModal}}>Close</button>
57+
<button type="button" {{on "click" this.toggleOverlay}}>Toggle Overlay</button>
5858
</div>
5959
{{/ember-wormhole}}
6060
{{/if}}
@@ -66,9 +66,9 @@
6666
<h2>Sidebar Example</h2>
6767
{{!-- BEGIN-SNIPPET sidebar --}}
6868
{{#current-user as |user|}}
69-
<button type="button" {{action 'toggleSidebarContent'}}>Toggle Sidebar Content</button>
70-
<button type="button" {{action 'switchSidebars'}}>Switch Sidebars From Without</button>
71-
<button type="button" {{action 'toggleInPlace'}}>Toggle In Place</button>
69+
<button type="button" {{on "click" this.toggleSidebarContent}}>Toggle Sidebar Content</button>
70+
<button type="button" {{on "click" this.switchSidebars}}>Switch Sidebars From Without</button>
71+
<button type="button" {{on "click" this.toggleInPlace}}>Toggle In Place</button>
7272
<label>
7373
First Name: <Input @value={{user.firstName}} class="first-name" />
7474
</label>
@@ -80,8 +80,8 @@
8080
<h1>Epic sidebar action</h1>
8181
<p>Here we have some content which is bound from the context
8282
where the wormhole component was used: "{{user.fullName}}"</p>
83-
<button type="button" {{action 'toggleSidebarContent'}}>Hide Sidebar Content</button>
84-
<button type="button" {{action 'switchSidebars'}}>Switch Sidebars From Within</button>
83+
<button type="button" {{on "click" this.toggleSidebarContent}}>Hide Sidebar Content</button>
84+
<button type="button" {{on "click" this.switchSidebars}}>Switch Sidebars From Within</button>
8585
{{/ember-wormhole}}
8686
{{/if}}
8787
{{/current-user}}

0 commit comments

Comments
 (0)