Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember.js: building better apps in less time

Ember.js: building better apps in less time

Rômulo Machado

November 26, 2016
Tweet

More Decks by Rômulo Machado

Other Decks in Programming

Transcript

  1. It was fun to get to pick and choose, but

    every step of the way we doubted our choices: were we making the wrong decision with a given library choice? “ Jesse Pollak, “Choosing Ember over React in 2016”
  2. app !"" controllers # $"" post.js !"" routes # $""

    post.js $"" templates $"" post.hbs
  3. $ ember new super-rentals installing app create .bowerrc create .ember-cli

    create .jshintrc create .travis.yml create .watchmanconfig create README.md create app/app.js create app/router.js create bower.json create package.json create tests/index.html create tests/test-helper.js ... Successfully initialized git. Installed packages for tooling via npm. Installed browser packages via Bower.
  4. super-rentals !"" app !"" bower_components !"" config !"" dist !""

    node_modules !"" public !"" tests !"" vendor !"" README.md !"" bower.json !"" ember-cli-build.js !"" package.json $"" testem.js
  5. $ ember server Livereload server on http://localhost:49152 Serving on http://localhost:4200/

    Build successful - 4247ms. Slowest Nodes (totalTime => 5% ) | Total (avg) ----------------------------------------------+--------------------- Babel (12) | 1868ms (155 ms) Concat (8) | 394ms (49 ms) ConfigReplace (3) | 389ms (129 ms)
  6. $ ember generate model rental title:string image:string installing model create

    app/models/rental.js installing model-test create tests/unit/models/rental-test.js.
  7. $ ember generate route about installing route create app/routes/about.js create

    app/templates/about.hbs updating router add route about installing route-test create tests/unit/routes/about-test.js
  8. $ ember generate component rental-listing installing component create app/components/rental-listing.js create

    app/templates/components/rental-listing.hbs installing component-test create tests/integration/components/rental-listing-test.js
  9. // tests/unit/models/rental-test.js test('slug', function (assert) { let model = this.subject({

    title: 'Quarto no Centro de Floripa' }); assert.equal(model.get('slug'), 'quarto-no-centro-de-floripa', 'should generate slug'); }); });
  10. // tests/integration/components/rental-listing-test.js test('should toggle wide class on click', function (assert)

    { let rentalObj = Ember.Object.create({ image: 'quarto-no-centro.jpg', title: 'Quarto no Centro de Floripa' }); this.render(hbs`{{rental-listing rental=rentalObj}}`); assert.equal(this.$('.image.wide').length, 0, 'initially rendered small’); this.$('.image').click(); assert.equal(this.$('.image.wide').length, 1, 'rendered wide after click'); this.$('.image').click(); assert.equal(this.$('.image.wide').length, 0, 'rendered small after second click'); });
  11. // tests/acceptance/list-rentals-test.js test('should link to about page', function (assert) {

    visit('/'); click('a:contains("About")'); andThen(function () { assert.equal(currentURL(), '/about', 'should navigate to about'); }); });
  12. $ ember test ok 1 PhantomJS 2.1 - Acceptance |

    list rentals: should link to about page ok 2 PhantomJS 2.1 - JSHint | acceptance/list-rentals-test.js: should pass jshint ... ok 9 PhantomJS 2.1 - Integration | Component | rental listing: should toggle wide class on click ... 1..19 # tests 19 # pass 19 # skip 0 # fail 0 # ok
  13. You don't have to worry about the next hype technology,

    we're gonna eventually catch up. “ — Erik Bryn