Sha256: 381a78991f2de86e322022f4df51d28e2afa8eca316fa6a50c685e6fdd27e4bd

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

import { Route } from 'ember-routing';
import { computed } from 'ember-metal';
import { Object as EmberObject, A as emberA } from 'ember-runtime';

import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';

moduleFor(
  'The example renders correctly',
  class extends ApplicationTestCase {
    ['@test Render index template into application outlet'](assert) {
      this.addTemplate('application', '{{outlet}}');
      this.addTemplate(
        'index',
        '<h1>People</h1><ul>{{#each model as |person|}}<li>Hello, <b>{{person.fullName}}</b>!</li>{{/each}}</ul>'
      );

      let Person = EmberObject.extend({
        firstName: null,
        lastName: null,
        fullName: computed('firstName', 'lastName', function() {
          return `${this.get('firstName')} ${this.get('lastName')}`;
        }),
      });

      this.add(
        'route:index',
        Route.extend({
          model() {
            return emberA([
              Person.create({ firstName: 'Tom', lastName: 'Dale' }),
              Person.create({ firstName: 'Yehuda', lastName: 'Katz' }),
            ]);
          },
        })
      );

      return this.visit('/').then(() => {
        let $ = this.$();

        assert.equal($.findAll('h1').text(), 'People');
        assert.equal($.findAll('li').length, 2);
        assert.equal($.findAll('li:nth-of-type(1)').text(), 'Hello, Tom Dale!');
        assert.equal($.findAll('li:nth-of-type(2)').text(), 'Hello, Yehuda Katz!');
      });
    }
  }
);

Version data entries

2 entries across 2 versions & 1 rubygems

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