diff --git a/Gemfile b/Gemfile
index abf697bb3b..8b9b4b72de 100644
--- a/Gemfile
+++ b/Gemfile
@@ -48,7 +48,7 @@ gem 'onebox'
gem 'http_accept_language', '~>2.0.5', require: false
gem 'ember-rails', '0.18.5'
-gem 'ember-source', '2.4.6'
+gem 'ember-source', '2.9.1.1'
gem 'barber'
gem 'babel-transpiler'
diff --git a/Gemfile.lock b/Gemfile.lock
index f48e3ff72e..776f689dc0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -93,7 +93,7 @@ GEM
ember-source (>= 1.1.0)
jquery-rails (>= 1.0.17)
railties (>= 3.1)
- ember-source (2.4.6)
+ ember-source (2.9.1.1)
erubis (2.7.0)
eventmachine (1.2.0.1)
excon (0.53.0)
@@ -413,7 +413,7 @@ DEPENDENCIES
discourse_fastimage (= 2.0.3)
email_reply_trimmer (= 0.1.6)
ember-rails (= 0.18.5)
- ember-source (= 2.4.6)
+ ember-source (= 2.9.1.1)
excon
execjs
fabrication (= 2.9.8)
diff --git a/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6
index 7d11fc8622..7ddc6f3ac4 100644
--- a/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6
@@ -68,7 +68,7 @@ export default Ember.Controller.extend(BufferedContent, {
this.get('model').save(data).then(() => {
if (newBadge) {
const adminBadges = this.get('adminBadges.model');
- if (!adminBadges.contains(model)) {
+ if (!adminBadges.includes(model)) {
adminBadges.pushObject(model);
}
this.transitionToRoute('adminBadges.show', model.get('id'));
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 2a4085f785..96a2066c41 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -89,7 +89,6 @@
//= require_tree ./discourse/models
//= require_tree ./discourse/components
//= require_tree ./discourse/raw-views
-//= require_tree ./discourse/views
//= require_tree ./discourse/helpers
//= require_tree ./discourse/templates
//= require_tree ./discourse/routes
diff --git a/app/assets/javascripts/discourse/components/mount-widget.js.es6 b/app/assets/javascripts/discourse/components/mount-widget.js.es6
index 3c56961ff8..3c41721fe6 100644
--- a/app/assets/javascripts/discourse/components/mount-widget.js.es6
+++ b/app/assets/javascripts/discourse/components/mount-widget.js.es6
@@ -23,8 +23,6 @@ export default Ember.Component.extend({
this._super();
const name = this.get('widget');
- (this.get('delegated') || []).forEach(m => this.set(m, m));
-
this.register = getRegister(this);
this._widgetClass = queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
@@ -33,7 +31,6 @@ export default Ember.Component.extend({
console.error(`Error: Could not find widget: ${name}`);
}
-
this._childEvents = [];
this._connected = [];
this._dispatched = [];
diff --git a/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 b/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6
index aeb9db8baa..13473c0e0f 100644
--- a/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6
@@ -1,17 +1,11 @@
import computed from 'ember-addons/ember-computed-decorators';
-import DelegatedActions from 'discourse/mixins/delegated-actions';
-export default Ember.Component.extend(DelegatedActions, {
+export default Ember.Component.extend({
elementId: 'topic-footer-buttons',
// Allow us to extend it
layoutName: 'components/topic-footer-buttons',
- init() {
- this._super();
- this.delegateAll(this.get('topicDelegated'));
- },
-
@computed('topic.details.can_invite_to')
canInviteTo(result) {
return !this.site.mobileView && result;
diff --git a/app/assets/javascripts/discourse/components/topic-progress.js.es6 b/app/assets/javascripts/discourse/components/topic-progress.js.es6
index 85cb520955..938c708549 100644
--- a/app/assets/javascripts/discourse/components/topic-progress.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-progress.js.es6
@@ -3,17 +3,11 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor
export default Ember.Component.extend({
elementId: 'topic-progress-wrapper',
classNameBindings: ['docked'],
- expanded: false,
docked: false,
progressPosition: null,
postStream: Ember.computed.alias('topic.postStream'),
_streamPercentage: null,
- init() {
- this._super();
- (this.get('delegated') || []).forEach(m => this.set(m, m));
- },
-
@computed('progressPosition')
jumpTopDisabled(progressPosition) {
return progressPosition <= 3;
diff --git a/app/assets/javascripts/discourse/controllers/application.js.es6 b/app/assets/javascripts/discourse/controllers/application.js.es6
index dc9f45d322..78402acd25 100644
--- a/app/assets/javascripts/discourse/controllers/application.js.es6
+++ b/app/assets/javascripts/discourse/controllers/application.js.es6
@@ -15,4 +15,10 @@ export default Ember.Controller.extend({
loginRequired() {
return Discourse.SiteSettings.login_required && !Discourse.User.current();
},
+
+ actions: {
+ appRouteAction(name) {
+ return this.send(name);
+ }
+ }
});
diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6
index ea7dee4409..50bd018802 100644
--- a/app/assets/javascripts/discourse/controllers/create-account.js.es6
+++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6
@@ -114,7 +114,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
email = this.get("accountEmail");
- if (this.get('rejectedEmails').contains(email)) {
+ if (this.get('rejectedEmails').includes(email)) {
return InputValidation.create({
failed: true,
reason: I18n.t('user.email.invalid')
@@ -314,7 +314,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
});
}
- if (this.get('rejectedPasswords').contains(password)) {
+ if (this.get('rejectedPasswords').includes(password)) {
return InputValidation.create({
failed: true,
reason: I18n.t('user.password.common')
diff --git a/app/assets/javascripts/discourse/controllers/tags-show.js.es6 b/app/assets/javascripts/discourse/controllers/tags-show.js.es6
index 0e8e15db50..1e8e0c2fa0 100644
--- a/app/assets/javascripts/discourse/controllers/tags-show.js.es6
+++ b/app/assets/javascripts/discourse/controllers/tags-show.js.es6
@@ -16,7 +16,7 @@ if (customNavItemHref) {
if (navItem.get('tagId')) {
var name = navItem.get('name');
- if ( !Discourse.Site.currentProp('filters').contains(name) ) {
+ if ( !Discourse.Site.currentProp('filters').includes(name) ) {
return null;
}
diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6
index 4b9650fd98..9638a25671 100644
--- a/app/assets/javascripts/discourse/controllers/topic.js.es6
+++ b/app/assets/javascripts/discourse/controllers/topic.js.es6
@@ -32,30 +32,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
filter: null,
quoteState: null,
- topicDelegated: [
- 'toggleMultiSelect',
- 'deleteTopic',
- 'recoverTopic',
- 'toggleClosed',
- 'showAutoClose',
- 'showFeatureTopic',
- 'showChangeTimestamp',
- 'toggleArchived',
- 'toggleVisibility',
- 'convertToPublicTopic',
- 'convertToPrivateMessage',
- 'jumpTop',
- 'jumpToPost',
- 'jumpToPostPrompt',
- 'jumpToIndex',
- 'jumpBottom',
- 'replyToPost',
- 'toggleArchiveMessage',
- 'showInvite',
- 'toggleBookmark',
- 'showFlagTopic'
- ],
-
updateQueryParams() {
const postStream = this.get('model.postStream');
this.setProperties(postStream.get('streamFilters'));
@@ -175,6 +151,22 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
actions: {
+ showPostFlags(post) {
+ return this.send('showFlags', post);
+ },
+
+ topicRouteAction(name) {
+ return this.send(name);
+ },
+
+ openAutoClose() {
+ this.send('showAutoClose');
+ },
+
+ openFeatureTopic() {
+ this.send('showFeatureTopic');
+ },
+
deselectText() {
this.get('quoteState').setProperties({ buffer: null, postId: null });
},
@@ -818,7 +810,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
postSelected(post) {
if (this.get('allPostsSelected')) { return true; }
- if (this.get('selectedPosts').contains(post)) { return true; }
+ if (this.get('selectedPosts').includes(post)) { return true; }
if (this.get('selectedReplies').findBy('post_number', post.get('reply_to_post_number'))) { return true; }
return false;
diff --git a/app/assets/javascripts/discourse/mixins/delegate-actions.js.es6 b/app/assets/javascripts/discourse/mixins/delegate-actions.js.es6
deleted file mode 100644
index ce3e46a56f..0000000000
--- a/app/assets/javascripts/discourse/mixins/delegate-actions.js.es6
+++ /dev/null
@@ -1,6 +0,0 @@
-export default Ember.Mixin.create({
- init() {
- this._super();
- (this.get('delegated') || []).forEach(m => this.set(m, m));
- },
-});
diff --git a/app/assets/javascripts/discourse/mixins/delegated-actions.js.es6 b/app/assets/javascripts/discourse/mixins/delegated-actions.js.es6
deleted file mode 100644
index 2aae916a9d..0000000000
--- a/app/assets/javascripts/discourse/mixins/delegated-actions.js.es6
+++ /dev/null
@@ -1,12 +0,0 @@
-export default Ember.Mixin.create({
- delegateAll(actionNames) {
- actionNames = actionNames || [];
-
- this.actions = this.actions || {};
-
- actionNames.forEach(m => {
- this.actions[m] = function() { this.sendAction(m); };
- this.set(m, m);
- });
- }
-});
diff --git a/app/assets/javascripts/discourse/models/nav-item.js.es6 b/app/assets/javascripts/discourse/models/nav-item.js.es6
index 58845c2d51..d28b672834 100644
--- a/app/assets/javascripts/discourse/models/nav-item.js.es6
+++ b/app/assets/javascripts/discourse/models/nav-item.js.es6
@@ -86,9 +86,9 @@ NavItem.reopenClass({
testName = name.split("/")[0],
anonymous = !Discourse.User.current();
- if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').contains(testName)) return null;
+ if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').includes(testName)) return null;
if (!Discourse.Category.list() && testName === "categories") return null;
- if (!Discourse.Site.currentProp('top_menu_items').contains(testName)) return null;
+ if (!Discourse.Site.currentProp('top_menu_items').includes(testName)) return null;
var args = { name: name, hasIcon: name === "unread" }, extra = null, self = this;
if (opts.category) { args.category = opts.category; }
diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6
index a711303f22..32cfa6427f 100644
--- a/app/assets/javascripts/discourse/models/post-stream.js.es6
+++ b/app/assets/javascripts/discourse/models/post-stream.js.es6
@@ -168,7 +168,7 @@ export default RestModel.extend({
this.set('summary', false);
let jump = false;
- if (userFilters.contains(username)) {
+ if (userFilters.includes(username)) {
userFilters.removeObject(username);
} else {
userFilters.addObject(username);
@@ -256,7 +256,7 @@ export default RestModel.extend({
return this.findPostsByIds(gap).then(posts => {
posts.forEach(p => {
const stored = this.storePost(p);
- if (!currentPosts.contains(stored)) {
+ if (!currentPosts.includes(stored)) {
currentPosts.insertAt(postIdx++, stored);
}
});
@@ -410,7 +410,7 @@ export default RestModel.extend({
if (stored) {
const posts = this.get('posts');
- if (!posts.contains(stored)) {
+ if (!posts.includes(stored)) {
if (!this.get('loadingBelow')) {
this.get('postsWithPlaceholders').appendPost(() => posts.pushObject(stored));
} else {
diff --git a/app/assets/javascripts/discourse/templates/additional-composer-buttons.hbs b/app/assets/javascripts/discourse/templates/additional-composer-buttons.hbs
deleted file mode 100644
index 43ccd1b392..0000000000
--- a/app/assets/javascripts/discourse/templates/additional-composer-buttons.hbs
+++ /dev/null
@@ -1 +0,0 @@
-{{!-- THIS IS AN EMPTY TEMPLATE THAT NEEDS TO BE OVERWRITTEN --}}
diff --git a/app/assets/javascripts/discourse/templates/application.hbs b/app/assets/javascripts/discourse/templates/application.hbs
index 8a074e2eb3..0b7e688ac0 100644
--- a/app/assets/javascripts/discourse/templates/application.hbs
+++ b/app/assets/javascripts/discourse/templates/application.hbs
@@ -1,11 +1,11 @@
{{plugin-outlet "above-site-header"}}
{{site-header canSignUp=canSignUp
- showCreateAccount="showCreateAccount"
- showLogin="showLogin"
- showKeyboard="showKeyboardShortcutsHelp"
- toggleMobileView="toggleMobileView"
- toggleAnonymous="toggleAnonymous"
- logout="logout"}}
+ showCreateAccount=(action "appRouteAction" "showCreateAccount")
+ showLogin=(action "appRouteAction" "showLogin")
+ showKeyboard=(action "appRouteAction" "showKeyboardShortcutsHelp")
+ toggleMobileView=(action "appRouteAction" "toggleMobileView")
+ toggleAnonymous=(action "appRouteAction" "toggleAnonymous")
+ logout=(action "appRouteAction" "logout")}}
{{plugin-outlet "below-site-header"}}
diff --git a/app/assets/javascripts/discourse/templates/components/topic-footer-buttons.hbs b/app/assets/javascripts/discourse/templates/components/topic-footer-buttons.hbs
index 518abc95c2..9585bb0236 100644
--- a/app/assets/javascripts/discourse/templates/components/topic-footer-buttons.hbs
+++ b/app/assets/javascripts/discourse/templates/components/topic-footer-buttons.hbs
@@ -1,5 +1,18 @@
{{#if showAdminButton}}
- {{topic-admin-menu-button topic=topic delegated=topicDelegated openUpwards="true"}}
+ {{topic-admin-menu-button
+ topic=topic
+ openUpwards="true"
+ toggleMultiSelect=toggleMultiSelect
+ deleteTopic=deleteTopic
+ recoverTopic=recoverTopic
+ toggleClosed=toggleClosed
+ toggleArchived=toggleArchived
+ toggleVisibility=toggleVisibility
+ showAutoClose=showAutoClose
+ showFeatureTopic=showFeatureTopic
+ showChangeTimestamp=showChangeTimestamp
+ convertToPublicTopic=convertToPublicTopic
+ convertToPrivateMessage=convertToPrivateMessage}}
{{/if}}
{{#unless topic.isPrivateMessage}}
@@ -10,7 +23,7 @@
title=bookmarkTitle
label=bookmarkLabel
icon="bookmark"
- action="toggleBookmark"}}
+ action=toggleBookmark}}
-
@@ -106,35 +135,34 @@
selectedPostsCount=selectedPostsCount
selectedQuery=selectedQuery
gaps=model.postStream.gaps
- showFlags="showFlags"
- editPost="editPost"
- showHistory="showHistory"
- showLogin="showLogin"
- showRawEmail="showRawEmail"
- deletePost="deletePost"
- recoverPost="recoverPost"
- expandHidden="expandHidden"
- newTopicAction="replyAsNewTopic"
- expandFirstPost="expandFirstPost"
- toggleBookmark="toggleBookmark"
- togglePostType="togglePostType"
- rebakePost="rebakePost"
- changePostOwner="changePostOwner"
- unhidePost="unhidePost"
- replyToPost="replyToPost"
- toggleWiki="toggleWiki"
- toggleSummary="toggleSummary"
- removeAllowedUser="removeAllowedUser"
- removeAllowedGroup="removeAllowedGroup"
- showInvite="showInvite"
- topVisibleChanged="topVisibleChanged"
- currentPostChanged="currentPostChanged"
- currentPostScrolled="currentPostScrolled"
- bottomVisibleChanged="bottomVisibleChanged"
- selectPost="toggledSelectedPost"
- selectReplies="toggledSelectedPostReplies"
- fillGapBefore="fillGapBefore"
- fillGapAfter="fillGapAfter"}}
+ showFlags=(action "showPostFlags")
+ editPost=(action "editPost")
+ showHistory=(action "topicRouteAction" "showHistory")
+ showLogin=(action "topicRouteAction" "showLogin")
+ showRawEmail=(action "topicRouteAction" "showRawEmail")
+ deletePost=(action "deletePost")
+ recoverPost=(action "recoverPost")
+ expandHidden=(action "expandHidden")
+ newTopicAction=(action "replyAsNewTopic")
+ toggleBookmark=(action "toggleBookmark")
+ togglePostType=(action "togglePostType")
+ rebakePost=(action "rebakePost")
+ changePostOwner=(action "changePostOwner")
+ unhidePost=(action "unhidePost")
+ replyToPost=(action "replyToPost")
+ toggleWiki=(action "toggleWiki")
+ toggleSummary=(action "toggleSummary")
+ removeAllowedUser=(action "removeAllowedUser")
+ removeAllowedGroup=(action "removeAllowedGroup")
+ showInvite=(action "topicRouteAction" "showInvite")
+ topVisibleChanged=(action "topVisibleChanged")
+ currentPostChanged=(action "currentPostChanged")
+ currentPostScrolled=(action "currentPostScrolled")
+ bottomVisibleChanged=(action "bottomVisibleChanged")
+ selectPost=(action "toggledSelectedPost")
+ selectReplies=(action "toggledSelectedPostReplies")
+ fillGapBefore=(action "fillGapBefore")
+ fillGapAfter=(action "fillGapAfter")}}
{{/unless}}
{{conditional-loading-spinner condition=model.postStream.loadingBelow}}
@@ -150,7 +178,25 @@
{{signup-cta}}
{{else}}
{{#if currentUser}}
- {{topic-footer-buttons topic=model topicDelegated=topicDelegated}}
+ {{topic-footer-buttons
+ topic=model
+ toggleMultiSelect=(action "toggleMultiSelect")
+ deleteTopic=(action "deleteTopic")
+ recoverTopic=(action "recoverTopic")
+ toggleClosed=(action "toggleClosed")
+ toggleArchived=(action "toggleArchived")
+ toggleVisibility=(action "toggleVisibility")
+ showAutoClose=(action "topicRouteAction" "showAutoClose")
+ showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
+ showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
+ convertToPublicTopic=(action "convertToPublicTopic")
+ convertToPrivateMessage=(action "convertToPrivateMessage")
+ toggleBookmark=(action "toggleBookmark")
+ showFlagTopic=(action "topicRouteAction" "showFlagTopic")
+ showInvite=(action "topicRouteAction" "showInvite")
+ toggleArchiveMessage=(action "toggleArchiveMessage")
+ replyToPost=(action "replyToPost")
+ }}
{{else}}
{{d-button icon="reply" class="btn-primary" action="showLogin" label="topic.reply.title"}}
{{/if}}
diff --git a/app/assets/javascripts/discourse/views/modal-body.js.es6 b/app/assets/javascripts/discourse/views/modal-body.js.es6
deleted file mode 100644
index e7e1f865ba..0000000000
--- a/app/assets/javascripts/discourse/views/modal-body.js.es6
+++ /dev/null
@@ -1,40 +0,0 @@
-import deprecated from 'discourse-common/lib/deprecated';
-
-export default Ember.View.extend({
- focusInput: true,
-
- didInsertElement() {
- this._super();
-
- deprecated('ModalBodyView is deprecated. Use the `d-modal-body` component instead');
-
- $('#modal-alert').hide();
- $('#discourse-modal').modal('show');
- Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender);
-
- this.appEvents.on('modal-body:flash', msg => this._flash(msg));
- },
-
- willDestroyElement() {
- this._super();
- this.appEvents.off('modal-body:flash');
- },
-
- _afterFirstRender() {
- if (!this.site.mobileView && this.get('focusInput')) {
- this.$('input:first').focus();
- }
-
- const title = this.get('title');
- if (title) {
- this.set('controller.modal.title', title);
- }
- },
-
- _flash(msg) {
- $('#modal-alert').hide()
- .removeClass('alert-error', 'alert-success')
- .addClass(`alert alert-${msg.messageClass || 'success'}`).html(msg.text || '')
- .fadeIn();
- }
-});
diff --git a/app/assets/javascripts/discourse/widgets/topic-map.js.es6 b/app/assets/javascripts/discourse/widgets/topic-map.js.es6
index 675e8b9d3a..67f70aefd9 100644
--- a/app/assets/javascripts/discourse/widgets/topic-map.js.es6
+++ b/app/assets/javascripts/discourse/widgets/topic-map.js.es6
@@ -11,7 +11,7 @@ function renderParticipants(userFilters, participants) {
userFilters = userFilters || [];
return participants.map(p => {
- return this.attach('topic-participant', p, { state: { toggled: userFilters.contains(p.username) } });
+ return this.attach('topic-participant', p, { state: { toggled: userFilters.includes(p.username) } });
});
}
diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6
index 8cf85e2555..55ea1db528 100644
--- a/app/assets/javascripts/discourse/widgets/widget.js.es6
+++ b/app/assets/javascripts/discourse/widgets/widget.js.es6
@@ -256,31 +256,24 @@ export default class Widget {
}
_sendComponentAction(name, param) {
- const view = this._findAncestorWithProperty('_emberView');
-
let promise;
- if (view) {
- // Peek into ember internals to allow us to return promises from actions
- const ev = view._emberView;
- const target = ev.get('targetObject');
- const actionName = ev.get(name);
- if (!actionName) {
- Ember.warn(`${name} not found`);
+ const view = this._findView();
+ if (view) {
+ const method = view.attrs[name];
+ if (!method) {
+ console.warn(`${name} not found`);
return;
}
- if (target) {
- // TODO: Use ember closure actions
- const actions = target.actions || target.actionHooks || {};
- const method = actions[actionName];
- if (method) {
- promise = method.call(target, param);
- if (!promise || !promise.then) {
- promise = Ember.RSVP.resolve(promise);
- }
- } else {
- return ev.sendAction(name, param);
+ if (typeof name === "string") {
+ view.sendAction(name, param);
+ promise = Ember.RSVP.resolve();
+ } else {
+ const target = view.get('targetObject');
+ promise = method.call(target, param);
+ if (!promise || !promise.then) {
+ promise = Ember.RSVP.resolve(promise);
}
}
}
diff --git a/app/assets/javascripts/env.js b/app/assets/javascripts/env.js
index 12deda108c..f561c7fad7 100644
--- a/app/assets/javascripts/env.js
+++ b/app/assets/javascripts/env.js
@@ -1,4 +1,3 @@
window.ENV = { };
window.EmberENV = window.EmberENV || {};
window.EmberENV.FORCE_JQUERY = true;
-window.EmberENV._ENABLE_LEGACY_VIEW_SUPPORT = true;
diff --git a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
index 401838b610..35aec81b5c 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
+++ b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
@@ -1,5 +1,4 @@
-import { acceptance, controllerFor } from "helpers/qunit-helpers";
-import PostCooked from 'discourse/widgets/post-cooked';
+import { acceptance } from "helpers/qunit-helpers";
acceptance("Rendering polls", {
loggedIn: true,
@@ -11,7 +10,7 @@ acceptance("Rendering polls", {
{ "Content-Type": "application/json" },
object
];
- }
+ };
server.get('/t/13.json', () => {
return response({"post_stream":{"posts":[{"id":19,"name":null,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png","created_at":"2016-12-01T02:39:49.199Z","cooked":"
\n\n
","post_number":1,"post_type":1,"updated_at":"2016-12-01T02:47:18.317Z","reply_count":0,"reply_to_post_number":null,"quote_count":0,"avg_time":null,"incoming_link_count":0,"reads":1,"score":0,"yours":true,"topic_id":13,"topic_slug":"this-is-a-test-topic-for-polls","display_username":null,"primary_group_name":null,"primary_group_flair_url":null,"primary_group_flair_bg_color":null,"primary_group_flair_color":null,"version":2,"can_edit":true,"can_delete":false,"can_recover":true,"can_wiki":true,"read":true,"user_title":null,"actions_summary":[{"id":3,"can_act":true},{"id":4,"can_act":true},{"id":5,"hidden":true,"can_act":true},{"id":7,"can_act":true},{"id":8,"can_act":true}],"moderator":false,"admin":true,"staff":true,"user_id":1,"hidden":false,"hidden_reason_id":null,"trust_level":4,"deleted_at":null,"user_deleted":false,"edit_reason":null,"can_view_edit_history":true,"wiki":false,"polls":{"poll":{"options":[{"id":"57ddd734344eb7436d64a7d68a0df444","html":"test","votes":0},{"id":"b5b78d79ab5b5d75d4d33d8b87f5d2aa","html":"haha","votes":0}],"voters":2,"status":"open","name":"poll"},"test":{"options":[{"id":"c26ad90783b0d80936e5fdb292b7963c","html":"donkey","votes":0},{"id":"99f2b9ac452ba73b115fcf3556e6d2d4","html":"kong","votes":0}],"voters":3,"status":"open","name":"test"}}}],"stream":[19]},"timeline_lookup":[[1,0]],"id":13,"title":"This is a test topic for polls","fancy_title":"This is a test topic for polls","posts_count":1,"created_at":"2016-12-01T02:39:48.055Z","views":1,"reply_count":0,"participant_count":1,"like_count":0,"last_posted_at":"2016-12-01T02:39:49.199Z","visible":true,"closed":false,"archived":false,"has_summary":false,"archetype":"regular","slug":"this-is-a-test-topic-for-polls","category_id":1,"word_count":10,"deleted_at":null,"user_id":1,"draft":null,"draft_key":"topic_13","draft_sequence":4,"posted":true,"unpinned":null,"pinned_globally":false,"pinned":false,"pinned_at":null,"pinned_until":null,"details":{"auto_close_at":null,"auto_close_hours":null,"auto_close_based_on_last_post":false,"created_by":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"},"last_poster":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"},"participants":[{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png","post_count":1}],"suggested_topics":[{"id":8,"title":"Welcome to Discourse","fancy_title":"Welcome to Discourse","slug":"welcome-to-discourse","posts_count":1,"reply_count":0,"highest_post_number":1,"image_url":null,"created_at":"2016-11-24T02:10:54.328Z","last_posted_at":"2016-11-24T02:10:54.393Z","bumped":true,"bumped_at":"2016-11-24T02:10:54.393Z","unseen":false,"pinned":true,"unpinned":null,"excerpt":"The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important! \n\nEdit this into a brief description of your community: \n\n\nWho is it for?\nWhat can they …","visible":true,"closed":false,"archived":false,"bookmarked":null,"liked":null,"archetype":"regular","like_count":0,"views":0,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":-1,"username":"system","avatar_template":"/letter_avatar_proxy/v2/letter/s/bcef8e/{size}.png"}}]},{"id":12,"title":"Some testing topic testing","fancy_title":"Some testing topic testing","slug":"some-testing-topic-testing","posts_count":4,"reply_count":0,"highest_post_number":4,"image_url":null,"created_at":"2016-11-24T08:36:08.773Z","last_posted_at":"2016-12-01T01:15:52.008Z","bumped":true,"bumped_at":"2016-12-01T01:15:52.008Z","unseen":false,"last_read_post_number":4,"unread":0,"new_posts":0,"pinned":false,"unpinned":null,"visible":true,"closed":false,"archived":false,"notification_level":3,"bookmarked":false,"liked":false,"archetype":"regular","like_count":0,"views":2,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"}}]},{"id":11,"title":"Some testing topic","fancy_title":"Some testing topic","slug":"some-testing-topic","posts_count":1,"reply_count":0,"highest_post_number":1,"image_url":null,"created_at":"2016-11-24T08:35:26.758Z","last_posted_at":"2016-11-24T08:35:26.894Z","bumped":true,"bumped_at":"2016-11-24T08:35:26.894Z","unseen":false,"last_read_post_number":1,"unread":0,"new_posts":0,"pinned":false,"unpinned":null,"visible":true,"closed":false,"archived":false,"notification_level":3,"bookmarked":false,"liked":false,"archetype":"regular","like_count":0,"views":0,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"}}]}],"notification_level":3,"notifications_reason_id":1,"can_move_posts":true,"can_edit":true,"can_delete":true,"can_recover":true,"can_remove_allowed_users":true,"can_invite_to":true,"can_create_post":true,"can_reply_as_new_topic":true,"can_flag_topic":true},"highest_post_number":1,"last_read_post_number":1,"last_read_post_id":19,"deleted_by":null,"has_deleted":false,"actions_summary":[{"id":4,"count":0,"hidden":false,"can_act":true},{"id":7,"count":0,"hidden":false,"can_act":true},{"id":8,"count":0,"hidden":false,"can_act":true}],"chunk_size":20,"bookmarked":false});
diff --git a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
index e4a7aaceb4..f58845ecfc 100644
--- a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
+++ b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
@@ -20,6 +20,6 @@ test("grantableBadges", function() {
});
- not(badgeNames.contains(badgeDisabled), "excludes disabled badges");
+ not(badgeNames.includes(badgeDisabled), "excludes disabled badges");
deepEqual(badgeNames, sortedNames, "sorts badges by name");
});
diff --git a/test/javascripts/models/post-stream-test.js.es6 b/test/javascripts/models/post-stream-test.js.es6
index 5f825d9fbc..b0c455e8fa 100644
--- a/test/javascripts/models/post-stream-test.js.es6
+++ b/test/javascripts/models/post-stream-test.js.es6
@@ -170,7 +170,7 @@ test("toggleParticipant", function() {
equal(postStream.get('userFilters.length'), 0, "by default no participants are toggled");
postStream.toggleParticipant(participant.username);
- ok(postStream.get('userFilters').contains('eviltrout'), 'eviltrout is in the filters');
+ ok(postStream.get('userFilters').includes('eviltrout'), 'eviltrout is in the filters');
postStream.toggleParticipant(participant.username);
blank(postStream.get('userFilters'), "toggling the participant again removes them");
@@ -283,7 +283,7 @@ test("identity map", function() {
});
test("loadIntoIdentityMap with no data", () => {
- buildStream(1234).loadIntoIdentityMap([]).then(result => {
+ return buildStream(1234).loadIntoIdentityMap([]).then(result => {
equal(result.length, 0, 'requesting no posts produces no posts');
});
});
@@ -291,7 +291,7 @@ test("loadIntoIdentityMap with no data", () => {
test("loadIntoIdentityMap with post ids", function() {
const postStream = buildStream(1234);
- postStream.loadIntoIdentityMap([10]).then(function() {
+ return postStream.loadIntoIdentityMap([10]).then(function() {
present(postStream.findLoadedPost(10), "it adds the returned post to the store");
});
});
@@ -327,7 +327,7 @@ test("staging and undoing a new post", function() {
equal(stagedPost.get('topic'), topic, "it assigns the topic reference");
equal(stagedPost.get('post_number'), 2, "it is assigned the probable post_number");
present(stagedPost.get('created_at'), "it is assigned a created date");
- ok(postStream.get('posts').contains(stagedPost), "the post is added to the stream");
+ ok(postStream.get('posts').includes(stagedPost), "the post is added to the stream");
equal(stagedPost.get('id'), -1, "the post has a magical -1 id");
// Undoing a created post (there was an error)
@@ -337,7 +337,7 @@ test("staging and undoing a new post", function() {
equal(topic.get('highest_post_number'), 1, "it reverts the highest_post_number");
equal(topic.get('posts_count'), 1, "it reverts the post count");
equal(postStream.get('filteredPostsCount'), 1, "it retains the filteredPostsCount");
- ok(!postStream.get('posts').contains(stagedPost), "the post is removed from the stream");
+ ok(!postStream.get('posts').includes(stagedPost), "the post is removed from the stream");
ok(postStream.get('lastAppended'), original, "it doesn't consider undid post lastAppended");
});
@@ -367,7 +367,7 @@ test("staging and committing a post", function() {
ok(postStream.get('lastAppended'), original, "staging a post doesn't change the lastAppended");
postStream.commitPost(stagedPost);
- ok(postStream.get('posts').contains(stagedPost), "the post is still in the stream");
+ ok(postStream.get('posts').includes(stagedPost), "the post is still in the stream");
ok(!postStream.get('loading'), "it is no longer loading");
equal(postStream.get('filteredPostsCount'), 2, "it increases the filteredPostsCount");
diff --git a/test/javascripts/models/result-set-test.js.es6 b/test/javascripts/models/result-set-test.js.es6
index c846fd8872..18c9aa0c80 100644
--- a/test/javascripts/models/result-set-test.js.es6
+++ b/test/javascripts/models/result-set-test.js.es6
@@ -15,7 +15,7 @@ test('defaults', function() {
test('pagination support', function() {
const store = createStore();
- store.findAll('widget').then(function(rs) {
+ return store.findAll('widget').then(function(rs) {
equal(rs.get('length'), 2);
equal(rs.get('totalRows'), 4);
ok(rs.get('loadMoreUrl'), 'has a url to load more');
@@ -36,7 +36,7 @@ test('pagination support', function() {
test('refresh support', function() {
const store = createStore();
- store.findAll('widget').then(function(rs) {
+ return store.findAll('widget').then(function(rs) {
equal(rs.get('refreshUrl'), '/widgets?refresh=true', 'it has the refresh url');
const promise = rs.refresh();
diff --git a/test/javascripts/widgets/actions-summary-test.js.es6 b/test/javascripts/widgets/actions-summary-test.js.es6
index 9b7f9cea23..6542d17b12 100644
--- a/test/javascripts/widgets/actions-summary-test.js.es6
+++ b/test/javascripts/widgets/actions-summary-test.js.es6
@@ -23,7 +23,7 @@ widgetTest('listing actions', {
});
widgetTest('undo', {
- template: '{{mount-widget widget="actions-summary" args=args undoPostAction="undoPostAction"}}',
+ template: '{{mount-widget widget="actions-summary" args=args undoPostAction=undoPostAction}}',
setup() {
this.set('args', {
actionsSummary: [
@@ -31,7 +31,7 @@ widgetTest('undo', {
]
});
- this.on('undoPostAction', () => this.undid = true);
+ this.set('undoPostAction', () => this.undid = true);
},
test(assert) {
assert.equal(this.$('.post-actions .post-action').length, 1);
diff --git a/vendor/assets/javascripts/ember-qunit.js b/vendor/assets/javascripts/ember-qunit.js
index 759edca9be..cf41920e2e 100644
--- a/vendor/assets/javascripts/ember-qunit.js
+++ b/vendor/assets/javascripts/ember-qunit.js
@@ -111,81 +111,82 @@ var define, requireModule, require, requirejs;
};
})();
-define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/test', 'ember-qunit/only', 'ember-test-helpers'], function (exports, moduleFor, moduleForComponent, moduleForModel, test, only, ember_test_helpers) {
-
+define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/adapter', 'ember-test-helpers', 'qunit'], function (exports, _emberQunitModuleFor, _emberQunitModuleForComponent, _emberQunitModuleForModel, _emberQunitAdapter, _emberTestHelpers, _qunit) {
'use strict';
-
-
- exports.moduleFor = moduleFor['default'];
- exports.moduleForComponent = moduleForComponent['default'];
- exports.moduleForModel = moduleForModel['default'];
- exports.test = test['default'];
- exports.only = only['default'];
- exports.setResolver = ember_test_helpers.setResolver;
-
+ exports.module = _qunit.module;
+ exports.test = _qunit.test;
+ exports.skip = _qunit.skip;
+ exports.only = _qunit.only;
+ exports.moduleFor = _emberQunitModuleFor['default'];
+ exports.moduleForComponent = _emberQunitModuleForComponent['default'];
+ exports.moduleForModel = _emberQunitModuleForModel['default'];
+ exports.setResolver = _emberTestHelpers.setResolver;
+ exports.QUnitAdapter = _emberQunitAdapter['default'];
});
-define('ember-qunit/module-for-component', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/adapter', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
+ 'use strict';
+
+ exports['default'] = _ember['default'].Test.Adapter.extend({
+ init: function init() {
+ this.doneCallbacks = [];
+ },
+
+ asyncStart: function asyncStart() {
+ this.doneCallbacks.push(_qunit['default'].config.current.assert.async());
+ },
+
+ asyncEnd: function asyncEnd() {
+ this.doneCallbacks.pop()();
+ },
+
+ exception: function exception(error) {
+ _qunit['default'].config.current.assert.ok(false, _ember['default'].inspect(error));
+ }
+ });
+});
+define('ember-qunit/module-for-component', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleForComponent(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModuleForComponent, name, description, callbacks);
- }
exports['default'] = moduleForComponent;
+ function moduleForComponent(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModuleForComponent, name, description, callbacks);
+ }
});
-define('ember-qunit/module-for-model', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/module-for-model', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleForModel(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModuleForModel, name, description, callbacks);
- }
exports['default'] = moduleForModel;
+ function moduleForModel(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModuleForModel, name, description, callbacks);
+ }
});
-define('ember-qunit/module-for', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/module-for', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleFor(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModule, name, description, callbacks);
- }
exports['default'] = moduleFor;
-});
-define('ember-qunit/only', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
-
- 'use strict';
-
- function only(/* testName, expected, callback, async */) {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
- args[_key] = arguments[_key];
- }
- args.unshift(qunit.only);
- testWrapper['default'].apply(null, args);
+ function moduleFor(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModule, name, description, callbacks);
}
- exports['default'] = only;
-
});
-define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, qunit) {
-
+define('ember-qunit/qunit-module', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
'use strict';
exports.createModule = createModule;
function beforeEachCallback(callbacks) {
- if (typeof callbacks !== 'object') { return; }
- if (!callbacks) { return; }
+ if (typeof callbacks !== 'object') {
+ return;
+ }
+ if (!callbacks) {
+ return;
+ }
var beforeEach;
- if (callbacks.setup) {
- beforeEach = callbacks.setup;
- delete callbacks.setup;
- }
-
if (callbacks.beforeEach) {
beforeEach = callbacks.beforeEach;
delete callbacks.beforeEach;
@@ -195,16 +196,15 @@ define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, quni
}
function afterEachCallback(callbacks) {
- if (typeof callbacks !== 'object') { return; }
- if (!callbacks) { return; }
+ if (typeof callbacks !== 'object') {
+ return;
+ }
+ if (!callbacks) {
+ return;
+ }
var afterEach;
- if (callbacks.teardown) {
- afterEach = callbacks.teardown;
- delete callbacks.teardown;
- }
-
if (callbacks.afterEach) {
afterEach = callbacks.afterEach;
delete callbacks.afterEach;
@@ -214,129 +214,349 @@ define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, quni
}
function createModule(Constructor, name, description, callbacks) {
- var beforeEach = beforeEachCallback(callbacks || description);
- var afterEach = afterEachCallback(callbacks || description);
+ var _beforeEach = beforeEachCallback(callbacks || description);
+ var _afterEach = afterEachCallback(callbacks || description);
var module = new Constructor(name, description, callbacks);
- qunit.module(module.name, {
- setup: function(assert) {
- var done = assert.async();
- return module.setup().then(function() {
- if (beforeEach) {
- beforeEach.call(module.context, assert);
+ _qunit.module(module.name, {
+ beforeEach: function beforeEach() {
+ var _this = this,
+ _arguments = arguments;
+
+ // provide the test context to the underlying module
+ module.setContext(this);
+
+ return module.setup.apply(module, arguments).then(function () {
+ if (_beforeEach) {
+ return _beforeEach.apply(_this, _arguments);
}
- })['finally'](done);
+ });
},
- teardown: function(assert) {
- if (afterEach) {
- afterEach.call(module.context, assert);
+ afterEach: function afterEach() {
+ var _arguments2 = arguments;
+
+ var result = undefined;
+
+ if (_afterEach) {
+ result = _afterEach.apply(this, arguments);
}
- var done = assert.async();
- return module.teardown()['finally'](done);
+
+ return _ember['default'].RSVP.resolve(result).then(function () {
+ return module.teardown.apply(module, _arguments2);
+ });
}
});
}
-
});
-define('ember-qunit/test-wrapper', ['exports', 'ember', 'ember-test-helpers'], function (exports, Ember, ember_test_helpers) {
-
+define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-acceptance', 'ember-test-helpers/test-module-for-integration', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, _ember, _emberTestHelpersTestModule, _emberTestHelpersTestModuleForAcceptance, _emberTestHelpersTestModuleForIntegration, _emberTestHelpersTestModuleForComponent, _emberTestHelpersTestModuleForModel, _emberTestHelpersTestContext, _emberTestHelpersTestResolver) {
'use strict';
- function testWrapper(qunit /*, testName, expected, callback, async */) {
- var callback;
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; ++_key) {
- args[_key - 1] = arguments[_key];
+ _ember['default'].testing = true;
+
+ exports.TestModule = _emberTestHelpersTestModule['default'];
+ exports.TestModuleForAcceptance = _emberTestHelpersTestModuleForAcceptance['default'];
+ exports.TestModuleForIntegration = _emberTestHelpersTestModuleForIntegration['default'];
+ exports.TestModuleForComponent = _emberTestHelpersTestModuleForComponent['default'];
+ exports.TestModuleForModel = _emberTestHelpersTestModuleForModel['default'];
+ exports.getContext = _emberTestHelpersTestContext.getContext;
+ exports.setContext = _emberTestHelpersTestContext.setContext;
+ exports.unsetContext = _emberTestHelpersTestContext.unsetContext;
+ exports.setResolver = _emberTestHelpersTestResolver.setResolver;
+});
+define('ember-test-helpers/-legacy-overrides', ['exports', 'ember', './has-ember-version'], function (exports, _ember, _hasEmberVersion) {
+ 'use strict';
+
+ exports.preGlimmerSetupIntegrationForComponent = preGlimmerSetupIntegrationForComponent;
+
+ function preGlimmerSetupIntegrationForComponent() {
+ var module = this;
+ var context = this.context;
+
+ this.actionHooks = {};
+
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
+ context.dispatcher.setup({}, '#ember-testing');
+ context.actions = module.actionHooks;
+
+ (this.registry || this.container).register('component:-test-holder', _ember['default'].Component.extend());
+
+ context.render = function (template) {
+ // in case `this.render` is called twice, make sure to teardown the first invocation
+ module.teardownComponent();
+
+ if (!template) {
+ throw new Error("in a component integration test you must pass a template to `render()`");
+ }
+ if (_ember['default'].isArray(template)) {
+ template = template.join('');
+ }
+ if (typeof template === 'string') {
+ template = _ember['default'].Handlebars.compile(template);
+ }
+ module.component = module.container.lookupFactory('component:-test-holder').create({
+ layout: template
+ });
+
+ module.component.set('context', context);
+ module.component.set('controller', context);
+
+ _ember['default'].run(function () {
+ module.component.appendTo('#ember-testing');
+ });
+
+ context._element = module.component.element;
+ };
+
+ context.$ = function () {
+ return module.component.$.apply(module.component, arguments);
+ };
+
+ context.set = function (key, value) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].set(context, key, value);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.setProperties = function (hash) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].setProperties(context, hash);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.get = function (key) {
+ return _ember['default'].get(context, key);
+ };
+
+ context.getProperties = function () {
+ var args = Array.prototype.slice.call(arguments);
+ return _ember['default'].getProperties(context, args);
+ };
+
+ context.on = function (actionName, handler) {
+ module.actionHooks[actionName] = handler;
+ };
+
+ context.send = function (actionName) {
+ var hook = module.actionHooks[actionName];
+ if (!hook) {
+ throw new Error("integration testing template received unexpected action " + actionName);
+ }
+ hook.apply(module, Array.prototype.slice.call(arguments, 1));
+ };
+
+ context.clearRender = function () {
+ module.teardownComponent();
+ };
+ }
+});
+define('ember-test-helpers/abstract-test-module', ['exports', './wait', './test-context', 'ember'], function (exports, _wait, _testContext, _ember) {
+ 'use strict';
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ // calling this `merge` here because we cannot
+ // actually assume it is like `Object.assign`
+ // with > 2 args
+ var merge = _ember['default'].assign || _ember['default'].merge;
+
+ var _default = (function () {
+ function _default(name, options) {
+ _classCallCheck(this, _default);
+
+ this.context = undefined;
+ this.name = name;
+ this.callbacks = options || {};
+
+ this.initSetupSteps();
+ this.initTeardownSteps();
}
- function wrapper() {
- var context = ember_test_helpers.getContext();
+ _default.prototype.setup = function setup(assert) {
+ var _this = this;
- var result = callback.apply(context, arguments);
+ return this.invokeSteps(this.setupSteps, this, assert).then(function () {
+ _this.contextualizeCallbacks();
+ return _this.invokeSteps(_this.contextualizedSetupSteps, _this.context, assert);
+ });
+ };
- function failTestOnPromiseRejection(reason) {
- var message;
- if (reason instanceof Error) {
- message = reason.stack;
- if (reason.message && message.indexOf(reason.message) < 0) {
- // PhantomJS has a `stack` that does not contain the actual
- // exception message.
- message = Ember['default'].inspect(reason) + "\n" + message;
- }
- } else {
- message = Ember['default'].inspect(reason);
- }
- ok(false, message);
+ _default.prototype.teardown = function teardown(assert) {
+ var _this2 = this;
+
+ return this.invokeSteps(this.contextualizedTeardownSteps, this.context, assert).then(function () {
+ return _this2.invokeSteps(_this2.teardownSteps, _this2, assert);
+ }).then(function () {
+ _this2.cache = null;
+ _this2.cachedCalls = null;
+ });
+ };
+
+ _default.prototype.initSetupSteps = function initSetupSteps() {
+ this.setupSteps = [];
+ this.contextualizedSetupSteps = [];
+
+ if (this.callbacks.beforeSetup) {
+ this.setupSteps.push(this.callbacks.beforeSetup);
+ delete this.callbacks.beforeSetup;
}
- Ember['default'].run(function(){
- QUnit.stop();
- Ember['default'].RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start);
+ this.setupSteps.push(this.setupContext);
+ this.setupSteps.push(this.setupTestElements);
+ this.setupSteps.push(this.setupAJAXListeners);
+
+ if (this.callbacks.setup) {
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
+ delete this.callbacks.setup;
+ }
+ };
+
+ _default.prototype.invokeSteps = function invokeSteps(steps, context, assert) {
+ steps = steps.slice();
+
+ function nextStep() {
+ var step = steps.shift();
+ if (step) {
+ // guard against exceptions, for example missing components referenced from needs.
+ return new _ember['default'].RSVP.Promise(function (resolve) {
+ resolve(step.call(context, assert));
+ }).then(nextStep);
+ } else {
+ return _ember['default'].RSVP.resolve();
+ }
+ }
+ return nextStep();
+ };
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {};
+
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
+ this.teardownSteps = [];
+ this.contextualizedTeardownSteps = [];
+
+ if (this.callbacks.teardown) {
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
+ delete this.callbacks.teardown;
+ }
+
+ this.teardownSteps.push(this.teardownContext);
+ this.teardownSteps.push(this.teardownTestElements);
+ this.teardownSteps.push(this.teardownAJAXListeners);
+
+ if (this.callbacks.afterTeardown) {
+ this.teardownSteps.push(this.callbacks.afterTeardown);
+ delete this.callbacks.afterTeardown;
+ }
+ };
+
+ _default.prototype.setupTestElements = function setupTestElements() {
+ var testEl = document.querySelector('#ember-testing');
+ if (!testEl) {
+ var element = document.createElement('div');
+ element.setAttribute('id', 'ember-testing');
+
+ document.body.appendChild(element);
+ this.fixtureResetValue = '';
+ } else {
+ this.fixtureResetValue = testEl.innerHTML;
+ }
+ };
+
+ _default.prototype.setupContext = function setupContext(options) {
+ var context = this.getContext();
+
+ merge(context, {
+ dispatcher: null,
+ inject: {}
});
- }
+ merge(context, options);
- if (args.length === 2) {
- callback = args.splice(1, 1, wrapper)[0];
- } else {
- callback = args.splice(2, 1, wrapper)[0];
- }
+ this.setToString();
+ _testContext.setContext(context);
+ this.context = context;
+ };
- qunit.apply(null, args);
- }
- exports['default'] = testWrapper;
+ _default.prototype.setContext = function setContext(context) {
+ this.context = context;
+ };
+ _default.prototype.getContext = function getContext() {
+ if (this.context) {
+ return this.context;
+ }
+
+ return this.context = _testContext.getContext() || {};
+ };
+
+ _default.prototype.setToString = function setToString() {
+ var _this3 = this;
+
+ this.context.toString = function () {
+ if (_this3.subjectName) {
+ return 'test context for: ' + _this3.subjectName;
+ }
+
+ if (_this3.name) {
+ return 'test context for: ' + _this3.name;
+ }
+ };
+ };
+
+ _default.prototype.setupAJAXListeners = function setupAJAXListeners() {
+ _wait._setupAJAXHooks();
+ };
+
+ _default.prototype.teardownAJAXListeners = function teardownAJAXListeners() {
+ _wait._teardownAJAXHooks();
+ };
+
+ _default.prototype.teardownTestElements = function teardownTestElements() {
+ document.getElementById('ember-testing').innerHTML = this.fixtureResetValue;
+
+ // Ember 2.0.0 removed Ember.View as public API, so only do this when
+ // Ember.View is present
+ if (_ember['default'].View && _ember['default'].View.views) {
+ _ember['default'].View.views = {};
+ }
+ };
+
+ _default.prototype.teardownContext = function teardownContext() {
+ var context = this.context;
+ this.context = undefined;
+ _testContext.unsetContext();
+
+ if (context && context.dispatcher && !context.dispatcher.isDestroyed) {
+ _ember['default'].run(function () {
+ context.dispatcher.destroy();
+ });
+ }
+ };
+
+ return _default;
+ })();
+
+ exports['default'] = _default;
});
-define('ember-qunit/test', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
-
- 'use strict';
-
- function test(/* testName, expected, callback, async */) {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
- args[_key] = arguments[_key];
- }
- args.unshift(qunit.test);
- testWrapper['default'].apply(null, args);
- }
- exports['default'] = test;
-
-});
-define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, Ember, TestModule, TestModuleForComponent, TestModuleForModel, test_context, test_resolver) {
-
- 'use strict';
-
- Ember['default'].testing = true;
-
- exports.TestModule = TestModule['default'];
- exports.TestModuleForComponent = TestModuleForComponent['default'];
- exports.TestModuleForModel = TestModuleForModel['default'];
- exports.getContext = test_context.getContext;
- exports.setContext = test_context.setContext;
- exports.setResolver = test_resolver.setResolver;
-
-});
-define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, Ember) {
+define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, _ember) {
+ /* globals global, self, requirejs, require */
'use strict';
function exposeRegistryMethodsWithoutDeprecations(container) {
- var methods = [
- 'register',
- 'unregister',
- 'resolve',
- 'normalize',
- 'typeInjection',
- 'injection',
- 'factoryInjection',
- 'factoryTypeInjection',
- 'has',
- 'options',
- 'optionsForType'
- ];
+ var methods = ['register', 'unregister', 'resolve', 'normalize', 'typeInjection', 'injection', 'factoryInjection', 'factoryTypeInjection', 'has', 'options', 'optionsForType'];
function exposeRegistryMethod(container, method) {
if (method in container) {
- container[method] = function() {
+ container[method] = function () {
return container._registry[method].apply(container._registry, arguments);
};
}
@@ -347,18 +567,20 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
}
}
- var Owner = (function() {
- if (Ember['default']._RegistryProxyMixin && Ember['default']._ContainerProxyMixin) {
- return Ember['default'].Object.extend(Ember['default']._RegistryProxyMixin, Ember['default']._ContainerProxyMixin);
+ var Owner = (function () {
+ if (_ember['default']._RegistryProxyMixin && _ember['default']._ContainerProxyMixin) {
+ return _ember['default'].Object.extend(_ember['default']._RegistryProxyMixin, _ember['default']._ContainerProxyMixin);
}
- return Ember['default'].Object.extend();
+ return _ember['default'].Object.extend();
})();
- exports['default'] = function(resolver) {
+ exports['default'] = function (resolver) {
var fallbackRegistry, registry, container;
- var namespace = Ember['default'].Object.create({
- Resolver: { create: function() { return resolver; } }
+ var namespace = _ember['default'].Object.create({
+ Resolver: { create: function create() {
+ return resolver;
+ } }
});
function register(name, factory) {
@@ -369,14 +591,18 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
}
}
- if (Ember['default'].Application.buildRegistry) {
- fallbackRegistry = Ember['default'].Application.buildRegistry(namespace);
- fallbackRegistry.register('component-lookup:main', Ember['default'].ComponentLookup);
+ if (_ember['default'].Application.buildRegistry) {
+ fallbackRegistry = _ember['default'].Application.buildRegistry(namespace);
+ fallbackRegistry.register('component-lookup:main', _ember['default'].ComponentLookup);
- registry = new Ember['default'].Registry({
+ registry = new _ember['default'].Registry({
fallback: fallbackRegistry
});
+ if (_ember['default'].ApplicationInstance && _ember['default'].ApplicationInstance.setupRegistry) {
+ _ember['default'].ApplicationInstance.setupRegistry(registry);
+ }
+
// these properties are set on the fallback registry by `buildRegistry`
// and on the primary registry within the ApplicationInstance constructor
// but we need to manually recreate them since ApplicationInstance's are not
@@ -395,8 +621,8 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
exposeRegistryMethodsWithoutDeprecations(container);
} else {
- container = Ember['default'].Application.buildContainer(namespace);
- container.register('component-lookup:main', Ember['default'].ComponentLookup);
+ container = _ember['default'].Application.buildContainer(namespace);
+ container.register('component-lookup:main', _ember['default'].ComponentLookup);
}
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
@@ -404,18 +630,26 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
//
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
- if (Ember['default'].View) {
- register('view:toplevel', Ember['default'].View.extend());
+ if (_ember['default'].View) {
+ register('view:toplevel', _ember['default'].View.extend());
}
// Ember 2.0.0 removed Ember._MetamorphView from the Ember global, so only
// do this when present
- if (Ember['default']._MetamorphView) {
- register('view:default', Ember['default']._MetamorphView);
+ if (_ember['default']._MetamorphView) {
+ register('view:default', _ember['default']._MetamorphView);
}
var globalContext = typeof global === 'object' && global || self;
- if (globalContext.DS) {
+ if (requirejs.entries['ember-data/setup-container']) {
+ // ember-data is a proper ember-cli addon since 2.3; if no 'import
+ // 'ember-data'' is present somewhere in the tests, there is also no `DS`
+ // available on the globalContext and hence ember-data wouldn't be setup
+ // correctly for the tests; that's why we import and call setupContainer
+ // here; also see https://github.com/emberjs/data/issues/4071 for context
+ var setupContainer = require('ember-data/setup-container')['default'];
+ setupContainer(registry || container);
+ } else if (globalContext.DS) {
var DS = globalContext.DS;
if (DS._setupContainer) {
DS._setupContainer(registry || container);
@@ -434,30 +668,26 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
registry: registry,
container: container
};
- }
-
+ };
});
-define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, Ember) {
-
+define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, _ember) {
'use strict';
- function hasEmberVersion(major, minor) {
- var numbers = Ember['default'].VERSION.split('-')[0].split('.');
- var actualMajor = parseInt(numbers[0], 10);
- var actualMinor = parseInt(numbers[1], 10);
- return actualMajor > major || (actualMajor === major && actualMinor >= minor);
- }
exports['default'] = hasEmberVersion;
+ function hasEmberVersion(major, minor) {
+ var numbers = _ember['default'].VERSION.split('-')[0].split('.');
+ var actualMajor = parseInt(numbers[0], 10);
+ var actualMinor = parseInt(numbers[1], 10);
+ return actualMajor > major || actualMajor === major && actualMinor >= minor;
+ }
});
-define('ember-test-helpers/test-context', ['exports'], function (exports) {
-
- 'use strict';
+define("ember-test-helpers/test-context", ["exports"], function (exports) {
+ "use strict";
exports.setContext = setContext;
exports.getContext = getContext;
exports.unsetContext = unsetContext;
-
var __test_context__;
function setContext(context) {
@@ -471,16 +701,82 @@ define('ember-test-helpers/test-context', ['exports'], function (exports) {
function unsetContext() {
__test_context__ = undefined;
}
-
});
-define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-helpers/test-module', 'ember', 'ember-test-helpers/test-resolver'], function (exports, TestModule, Ember, test_resolver) {
-
+define('ember-test-helpers/test-module-for-acceptance', ['exports', './abstract-test-module', 'ember', './test-context'], function (exports, _abstractTestModule, _ember, _testContext) {
'use strict';
- exports['default'] = TestModule['default'].extend({
- isComponentTestModule: true,
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default() {
+ _classCallCheck(this, _default);
+
+ _AbstractTestModule.apply(this, arguments);
+ }
+
+ _default.prototype.setupContext = function setupContext() {
+ _AbstractTestModule.prototype.setupContext.call(this, { application: this.createApplication() });
+ };
+
+ _default.prototype.teardownContext = function teardownContext() {
+ _ember['default'].run(function () {
+ _testContext.getContext().application.destroy();
+ });
+
+ _AbstractTestModule.prototype.teardownContext.call(this);
+ };
+
+ _default.prototype.createApplication = function createApplication() {
+ var _callbacks = this.callbacks;
+ var Application = _callbacks.Application;
+ var config = _callbacks.config;
+
+ var application = undefined;
+
+ _ember['default'].run(function () {
+ application = Application.create(config);
+ application.setupForTesting();
+ application.injectTestHelpers();
+ });
+
+ return application;
+ };
+
+ return _default;
+ })(_abstractTestModule['default']);
+
+ exports['default'] = _default;
+});
+define('ember-test-helpers/test-module-for-component', ['exports', './test-module', 'ember', './has-ember-version', './-legacy-overrides'], function (exports, _testModule, _ember, _hasEmberVersion, _legacyOverrides) {
+ 'use strict';
+
+ exports.setupComponentIntegrationTest = _setupComponentIntegrationTest;
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var ACTION_KEY = undefined;
+ if (_hasEmberVersion['default'](2, 0)) {
+ ACTION_KEY = 'actions';
+ } else {
+ ACTION_KEY = '_actions';
+ }
+
+ var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
+
+ var getOwner = _ember['default'].getOwner;
+
+ var _default = (function (_TestModule) {
+ _inherits(_default, _TestModule);
+
+ function _default(componentName, description, callbacks) {
+ _classCallCheck(this, _default);
- init: function(componentName, description, callbacks) {
// Allow `description` to be omitted
if (!callbacks && typeof description === 'object') {
callbacks = description;
@@ -489,30 +785,21 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
callbacks = {};
}
+ var integrationOption = callbacks.integration;
+
+ _TestModule.call(this, 'component:' + componentName, description, callbacks);
+
this.componentName = componentName;
- if (callbacks.needs || callbacks.unit || callbacks.integration === false) {
+ if (callbacks.needs || callbacks.unit || integrationOption === false) {
this.isUnitTest = true;
- } else if (callbacks.integration) {
+ } else if (integrationOption) {
this.isUnitTest = false;
} else {
- Ember['default'].deprecate(
- "the component:" + componentName + " test module is implicitly running in unit test mode, " +
- "which will change to integration test mode by default in an upcoming version of " +
- "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " +
- "test mode.",
- false,
- { id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' }
- );
+ _ember['default'].deprecate("the component:" + componentName + " test module is implicitly running in unit test mode, " + "which will change to integration test mode by default in an upcoming version of " + "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " + "test mode.", false, { id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' });
this.isUnitTest = true;
}
- if (description) {
- this._super.call(this, 'component:' + componentName, description, callbacks);
- } else {
- this._super.call(this, 'component:' + componentName, callbacks);
- }
-
if (!this.isUnitTest && !this.isLegacy) {
callbacks.integration = true;
}
@@ -520,35 +807,40 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
if (this.isUnitTest || this.isLegacy) {
this.setupSteps.push(this.setupComponentUnitTest);
} else {
- this.callbacks.subject = function() {
- throw new Error("component integration tests do not support `subject()`.");
+ this.callbacks.subject = function () {
+ throw new Error("component integration tests do not support `subject()`. Instead, render the component as if it were HTML: `this.render('
');`. For more information, read: http://guides.emberjs.com/v2.2.0/testing/testing-components/");
};
this.setupSteps.push(this.setupComponentIntegrationTest);
this.teardownSteps.unshift(this.teardownComponent);
}
- if (Ember['default'].View && Ember['default'].View.views) {
+ if (_ember['default'].View && _ember['default'].View.views) {
this.setupSteps.push(this._aliasViewRegistry);
this.teardownSteps.unshift(this._resetViewRegistry);
}
- },
+ }
- _aliasViewRegistry: function() {
- this._originalGlobalViewRegistry = Ember['default'].View.views;
+ _default.prototype.initIntegration = function initIntegration(options) {
+ this.isLegacy = options.integration === 'legacy';
+ this.isIntegration = options.integration !== 'legacy';
+ };
+
+ _default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
+ this._originalGlobalViewRegistry = _ember['default'].View.views;
var viewRegistry = this.container.lookup('-view-registry:main');
if (viewRegistry) {
- Ember['default'].View.views = viewRegistry;
+ _ember['default'].View.views = viewRegistry;
}
- },
+ };
- _resetViewRegistry: function() {
- Ember['default'].View.views = this._originalGlobalViewRegistry;
- },
+ _default.prototype._resetViewRegistry = function _resetViewRegistry() {
+ _ember['default'].View.views = this._originalGlobalViewRegistry;
+ };
- setupComponentUnitTest: function() {
+ _default.prototype.setupComponentUnitTest = function setupComponentUnitTest() {
var _this = this;
- var resolver = test_resolver.getResolver();
+ var resolver = this.resolver;
var context = this.context;
var layoutName = 'template:components/' + this.componentName;
@@ -561,114 +853,51 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
thingToRegisterWith.injection(this.subjectName, 'layout', layoutName);
}
- context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
- this.callbacks.render = function() {
+ context._element = null;
+
+ this.callbacks.render = function () {
var subject;
- Ember['default'].run(function(){
+ _ember['default'].run(function () {
subject = context.subject();
subject.appendTo('#ember-testing');
});
- _this.teardownSteps.unshift(function() {
- Ember['default'].run(function() {
- Ember['default'].tryInvoke(subject, 'destroy');
+ context._element = subject.element;
+
+ _this.teardownSteps.unshift(function () {
+ _ember['default'].run(function () {
+ _ember['default'].tryInvoke(subject, 'destroy');
});
});
};
- this.callbacks.append = function() {
- Ember['default'].deprecate(
- 'this.append() is deprecated. Please use this.render() or this.$() instead.',
- false,
- { id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' }
- );
+ this.callbacks.append = function () {
+ _ember['default'].deprecate('this.append() is deprecated. Please use this.render() or this.$() instead.', false, { id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' });
return context.$();
};
- context.$ = function() {
+ context.$ = function () {
this.render();
var subject = this.subject();
return subject.$.apply(subject, arguments);
};
- },
+ };
- setupComponentIntegrationTest: function() {
- var module = this;
- var context = this.context;
+ _default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
+ if (isPreGlimmer) {
+ return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
+ } else {
+ return _setupComponentIntegrationTest.apply(this, arguments);
+ }
+ };
- this.actionHooks = {};
-
- context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
- context.dispatcher.setup({}, '#ember-testing');
- context.actions = module.actionHooks;
-
- (this.registry || this.container).register('component:-test-holder', Ember['default'].Component.extend());
-
- context.render = function(template) {
- if (!template) {
- throw new Error("in a component integration test you must pass a template to `render()`");
- }
- if (Ember['default'].isArray(template)) {
- template = template.join('');
- }
- if (typeof template === 'string') {
- template = Ember['default'].Handlebars.compile(template);
- }
- module.component = module.container.lookupFactory('component:-test-holder').create({
- layout: template
- });
-
- module.component.set('context' ,context);
- module.component.set('controller', context);
-
- Ember['default'].run(function() {
- module.component.appendTo('#ember-testing');
- });
- };
-
- context.$ = function() {
- return module.component.$.apply(module.component, arguments);
- };
-
- context.set = function(key, value) {
- Ember['default'].run(function() {
- Ember['default'].set(context, key, value);
- });
- };
-
- context.setProperties = function(hash) {
- Ember['default'].run(function() {
- Ember['default'].setProperties(context, hash);
- });
- };
-
- context.get = function(key) {
- return Ember['default'].get(context, key);
- };
-
- context.getProperties = function() {
- var args = Array.prototype.slice.call(arguments);
- return Ember['default'].getProperties(context, args);
- };
-
- context.on = function(actionName, handler) {
- module.actionHooks[actionName] = handler;
- };
- context.send = function(actionName) {
- var hook = module.actionHooks[actionName];
- if (!hook) {
- throw new Error("integration testing template received unexpected action " + actionName);
- }
- hook.apply(module, Array.prototype.slice.call(arguments, 1));
- };
- },
-
- setupContext: function() {
- this._super.call(this);
+ _default.prototype.setupContext = function setupContext() {
+ _TestModule.prototype.setupContext.call(this);
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
@@ -677,35 +906,409 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
}
if (!this.isUnitTest && !this.isLegacy) {
- this.context.factory = function() {};
+ this.context.factory = function () {};
}
- },
+ };
- teardownComponent: function() {
+ _default.prototype.teardownComponent = function teardownComponent() {
var component = this.component;
if (component) {
- Ember['default'].run(function() {
+ _ember['default'].run(component, 'destroy');
+ this.component = null;
+ }
+ };
+
+ return _default;
+ })(_testModule['default']);
+
+ exports['default'] = _default;
+
+ function _setupComponentIntegrationTest() {
+ var module = this;
+ var context = this.context;
+
+ this.actionHooks = context[ACTION_KEY] = {};
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
+ context.dispatcher.setup({}, '#ember-testing');
+
+ var hasRendered = false;
+ var OutletView = module.container.lookupFactory('view:-outlet');
+ var OutletTemplate = module.container.lookup('template:-outlet');
+ var toplevelView = module.component = OutletView.create();
+ var hasOutletTemplate = !!OutletTemplate;
+ var outletState = {
+ render: {
+ owner: getOwner ? getOwner(module.container) : undefined,
+ into: undefined,
+ outlet: 'main',
+ name: 'application',
+ controller: module.context,
+ ViewClass: undefined,
+ template: OutletTemplate
+ },
+
+ outlets: {}
+ };
+
+ var element = document.getElementById('ember-testing');
+ var templateId = 0;
+
+ if (hasOutletTemplate) {
+ _ember['default'].run(function () {
+ toplevelView.setOutletState(outletState);
+ });
+ }
+
+ context.render = function (template) {
+ if (!template) {
+ throw new Error("in a component integration test you must pass a template to `render()`");
+ }
+ if (_ember['default'].isArray(template)) {
+ template = template.join('');
+ }
+ if (typeof template === 'string') {
+ template = _ember['default'].Handlebars.compile(template);
+ }
+
+ var templateFullName = 'template:-undertest-' + ++templateId;
+ this.registry.register(templateFullName, template);
+ var stateToRender = {
+ owner: getOwner ? getOwner(module.container) : undefined,
+ into: undefined,
+ outlet: 'main',
+ name: 'index',
+ controller: module.context,
+ ViewClass: undefined,
+ template: module.container.lookup(templateFullName),
+ outlets: {}
+ };
+
+ if (hasOutletTemplate) {
+ stateToRender.name = 'index';
+ outletState.outlets.main = { render: stateToRender, outlets: {} };
+ } else {
+ stateToRender.name = 'application';
+ outletState = { render: stateToRender, outlets: {} };
+ }
+
+ _ember['default'].run(function () {
+ toplevelView.setOutletState(outletState);
+ });
+
+ if (!hasRendered) {
+ _ember['default'].run(module.component, 'appendTo', '#ember-testing');
+ hasRendered = true;
+ }
+
+ // ensure the element is based on the wrapping toplevel view
+ // Ember still wraps the main application template with a
+ // normal tagged view
+ context._element = element = document.querySelector('#ember-testing > .ember-view');
+ };
+
+ context.$ = function (selector) {
+ // emulates Ember internal behavor of `this.$` in a component
+ // https://github.com/emberjs/ember.js/blob/v2.5.1/packages/ember-views/lib/views/states/has_element.js#L18
+ return selector ? _ember['default'].$(selector, element) : _ember['default'].$(element);
+ };
+
+ context.set = function (key, value) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].set(context, key, value);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.setProperties = function (hash) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].setProperties(context, hash);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.get = function (key) {
+ return _ember['default'].get(context, key);
+ };
+
+ context.getProperties = function () {
+ var args = Array.prototype.slice.call(arguments);
+ return _ember['default'].getProperties(context, args);
+ };
+
+ context.on = function (actionName, handler) {
+ module.actionHooks[actionName] = handler;
+ };
+
+ context.send = function (actionName) {
+ var hook = module.actionHooks[actionName];
+ if (!hook) {
+ throw new Error("integration testing template received unexpected action " + actionName);
+ }
+ hook.apply(module.context, Array.prototype.slice.call(arguments, 1));
+ };
+
+ context.clearRender = function () {
+ _ember['default'].run(function () {
+ toplevelView.setOutletState({
+ render: {
+ owner: module.container,
+ into: undefined,
+ outlet: 'main',
+ name: 'application',
+ controller: module.context,
+ ViewClass: undefined,
+ template: undefined
+ },
+ outlets: {}
+ });
+ });
+ };
+ }
+});
+define('ember-test-helpers/test-module-for-integration', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version', './-legacy-overrides', './test-module-for-component'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion, _legacyOverrides, _testModuleForComponent) {
+ 'use strict';
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var ACTION_KEY = undefined;
+ if (_hasEmberVersion['default'](2, 0)) {
+ ACTION_KEY = 'actions';
+ } else {
+ ACTION_KEY = '_actions';
+ }
+
+ var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default() {
+ _classCallCheck(this, _default);
+
+ _AbstractTestModule.apply(this, arguments);
+ this.resolver = this.callbacks.resolver || _testResolver.getResolver();
+ }
+
+ _default.prototype.initSetupSteps = function initSetupSteps() {
+ this.setupSteps = [];
+ this.contextualizedSetupSteps = [];
+
+ if (this.callbacks.beforeSetup) {
+ this.setupSteps.push(this.callbacks.beforeSetup);
+ delete this.callbacks.beforeSetup;
+ }
+
+ this.setupSteps.push(this.setupContainer);
+ this.setupSteps.push(this.setupContext);
+ this.setupSteps.push(this.setupTestElements);
+ this.setupSteps.push(this.setupAJAXListeners);
+ this.setupSteps.push(this.setupComponentIntegrationTest);
+
+ if (_ember['default'].View && _ember['default'].View.views) {
+ this.setupSteps.push(this._aliasViewRegistry);
+ }
+
+ if (this.callbacks.setup) {
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
+ delete this.callbacks.setup;
+ }
+ };
+
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
+ this.teardownSteps = [];
+ this.contextualizedTeardownSteps = [];
+
+ if (this.callbacks.teardown) {
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
+ delete this.callbacks.teardown;
+ }
+
+ this.teardownSteps.push(this.teardownContainer);
+ this.teardownSteps.push(this.teardownContext);
+ this.teardownSteps.push(this.teardownAJAXListeners);
+ this.teardownSteps.push(this.teardownComponent);
+
+ if (_ember['default'].View && _ember['default'].View.views) {
+ this.teardownSteps.push(this._resetViewRegistry);
+ }
+
+ this.teardownSteps.push(this.teardownTestElements);
+
+ if (this.callbacks.afterTeardown) {
+ this.teardownSteps.push(this.callbacks.afterTeardown);
+ delete this.callbacks.afterTeardown;
+ }
+ };
+
+ _default.prototype.setupContainer = function setupContainer() {
+ var resolver = this.resolver;
+ var items = _buildRegistry['default'](resolver);
+
+ this.container = items.container;
+ this.registry = items.registry;
+
+ if (_hasEmberVersion['default'](1, 13)) {
+ var thingToRegisterWith = this.registry || this.container;
+ var router = resolver.resolve('router:main');
+ router = router || _ember['default'].Router.extend();
+ thingToRegisterWith.register('router:main', router);
+ }
+ };
+
+ _default.prototype.setupContext = function setupContext() {
+ var subjectName = this.subjectName;
+ var container = this.container;
+
+ var factory = function factory() {
+ return container.lookupFactory(subjectName);
+ };
+
+ _AbstractTestModule.prototype.setupContext.call(this, {
+ container: this.container,
+ registry: this.registry,
+ factory: factory,
+ register: function register() {
+ var target = this.registry || this.container;
+ return target.register.apply(target, arguments);
+ }
+ });
+
+ var context = this.context;
+
+ if (_ember['default'].setOwner) {
+ _ember['default'].setOwner(context, this.container.owner);
+ }
+
+ if (_ember['default'].inject) {
+ var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
+ keys.forEach(function (typeName) {
+ context.inject[typeName] = function (name, opts) {
+ var alias = opts && opts.as || name;
+ _ember['default'].run(function () {
+ _ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
+ });
+ };
+ });
+ }
+
+ // only setup the injection if we are running against a version
+ // of Ember that has `-view-registry:main` (Ember >= 1.12)
+ if (this.container.lookupFactory('-view-registry:main')) {
+ (this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
+ }
+ };
+
+ _default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
+ if (isPreGlimmer) {
+ return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
+ } else {
+ return _testModuleForComponent.setupComponentIntegrationTest.apply(this, arguments);
+ }
+ };
+
+ _default.prototype.teardownComponent = function teardownComponent() {
+ var component = this.component;
+ if (component) {
+ _ember['default'].run(function () {
component.destroy();
});
}
- }
- });
+ };
+ _default.prototype.teardownContainer = function teardownContainer() {
+ var container = this.container;
+ _ember['default'].run(function () {
+ container.destroy();
+ });
+ };
+
+ // allow arbitrary named factories, like rspec let
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
+ var callbacks = this.callbacks;
+ var context = this.context;
+
+ this.cache = this.cache || {};
+ this.cachedCalls = this.cachedCalls || {};
+
+ var keys = (Object.keys || _ember['default'].keys)(callbacks);
+ var keysLength = keys.length;
+
+ if (keysLength) {
+ for (var i = 0; i < keysLength; i++) {
+ this._contextualizeCallback(context, keys[i], context);
+ }
+ }
+ };
+
+ _default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
+ var _this = this;
+ var callbacks = this.callbacks;
+ var factory = context.factory;
+
+ context[key] = function (options) {
+ if (_this.cachedCalls[key]) {
+ return _this.cache[key];
+ }
+
+ var result = callbacks[key].call(callbackContext, options, factory());
+
+ _this.cache[key] = result;
+ _this.cachedCalls[key] = true;
+
+ return result;
+ };
+ };
+
+ _default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
+ this._originalGlobalViewRegistry = _ember['default'].View.views;
+ var viewRegistry = this.container.lookup('-view-registry:main');
+
+ if (viewRegistry) {
+ _ember['default'].View.views = viewRegistry;
+ }
+ };
+
+ _default.prototype._resetViewRegistry = function _resetViewRegistry() {
+ _ember['default'].View.views = this._originalGlobalViewRegistry;
+ };
+
+ return _default;
+ })(_abstractTestModule['default']);
+
+ exports['default'] = _default;
});
-define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpers/test-module', 'ember'], function (exports, TestModule, Ember) {
+define('ember-test-helpers/test-module-for-model', ['exports', './test-module', 'ember'], function (exports, _testModule, _ember) {
+ /* global DS, require, requirejs */ // added here to prevent an import from erroring when ED is not present
'use strict';
- exports['default'] = TestModule['default'].extend({
- init: function(modelName, description, callbacks) {
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_TestModule) {
+ _inherits(_default, _TestModule);
+
+ function _default(modelName, description, callbacks) {
+ _classCallCheck(this, _default);
+
+ _TestModule.call(this, 'model:' + modelName, description, callbacks);
+
this.modelName = modelName;
- this._super.call(this, 'model:' + modelName, description, callbacks);
-
this.setupSteps.push(this.setupModel);
- },
+ }
- setupModel: function() {
+ _default.prototype.setupModel = function setupModel() {
var container = this.container;
var defaultSubject = this.defaultSubject;
var callbacks = this.callbacks;
@@ -713,38 +1316,57 @@ define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpe
var adapterFactory = container.lookupFactory('adapter:application');
if (!adapterFactory) {
- adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
+ if (requirejs.entries['ember-data/adapters/json-api']) {
+ adapterFactory = require('ember-data/adapters/json-api')['default'];
+ }
+
+ // when ember-data/adapters/json-api is provided via ember-cli shims
+ // using Ember Data 1.x the actual JSONAPIAdapter isn't found, but the
+ // above require statement returns a bizzaro object with only a `default`
+ // property (circular reference actually)
+ if (!adapterFactory || !adapterFactory.create) {
+ adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
+ }
var thingToRegisterWith = this.registry || this.container;
thingToRegisterWith.register('adapter:application', adapterFactory);
}
- callbacks.store = function(){
+ callbacks.store = function () {
var container = this.container;
- var store = container.lookup('service:store') || container.lookup('store:main');
- return store;
+ return container.lookup('service:store') || container.lookup('store:main');
};
if (callbacks.subject === defaultSubject) {
- callbacks.subject = function(options) {
+ callbacks.subject = function (options) {
var container = this.container;
- return Ember['default'].run(function() {
+ return _ember['default'].run(function () {
var store = container.lookup('service:store') || container.lookup('store:main');
return store.createRecord(modelName, options);
});
};
}
- }
- });
+ };
+ return _default;
+ })(_testModule['default']);
+
+ exports['default'] = _default;
});
-define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helpers/test-context', 'klassy', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version', 'ember-test-helpers/wait'], function (exports, Ember, test_context, klassy, test_resolver, buildRegistry, hasEmberVersion, wait) {
-
+define('ember-test-helpers/test-module', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion) {
'use strict';
- exports['default'] = klassy.Klass.extend({
- init: function(subjectName, description, callbacks) {
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default(subjectName, description, callbacks) {
+ _classCallCheck(this, _default);
+
// Allow `description` to be omitted, in which case it should
// default to `subjectName`
if (!callbacks && typeof description === 'object') {
@@ -752,53 +1374,50 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
description = subjectName;
}
+ _AbstractTestModule.call(this, description || subjectName, callbacks);
+
this.subjectName = subjectName;
this.description = description || subjectName;
- this.name = description || subjectName;
- this.callbacks = callbacks || {};
+ this.resolver = this.callbacks.resolver || _testResolver.getResolver();
if (this.callbacks.integration && this.callbacks.needs) {
throw new Error("cannot declare 'integration: true' and 'needs' in the same module");
}
if (this.callbacks.integration) {
- if (this.isComponentTestModule) {
- this.isLegacy = (callbacks.integration === 'legacy');
- this.isIntegration = (callbacks.integration !== 'legacy');
- } else {
- if (callbacks.integration === 'legacy') {
- throw new Error('`integration: \'legacy\'` is only valid for component tests.');
- }
- this.isIntegration = true;
- }
-
+ this.initIntegration(callbacks);
delete callbacks.integration;
}
this.initSubject();
this.initNeeds();
- this.initSetupSteps();
- this.initTeardownSteps();
- },
+ }
- initSubject: function() {
+ _default.prototype.initIntegration = function initIntegration(options) {
+ if (options.integration === 'legacy') {
+ throw new Error('`integration: \'legacy\'` is only valid for component tests.');
+ }
+ this.isIntegration = true;
+ };
+
+ _default.prototype.initSubject = function initSubject() {
this.callbacks.subject = this.callbacks.subject || this.defaultSubject;
- },
+ };
- initNeeds: function() {
+ _default.prototype.initNeeds = function initNeeds() {
this.needs = [this.subjectName];
if (this.callbacks.needs) {
this.needs = this.needs.concat(this.callbacks.needs);
delete this.callbacks.needs;
}
- },
+ };
- initSetupSteps: function() {
+ _default.prototype.initSetupSteps = function initSetupSteps() {
this.setupSteps = [];
this.contextualizedSetupSteps = [];
if (this.callbacks.beforeSetup) {
- this.setupSteps.push( this.callbacks.beforeSetup );
+ this.setupSteps.push(this.callbacks.beforeSetup);
delete this.callbacks.beforeSetup;
}
@@ -808,17 +1427,17 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
this.setupSteps.push(this.setupAJAXListeners);
if (this.callbacks.setup) {
- this.contextualizedSetupSteps.push( this.callbacks.setup );
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
delete this.callbacks.setup;
}
- },
+ };
- initTeardownSteps: function() {
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
this.teardownSteps = [];
this.contextualizedTeardownSteps = [];
if (this.callbacks.teardown) {
- this.contextualizedTeardownSteps.push( this.callbacks.teardown );
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
delete this.callbacks.teardown;
}
@@ -829,203 +1448,176 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
this.teardownSteps.push(this.teardownAJAXListeners);
if (this.callbacks.afterTeardown) {
- this.teardownSteps.push( this.callbacks.afterTeardown );
+ this.teardownSteps.push(this.callbacks.afterTeardown);
delete this.callbacks.afterTeardown;
}
- },
+ };
- setup: function() {
- var self = this;
- return self.invokeSteps(self.setupSteps).then(function() {
- self.contextualizeCallbacks();
- return self.invokeSteps(self.contextualizedSetupSteps, self.context);
- });
- },
-
- teardown: function() {
- var self = this;
- return self.invokeSteps(self.contextualizedTeardownSteps, self.context).then(function() {
- return self.invokeSteps(self.teardownSteps);
- }).then(function() {
- self.cache = null;
- self.cachedCalls = null;
- });
- },
-
- invokeSteps: function(steps, _context) {
- var context = _context;
- if (!context) {
- context = this;
- }
- steps = steps.slice();
- function nextStep() {
- var step = steps.shift();
- if (step) {
- // guard against exceptions, for example missing components referenced from needs.
- return new Ember['default'].RSVP.Promise(function(ok) {
- ok(step.call(context));
- }).then(nextStep);
- } else {
- return Ember['default'].RSVP.resolve();
- }
- }
- return nextStep();
- },
-
- setupContainer: function() {
+ _default.prototype.setupContainer = function setupContainer() {
if (this.isIntegration || this.isLegacy) {
this._setupIntegratedContainer();
} else {
this._setupIsolatedContainer();
}
- },
+ };
- setupContext: function() {
+ _default.prototype.setupContext = function setupContext() {
var subjectName = this.subjectName;
var container = this.container;
- var factory = function() {
+ var factory = function factory() {
return container.lookupFactory(subjectName);
};
- test_context.setContext({
- container: this.container,
+ _AbstractTestModule.prototype.setupContext.call(this, {
+ container: this.container,
registry: this.registry,
- factory: factory,
- dispatcher: null,
- register: function() {
+ factory: factory,
+ register: function register() {
var target = this.registry || this.container;
return target.register.apply(target, arguments);
- },
- inject: {}
+ }
});
- var context = this.context = test_context.getContext();
-
- if (Ember['default'].setOwner) {
- Ember['default'].setOwner(context, this.container.owner);
+ if (_ember['default'].setOwner) {
+ _ember['default'].setOwner(this.context, this.container.owner);
}
- if (Ember['default'].inject) {
- var keys = (Object.keys || Ember['default'].keys)(Ember['default'].inject);
- keys.forEach(function(typeName) {
- context.inject[typeName] = function(name, opts) {
- var alias = (opts && opts.as) || name;
- Ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
+ this.setupInject();
+ };
+
+ _default.prototype.setupInject = function setupInject() {
+ var module = this;
+ var context = this.context;
+
+ if (_ember['default'].inject) {
+ var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
+
+ keys.forEach(function (typeName) {
+ context.inject[typeName] = function (name, opts) {
+ var alias = opts && opts.as || name;
+ _ember['default'].run(function () {
+ _ember['default'].set(context, alias, module.container.lookup(typeName + ':' + name));
+ });
};
});
}
- },
+ };
- setupTestElements: function() {
- if (Ember['default'].$('#ember-testing').length === 0) {
- Ember['default'].$('').appendTo(document.body);
- }
- },
-
- setupAJAXListeners: function() {
- wait._setupAJAXHooks();
- },
-
- teardownSubject: function() {
+ _default.prototype.teardownSubject = function teardownSubject() {
var subject = this.cache.subject;
if (subject) {
- Ember['default'].run(function() {
- Ember['default'].tryInvoke(subject, 'destroy');
+ _ember['default'].run(function () {
+ _ember['default'].tryInvoke(subject, 'destroy');
});
}
- },
+ };
- teardownContainer: function() {
+ _default.prototype.teardownContainer = function teardownContainer() {
var container = this.container;
- Ember['default'].run(function() {
+ _ember['default'].run(function () {
container.destroy();
});
- },
+ };
- teardownContext: function() {
- var context = this.context;
- this.context = undefined;
- test_context.unsetContext();
-
- if (context.dispatcher && !context.dispatcher.isDestroyed) {
- Ember['default'].run(function() {
- context.dispatcher.destroy();
- });
- }
- },
-
- teardownTestElements: function() {
- Ember['default'].$('#ember-testing').empty();
-
- // Ember 2.0.0 removed Ember.View as public API, so only do this when
- // Ember.View is present
- if (Ember['default'].View && Ember['default'].View.views) {
- Ember['default'].View.views = {};
- }
- },
-
- teardownAJAXListeners: function() {
- wait._teardownAJAXHooks();
- },
-
- defaultSubject: function(options, factory) {
+ _default.prototype.defaultSubject = function defaultSubject(options, factory) {
return factory.create(options);
- },
+ };
// allow arbitrary named factories, like rspec let
- contextualizeCallbacks: function() {
- var _this = this;
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
var callbacks = this.callbacks;
- var context = this.context;
- var factory = context.factory;
+ var context = this.context;
this.cache = this.cache || {};
this.cachedCalls = this.cachedCalls || {};
- var keys = (Object.keys || Ember['default'].keys)(callbacks);
+ var keys = (Object.keys || _ember['default'].keys)(callbacks);
+ var keysLength = keys.length;
- for (var i = 0, l = keys.length; i < l; i++) {
- (function(key) {
-
- context[key] = function(options) {
- if (_this.cachedCalls[key]) { return _this.cache[key]; }
-
- var result = callbacks[key].call(_this, options, factory());
-
- _this.cache[key] = result;
- _this.cachedCalls[key] = true;
-
- return result;
- };
-
- })(keys[i]);
+ if (keysLength) {
+ var deprecatedContext = this._buildDeprecatedContext(this, context);
+ for (var i = 0; i < keysLength; i++) {
+ this._contextualizeCallback(context, keys[i], deprecatedContext);
+ }
}
- },
+ };
- _setupContainer: function(isolated) {
- var resolver = test_resolver.getResolver();
+ _default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
+ var _this = this;
+ var callbacks = this.callbacks;
+ var factory = context.factory;
- var items = buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
+ context[key] = function (options) {
+ if (_this.cachedCalls[key]) {
+ return _this.cache[key];
+ }
+
+ var result = callbacks[key].call(callbackContext, options, factory());
+
+ _this.cache[key] = result;
+ _this.cachedCalls[key] = true;
+
+ return result;
+ };
+ };
+
+ /*
+ Builds a version of the passed in context that contains deprecation warnings
+ for accessing properties that exist on the module.
+ */
+
+ _default.prototype._buildDeprecatedContext = function _buildDeprecatedContext(module, context) {
+ var deprecatedContext = Object.create(context);
+
+ var keysForDeprecation = Object.keys(module);
+
+ for (var i = 0, l = keysForDeprecation.length; i < l; i++) {
+ this._proxyDeprecation(module, deprecatedContext, keysForDeprecation[i]);
+ }
+
+ return deprecatedContext;
+ };
+
+ /*
+ Defines a key on an object to act as a proxy for deprecating the original.
+ */
+
+ _default.prototype._proxyDeprecation = function _proxyDeprecation(obj, proxy, key) {
+ if (typeof proxy[key] === 'undefined') {
+ Object.defineProperty(proxy, key, {
+ get: function get() {
+ _ember['default'].deprecate('Accessing the test module property "' + key + '" from a callback is deprecated.', false, { id: 'ember-test-helpers.test-module.callback-context', until: '0.6.0' });
+ return obj[key];
+ }
+ });
+ }
+ };
+
+ _default.prototype._setupContainer = function _setupContainer(isolated) {
+ var resolver = this.resolver;
+
+ var items = _buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
resolve: {
- value: function() {}
+ value: function value() {}
}
}));
this.container = items.container;
this.registry = items.registry;
- if (hasEmberVersion['default'](1, 13)) {
+ if (_hasEmberVersion['default'](1, 13)) {
var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
- router = router || Ember['default'].Router.extend();
+ router = router || _ember['default'].Router.extend();
thingToRegisterWith.register('router:main', router);
}
- },
+ };
- _setupIsolatedContainer: function() {
- var resolver = test_resolver.getResolver();
+ _default.prototype._setupIsolatedContainer = function _setupIsolatedContainer() {
+ var resolver = this.resolver;
this._setupContainer(true);
var thingToRegisterWith = this.registry || this.container;
@@ -1037,24 +1629,24 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
}
if (!this.registry) {
- this.container.resolver = function() {};
+ this.container.resolver = function () {};
}
- },
+ };
- _setupIntegratedContainer: function() {
+ _default.prototype._setupIntegratedContainer = function _setupIntegratedContainer() {
this._setupContainer();
- }
+ };
- });
+ return _default;
+ })(_abstractTestModule['default']);
+ exports['default'] = _default;
});
define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
-
'use strict';
exports.setResolver = setResolver;
exports.getResolver = getResolver;
-
var __resolver__;
function setResolver(resolver) {
@@ -1062,17 +1654,23 @@ define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
}
function getResolver() {
- if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
+ if (__resolver__ == null) {
+ throw new Error('you must set a resolver with `testResolver.set(resolver)`');
+ }
+
return __resolver__;
}
-
});
-define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember) {
+define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, _ember) {
+ /* globals self */
'use strict';
exports._teardownAJAXHooks = _teardownAJAXHooks;
exports._setupAJAXHooks = _setupAJAXHooks;
+ exports['default'] = wait;
+
+ var jQuery = _ember['default'].$;
var requests;
function incrementAjaxPendingRequests(_, xhr) {
@@ -1080,7 +1678,7 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
}
function decrementAjaxPendingRequests(_, xhr) {
- for (var i = 0;i < requests.length;i++) {
+ for (var i = 0; i < requests.length; i++) {
if (xhr === requests[i]) {
requests.splice(i, 1);
}
@@ -1088,6 +1686,10 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
}
function _teardownAJAXHooks() {
+ if (!jQuery) {
+ return;
+ }
+
jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
}
@@ -1095,18 +1697,44 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
function _setupAJAXHooks() {
requests = [];
+ if (!jQuery) {
+ return;
+ }
+
jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
}
+ var _internalCheckWaiters;
+ if (_ember['default'].__loader.registry['ember-testing/test/waiters']) {
+ _internalCheckWaiters = _ember['default'].__loader.require('ember-testing/test/waiters').checkWaiters;
+ }
+
+ function checkWaiters() {
+ if (_internalCheckWaiters) {
+ return _internalCheckWaiters();
+ } else if (_ember['default'].Test.waiters) {
+ if (_ember['default'].Test.waiters.any(function (_ref) {
+ var context = _ref[0];
+ var callback = _ref[1];
+ return !callback.call(context);
+ })) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
function wait(_options) {
var options = _options || {};
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
var waitForAJAX = options.hasOwnProperty('waitForAJAX') ? options.waitForAJAX : true;
+ var waitForWaiters = options.hasOwnProperty('waitForWaiters') ? options.waitForWaiters : true;
- return new Ember['default'].RSVP.Promise(function(resolve) {
- var watcher = self.setInterval(function() {
- if (waitForTimers && (Ember['default'].run.hasScheduledTimers() || Ember['default'].run.currentRunLoop)) {
+ return new _ember['default'].RSVP.Promise(function (resolve) {
+ var watcher = self.setInterval(function () {
+ if (waitForTimers && (_ember['default'].run.hasScheduledTimers() || _ember['default'].run.currentRunLoop)) {
return;
}
@@ -1114,188 +1742,34 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
return;
}
+ if (waitForWaiters && checkWaiters()) {
+ return;
+ }
+
// Stop polling
self.clearInterval(watcher);
// Synchronously resolve the promise
- Ember['default'].run(null, resolve);
+ _ember['default'].run(null, resolve);
}, 10);
});
}
- exports['default'] = wait;
-
});
-define('klassy', ['exports'], function (exports) {
+define("qunit", ["exports"], function (exports) {
+ /* globals QUnit */
- 'use strict';
+ "use strict";
- /**
- Extend a class with the properties and methods of one or more other classes.
-
- When a method is replaced with another method, it will be wrapped in a
- function that makes the replaced method accessible via `this._super`.
-
- @method extendClass
- @param {Object} destination The class to merge into
- @param {Object} source One or more source classes
- */
- var extendClass = function(destination) {
- var sources = Array.prototype.slice.call(arguments, 1);
- var source;
-
- for (var i = 0, l = sources.length; i < l; i++) {
- source = sources[i];
-
- for (var p in source) {
- if (source.hasOwnProperty(p) &&
- destination[p] &&
- typeof destination[p] === 'function' &&
- typeof source[p] === 'function') {
-
- /* jshint loopfunc:true */
- destination[p] =
- (function(destinationFn, sourceFn) {
- var wrapper = function() {
- var prevSuper = this._super;
- this._super = destinationFn;
-
- var ret = sourceFn.apply(this, arguments);
-
- this._super = prevSuper;
-
- return ret;
- };
- wrapper.wrappedFunction = sourceFn;
- return wrapper;
- })(destination[p], source[p]);
-
- } else {
- destination[p] = source[p];
- }
- }
- }
- };
-
- // `subclassing` is a state flag used by `defineClass` to track when a class is
- // being subclassed. It allows constructors to avoid calling `init`, which can
- // be expensive and cause undesirable side effects.
- var subclassing = false;
-
- /**
- Define a new class with the properties and methods of one or more other classes.
-
- The new class can be based on a `SuperClass`, which will be inserted into its
- prototype chain.
-
- Furthermore, one or more mixins (object that contain properties and/or methods)
- may be specified, which will be applied in order. When a method is replaced
- with another method, it will be wrapped in a function that makes the previous
- method accessible via `this._super`.
-
- @method defineClass
- @param {Object} SuperClass A base class to extend. If `mixins` are to be included
- without a `SuperClass`, pass `null` for SuperClass.
- @param {Object} mixins One or more objects that contain properties and methods
- to apply to the new class.
- */
- var defineClass = function(SuperClass) {
- var Klass = function() {
- if (!subclassing && this.init) {
- this.init.apply(this, arguments);
- }
- };
-
- if (SuperClass) {
- subclassing = true;
- Klass.prototype = new SuperClass();
- subclassing = false;
- }
-
- if (arguments.length > 1) {
- var extendArgs = Array.prototype.slice.call(arguments, 1);
- extendArgs.unshift(Klass.prototype);
- extendClass.apply(Klass.prototype, extendArgs);
- }
-
- Klass.constructor = Klass;
-
- Klass.extend = function() {
- var args = Array.prototype.slice.call(arguments, 0);
- args.unshift(Klass);
- return defineClass.apply(Klass, args);
- };
-
- return Klass;
- };
-
- /**
- A base class that can be extended.
-
- @example
-
- ```javascript
- var CelestialObject = Klass.extend({
- init: function(name) {
- this._super();
- this.name = name;
- this.isCelestialObject = true;
- },
- greeting: function() {
- return 'Hello from ' + this.name;
- }
- });
-
- var Planet = CelestialObject.extend({
- init: function(name) {
- this._super.apply(this, arguments);
- this.isPlanet = true;
- },
- greeting: function() {
- return this._super() + '!';
- },
- });
-
- var earth = new Planet('Earth');
-
- console.log(earth instanceof Klass); // true
- console.log(earth instanceof CelestialObject); // true
- console.log(earth instanceof Planet); // true
-
- console.log(earth.isCelestialObject); // true
- console.log(earth.isPlanet); // true
-
- console.log(earth.greeting()); // 'Hello from Earth!'
- ```
-
- @class Klass
- */
- var Klass = defineClass(null, {
- init: function() {}
- });
-
- exports.Klass = Klass;
- exports.defineClass = defineClass;
- exports.extendClass = extendClass;
-
-});
-define('qunit', ['exports'], function (exports) {
-
- 'use strict';
-
- /* globals test:true */
-
- var module = QUnit.module;
- var test = QUnit.test;
- var skip = QUnit.skip;
- var only = QUnit.only;
-
- exports['default'] = QUnit;
-
- exports.module = module;
- exports.test = test;
- exports.skip = skip;
- exports.only = only;
+ var _module = QUnit.module;
+ exports.module = _module;
+ var test = QUnit.test;
+ exports.test = test;
+ var skip = QUnit.skip;
+ exports.skip = skip;
+ var only = QUnit.only;
+ exports.only = only;
+ exports["default"] = QUnit;
});
define("ember", ["exports"], function(__exports__) {
__exports__["default"] = window.Ember;