Skip to content

Commit

Permalink
feat: add ember-zipline component and service
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya committed Jan 13, 2019
1 parent b6f48ca commit 21aebed
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 2 deletions.
17 changes: 17 additions & 0 deletions addon/components/ember-zipline/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import layout from './template';

export default Component.extend({
ziplineService: service('zipline'),

layout,
tagName: '',

didReceiveAttrs() {
let zipline = this.ziplineService;
let data = this.data;

zipline.set('data', data);
}
});
1 change: 1 addition & 0 deletions addon/components/ember-zipline/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield}}
4 changes: 4 additions & 0 deletions addon/services/zipline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Service from '@ember/service';

export default Service.extend({
});
1 change: 1 addition & 0 deletions app/components/ember-zipline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-zipline/components/ember-zipline/component';
1 change: 1 addition & 0 deletions app/services/zipline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-zipline/services/zipline';
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"test:all": "ember try:each"
},
"dependencies": {
"ember-cli-babel": "^7.1.2"
"ember-cli-babel": "^7.1.2",
"ember-cli-htmlbars": "^3.0.0"
},
"devDependencies": {
"@ember/optional-features": "^0.6.3",
"broccoli-asset-rev": "^2.7.0",
"ember-cli": "~3.7.0",
"ember-cli-dependency-checker": "^3.0.0",
"ember-cli-eslint": "^4.2.3",
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-sri": "^2.1.1",
Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/app/components/my-button/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Component from '@ember/component';
import layout from './template';

export default Component.extend({
layout,
tagName: 'button'
});
2 changes: 2 additions & 0 deletions tests/dummy/app/components/my-button/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{yield}}
{{@label}}
6 changes: 6 additions & 0 deletions tests/dummy/app/index/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default Controller.extend({
ziplineService: service('zipline')
});
4 changes: 4 additions & 0 deletions tests/dummy/app/index/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Route from '@ember/routing/route';

export default Route.extend({
});
5 changes: 5 additions & 0 deletions tests/dummy/app/index/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{outlet}}

{{#let this.ziplineService.data.MyButton as |MyButton|}}
<MyButton/>
{{/let}}
6 changes: 6 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<h2 id="title">Welcome to Ember</h2>

<EmberZipline
@data={{hash
MyButton=(component "my-button" label="Hello")
}}
/>

{{outlet}}
31 changes: 31 additions & 0 deletions tests/integration/components/ember-zipline/component-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import Service from '@ember/service';


const ZiplineService = Service.extend({

});

module('Integration | Component | ember-zipline', function(hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function() {
this.owner.register('service:zipline', ZiplineService);
});

test('it renders', async function(assert) {
await render(hbs`
<EmberZipline
@data={{hash
MyButton=(component 'my-button' label='Hello')
}}
/>
`);

let ziplineService = this.owner.lookup('service:zipline');
assert.ok(ziplineService.get('data'), 'Has data object');
});
});
12 changes: 12 additions & 0 deletions tests/unit/services/zipline-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Service | zipline', function(hooks) {
setupTest(hooks);

// Replace this with your real tests.
test('it exists', function(assert) {
let service = this.owner.lookup('service:zipline');
assert.ok(service);
});
});

0 comments on commit 21aebed

Please sign in to comment.