Skip to content

Instantly share code, notes, and snippets.

@morhook
Last active May 31, 2016 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morhook/6bad579ccbec341a048302c4707fb9d9 to your computer and use it in GitHub Desktop.
Save morhook/6bad579ccbec341a048302c4707fb9d9 to your computer and use it in GitHub Desktop.
test attribute inheritance
import Ember from 'ember';
import MyComponent from './my-component';
export default MyComponent.extend({
attributeBindings: ['other'],
other: 'default value'
});
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings:['title'],
title: 'title from parent'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('my-component-son', 'test SON', {
integration: true
});
test('it renders', function(assert) {
this.render(hbs`{{my-component-son}}`);
assert.equal(this.$().text().trim(), '');
// Template block usage:
this.render(hbs`
{{#my-component-son}}
template block text
{{/my-component-son}}
`);
assert.equal(this.$().text().trim(), 'template block text');
});
test('it renders father stuff', function(assert) {
this.render(hbs`{{my-component-son title='hola'}}`);
assert.equal(this.$().text().trim(), '');
assert.equal(this.$('div').attr('title'), 'hola');
});
test('it renders own attributes', function(assert) {
this.render(hbs`{{my-component-son other='hola'}}`);
assert.equal(this.$().text().trim(), '');
assert.equal(this.$('div').attr('other'), 'hola');
});
test('it renders both attributes', function(assert) {
this.render(hbs`{{my-component-son other='hola' title='hellouu'}}`);
assert.equal(this.$().text().trim(), '');
assert.equal(this.$('div').attr('other'), 'hola');
assert.equal(this.$('div').attr('title'), 'hellouu');
});
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('my-component', 'TODO: put something here', {
integration: true
});
test('it renders', function(assert) {
this.render(hbs`{{my-component title='hola'}}`);
assert.equal(this.$().text().trim(), '');
assert.equal(this.$('div').attr('title'), 'hola');
// Template block usage:
this.render(hbs`
{{#my-component}}
template block text
{{/my-component}}
`);
assert.equal(this.$().text().trim(), 'template block text');
});
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.8.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment