Skip to content

Commit

Permalink
Fixed tests, upgraded deps
Browse files Browse the repository at this point in the history
  • Loading branch information
briangonzalez committed Jan 24, 2017
1 parent b777579 commit 0b4a460
Show file tree
Hide file tree
Showing 4 changed files with 6,063 additions and 15 deletions.
1 change: 1 addition & 0 deletions addon/services/router-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default Service.extend({

set(this, 'key', stateUuid);
let key = getWithDefault(this, 'key', '-1');
console.log(key);

return getWithDefault(scrollMap, key, { x: 0, y: 0 });
}).volatile(),
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
"devDependencies": {
"broccoli-asset-rev": "^2.4.2",
"ember-ajax": "^2.0.1",
"ember-cli": "2.6.2",
"ember-cli": "2.11.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^1.0.0",
"ember-cli-qunit": "^1.4.0",
"ember-cli-release": "^0.2.9",
"ember-cli-release": "^1.0.0-beta.2",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.6.0",
Expand All @@ -74,8 +74,8 @@
"ember-getowner-polyfill": "1.0.1",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-welcome-page": "^1.0.1",
"eslint": "^2.4.0",
"ember-welcome-page": "^2.0.3",
"eslint": "^3.14.0",
"eslint-config-airbnb": "^6.1.0",
"eslint-plugin-dollarshaveclub": "^1.0.0",
"loader.js": "^4.0.1",
Expand All @@ -92,6 +92,6 @@
},
"ember-addon": {
"configPath": "tests/dummy/config",
"demoURL": "https://dollarshaveclub.github.io/router-scroll-demo/"
"demoURL": "https://dollarshaveclub.github.io/router-scroll-demo/"
}
}
19 changes: 9 additions & 10 deletions tests/unit/services/router-scroll-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { moduleFor, test } from 'ember-qunit';

const {
get,
set
set,
} = Ember;

moduleFor('service:router-scroll', {
Expand All @@ -12,13 +12,13 @@ moduleFor('service:router-scroll', {
});

// Replace this with your real tests.
test('it inits `scrollMap` and `key`', function(assert) {
test('it inits `scrollMap` and `key`', function (assert) {
let service = this.subject();
assert.deepEqual(get(service, 'scrollMap'), {});
assert.deepEqual(get(service, 'key'), null);
});

test('updating will set `scrollMap` to the current scroll position', function(assert) {
test('updating will set `scrollMap` to the current scroll position', function (assert) {
let service = this.subject();

let expected = { x: window.scrollX, y: window.scrollY };
Expand All @@ -27,35 +27,34 @@ test('updating will set `scrollMap` to the current scroll position', function(as
assert.deepEqual(get(service, 'scrollMap'), { '123': expected });
});

test('updating will not set `scrollMap` to the current scroll position if `key` is not yet set', function(assert) {
test('updating will not set `scrollMap` to the current scroll position if `key` is not yet set', function (assert) {
let service = this.subject();

service.update();
assert.deepEqual(get(service, 'scrollMap'), { });
});

test('computing the position for an existing state uuid return the coords', function(assert) {
test('computing the position for an existing state uuid return the coords', function (assert) {
let service = this.subject();
let state = window.history.state;
window.history.replaceState({uuid: '123'}, null);
window.history.replaceState({ uuid: '123' }, null);

let expected = { x: 1, y: 1 };
set(service, 'scrollMap.123', expected);
assert.deepEqual(get(service, 'position'), expected);
window.history.replaceState(state, null);
});

test('computing the position for a state without a cached scroll position returns default', function(assert) {
test('computing the position for a state without a cached scroll position returns default', function (assert) {
let service = this.subject();
let state = window.history.state;
window.history.replaceState({uuid: '123'}, null);
window.history.replaceState({ uuid: '123' }, null);

let expected = { x: 0, y: 0 };
assert.deepEqual(get(service, 'position'), expected);
window.history.replaceState(state, null);
});

test('computing the position for a non-existing state returns default', function(assert) {
test('computing the position for a non-existing state returns default', function (assert) {
let service = this.subject();

let expected = { x: 0, y: 0 };
Expand Down
Loading

0 comments on commit 0b4a460

Please sign in to comment.