Skip to content

Commit

Permalink
Update to Babel 6 and New Module Imports (#58)
Browse files Browse the repository at this point in the history
* Update "ember-cli-babel" to v6.6.0

* Update "ember-cli-htmlbars-inline-precompile" to v0.4.4

* Use New Module Imports
  • Loading branch information
Turbo87 authored and briangonzalez committed Aug 2, 2017
1 parent 4eb771a commit 3ca021a
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 67 deletions.
20 changes: 8 additions & 12 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import Ember from 'ember';
const { getOwner } = Ember;

const {
computed,
get,
inject,
} = Ember;

export default Ember.Mixin.create({
scheduler: inject.service('scheduler'),
service: inject.service('router-scroll'),
import Mixin from '@ember/object/mixin';
import { get, computed } from '@ember/object';
import { inject } from '@ember/service';
import { getOwner } from '@ember/application';

export default Mixin.create({
scheduler: inject('scheduler'),
service: inject('router-scroll'),

isFastBoot: computed(function() {
const fastboot = getOwner(this).lookup('service:fastboot');
Expand Down
9 changes: 2 additions & 7 deletions addon/locations/router-scroll.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
/* eslint-disable */
import Ember from 'ember';
import HistoryLocation from '@ember/routing/history-location';
import { set, get } from '@ember/object';

const uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : r & 3 | 8;
return v.toString(16);
});

const {
get,
set,
HistoryLocation,
} = Ember;

export default HistoryLocation.extend({
pushState(path) {
const state = { path, uuid: uuid() };
Expand Down
11 changes: 2 additions & 9 deletions addon/services/router-scroll.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/* eslint-disable */
import Ember from 'ember';

const {
get,
set,
computed,
getWithDefault,
Service,
} = Ember;
import Service from '@ember/service';
import { getWithDefault, computed, set, get } from '@ember/object';

export default Service.extend({
init(...args) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"ember-cli-app-version": "^3.0.0",
"ember-cli-dependency-checker": "^1.4.0",
"ember-cli-htmlbars": "^1.3.0",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.4",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^2.0.1",
"ember-cli-qunit": "^3.1.2",
Expand All @@ -89,7 +89,7 @@
"browser scroll"
],
"dependencies": {
"ember-cli-babel": "^5.2.4",
"ember-cli-babel": "^6.6.0",
"ember-getowner-polyfill": "^1.2.3"
},
"ember-addon": {
Expand Down
5 changes: 2 additions & 3 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Application from '@ember/application';
import Ember from 'ember';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
let App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
const Router = EmberRouter.extend({
location: config.locationType
});

Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import { run } from '@ember/runloop';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
run(application, 'destroy');
}
4 changes: 1 addition & 3 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Promise } from 'rsvp';
import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Ember from 'ember';
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Application from '../../app';
import config from '../../config/environment';

export default function startApp(attrs) {
let application;

let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = merge({}, config.APP);
attributes = merge(attributes, attrs); // use defaults, but you can override;

Ember.run(() => {
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
Expand Down
13 changes: 7 additions & 6 deletions tests/unit/mixins/router-scroll-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import { run, next } from '@ember/runloop';
import EmberObject from '@ember/object';
import RouterScroll from 'ember-router-scroll';
import { module, test } from 'qunit';

Expand All @@ -16,7 +17,7 @@ test('when the application is FastBooted', (assert) => {
assert.expect(1);

const done = assert.async();
const RouterScrollObject = Ember.Object.extend(RouterScroll);
const RouterScrollObject = EmberObject.extend(RouterScroll);
const subject = RouterScrollObject.create({
isFastBoot: true,
scheduler: getSchedulerMock(),
Expand All @@ -26,9 +27,9 @@ test('when the application is FastBooted', (assert) => {
},
});

Ember.run(() => {
run(() => {
subject.didTransition();
Ember.run.next(() => {
next(() => {
assert.ok(true, 'it should not call updateScrollPosition.');
done();
});
Expand All @@ -39,7 +40,7 @@ test('when the application is not FastBooted', (assert) => {
assert.expect(1);

const done = assert.async();
const RouterScrollObject = Ember.Object.extend(RouterScroll);
const RouterScrollObject = EmberObject.extend(RouterScroll);
const subject = RouterScrollObject.create({
isFastBoot: false,
scheduler: getSchedulerMock(),
Expand All @@ -49,7 +50,7 @@ test('when the application is not FastBooted', (assert) => {
},
});

Ember.run(() => {
run(() => {
subject.didTransition();
});
});
7 changes: 1 addition & 6 deletions tests/unit/services/router-scroll-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import Ember from 'ember';
import { set, get } from '@ember/object';
import { moduleFor, test } from 'ember-qunit';

const {
get,
set,
} = Ember;

moduleFor('service:router-scroll');

// Replace this with your real tests.
Expand Down
Loading

0 comments on commit 3ca021a

Please sign in to comment.