import { test } from 'internal-test-helpers/tests/skip-if-glimmer'; test('Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present', function() { expect(2); var appDeferred = RSVP.defer(); App.ApplicationRoute = Route.extend({ model() { return appDeferred.promise; } }); var loadingRouteEntered = false; App.ApplicationLoadingRoute = Route.extend({ setupController() { loadingRouteEntered = true; } }); bootApplication(); ok(loadingRouteEntered, 'ApplicationLoadingRoute was entered'); run(appDeferred, 'resolve', {}); equal(jQuery('#app', '#qunit-fixture').text(), 'INDEX'); }); test('Slow promises returned from ApplicationRoute#model enter application_loading if template present', function() { expect(3);
test('should create and append a DOM element after bindings have synced', function() { var ViewTest; lookup.ViewTest = ViewTest = {}; run(function() { ViewTest.fakeController = EmberObject.create({ fakeThing: 'controllerPropertyValue' }); let deprecationMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; expectDeprecation(() => { view = EmberView.create({ fooBinding: 'ViewTest.fakeController.fakeThing', template: compile('{{view.foo}}') }); }, deprecationMessage); ok(!view.get('element'), 'precond - does not have an element before appending'); // the actual render happens in the `render` queue, which is after the `sync` // queue where the binding is synced. view.append(); }); equal(view.$().text(), 'controllerPropertyValue', 'renders and appends after bindings have synced'); });
import { template } from 'ember-template-compiler'; import { test, testModule } from 'internal-test-helpers/tests/skip-if-glimmer'; testModule('ember-htmlbars: template'); test('sets `isTop` on the provided function', function() { function test() { } var result = template(test); equal(result.isTop, true, 'sets isTop on the provided function'); }); test('sets `isMethod` on the provided function', function() { function test() { } var result = template(test); equal(result.isMethod, false, 'sets isMethod on the provided function'); });
test('`click` triggers appropriate events in order', function() { expect(5); var click, wait, events; App.IndexView = EmberView.extend({ classNames: 'index-view', didInsertElement() { this.$().on('mousedown focusin mouseup click', function(e) { events.push(e.type); }); }, Checkbox: Checkbox.extend({ click() { events.push('click:' + this.get('checked')); }, change() { events.push('change:' + this.get('checked')); } }) }); setTemplate('index', compile('{{input type="text"}} {{view view.Checkbox}} {{textarea}} <div contenteditable="true"> </div>')); run(App, App.advanceReadiness); click = App.testHelpers.click; wait = App.testHelpers.wait; return wait().then(function() { events = []; return click('.index-view'); }).then(function() { deepEqual(events, ['mousedown', 'mouseup', 'click'], 'fires events in order'); }).then(function() { events = []; return click('.index-view input[type=text]'); }).then(function() { deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on inputs'); }).then(function() { events = []; return click('.index-view textarea'); }).then(function() { deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on textareas'); }).then(function() { events = []; return click('.index-view div'); }).then(function() { deepEqual(events, ['mousedown', 'focusin', 'mouseup', 'click'], 'fires focus events on contenteditable'); }).then(function() { events = []; return click('.index-view input[type=checkbox]'); }).then(function() { // i.e. mousedown, mouseup, change:true, click, click:true // Firefox differs so we can't assert the exact ordering here. // See https://bugzilla.mozilla.org/show_bug.cgi?id=843554. equal(events.length, 5, 'fires click and change on checkboxes'); }); });
testModule('mount keyword', { setup() { commonSetup(); }, teardown() { commonTeardown(); } }); test('asserts that only a single param is passed', function(assert) { assert.expect(1); let component = Component.extend({ [OWNER]: appInstance, layout: compile('{{mount "chat" "extra"}}') }).create(); expectAssertion(() => { runAppend(component); }, /The first argument of {{mount}} must be an engine name, e.g. {{mount "chat-engine"}}./i); }); test('asserts that the engine name argument is quoted', function(assert) { assert.expect(1); let component = Component.extend({ [OWNER]: appInstance, layout: compile('{{mount chat}}') }).create(); expectAssertion(() => {