Sha256: 3bbfb48494391dc56637a8d8adb9c4e526ca7b0ee0cc149b4e612fcf06b8d00a

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

import Controller from '@ember/controller';
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';
import { Component } from 'ember-glimmer';

/*
 In Ember 1.x, controllers subtly affect things like template scope
 and action targets in exciting and often inscrutable ways. This test
 file contains integration tests that verify the correct behavior of
 the many parts of the system that change and rely upon controller scope,
 from the runtime up to the templating layer.
*/

moduleFor(
  'Template scoping examples',
  class extends ApplicationTestCase {
    ['@test Actions inside an outlet go to the associated controller'](assert) {
      this.add(
        'controller:index',
        Controller.extend({
          actions: {
            componentAction() {
              assert.ok(true, 'controller received the action');
            },
          },
        })
      );

      this.addComponent('component-with-action', {
        ComponentClass: Component.extend({
          classNames: ['component-with-action'],
          click() {
            this.action();
          },
        }),
      });

      this.addTemplate('index', '{{component-with-action action=(action "componentAction")}}');

      return this.visit('/').then(() => {
        this.runTask(() => this.$('.component-with-action').click());
      });
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember/tests/controller_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember/tests/controller_test.js