Skip to content

Commit

Permalink
upgrade to 2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Batson committed Sep 18, 2017
1 parent c0098d2 commit 126161e
Show file tree
Hide file tree
Showing 13 changed files with 574 additions and 566 deletions.
19 changes: 8 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
extends: 'eslint:recommended',
env: {
browser: true
},
"rules": {
},
"globals": {
"$": true
rules: {
}
};
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
Expand All @@ -13,5 +13,11 @@
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.editorconfig
.ember-cli
.gitignore
.jshintrc
.eslintrc.js
.watchmanconfig
.travis.yml
bower.json
Expand Down
1 change: 0 additions & 1 deletion addon/flash/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default EmberObject.extend(Evented, {
if (!get(this, 'isExitable')) {
return;
}

this._setTimer('exitTimer', 'destroyMessage', get(this, 'extendedTimeout'));
this._cancelTimer('timer');

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"start": "ember server",
"test": "ember try:each"
},
"repository": "https://github.com/poteto/ember-cli-flash",
Expand All @@ -25,32 +25,31 @@
],
"license": "MIT",
"dependencies": {
"bower": "^1.8.2",
"ember-cli-babel": "^6.3.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-runtime-enumerable-includes-polyfill": "^1.0.1"
"ember-runtime-enumerable-includes-polyfill": "^2.0.0"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "3.0.0",
"ember-cli": "^2.14.1",
"ember-ajax": "^3.0.0",
"ember-cli": "~2.15.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.0.0",
"ember-cli-github-pages": "0.0.6",
"ember-cli-htmlbars-inline-precompile": "^0.4.3",
"ember-cli-inject-live-reload": "^1.7.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-shims": "^1.1.0",
"ember-cli-qunit": "^4.0.0",
"ember-cli-release": "^0.2.9",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-cli-eslint": "^3.0.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.3.0",
"ember-source": "~2.14.1",
"ember-sinon": "0.7.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.15.0",
"loader.js": "^4.2.3"
},
"keywords": [
Expand Down
24 changes: 16 additions & 8 deletions testem.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
/* eslint-env node */
module.exports = {
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"Chrome"
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
"launch_in_dev": [
"Chrome"
]
launch_in_dev: [
'Chrome'
],
browser_args: {
Chrome: [
'--disable-gpu',
'--headless',
'--remote-debugging-port=9222',
'--window-size=1440,900'
]
}
};
8 changes: 4 additions & 4 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;
const { RSVP: { resolve } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();

if (options.beforeEach) {
return options.beforeEach.apply(...arguments);
return options.beforeEach.apply(this, arguments);
}
},

afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(...arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return resolve(afterEach).then(() => destroyApp(this.application));
}
});
}
15 changes: 5 additions & 10 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';

const merge = Ember.assign || Ember.merge;

export default function startApp(attrs) {
let application;

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

Ember.run(() => {
application = Application.create(attributes);
return Ember.run(() => {
let application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
return application;
});

return application;
}
2 changes: 1 addition & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{{content-for "body"}}
{{content-for "test-body"}}

<script src="{{rootURL}}testem.js" integrity=""></script>
<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
Expand Down
136 changes: 61 additions & 75 deletions tests/integration/components/flash-message-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import FlashMessage from 'ember-cli-flash/flash/object';
import sinon from 'sinon';
import Ember from 'ember';
import wait from 'ember-test-helpers/wait';
import Ember from 'ember';

const { run: { later } } = Ember;

const timeoutDefault = 1000;

Expand Down Expand Up @@ -40,92 +41,77 @@ test('it does not error when quickly removed from the DOM', function(assert) {
assert.ok(this.get('flash').isDestroyed, 'Flash Object isDestroyed');
});

if (parseFloat(Ember.VERSION) > 2.0) {
test('flash message is removed after timeout', function(assert) {
assert.expect(3);
test('flash message is removed after timeout', function(assert) {
assert.expect(3);

let destroyMessage = sinon.spy();

this.set('flash', FlashMessage.create({
message: 'hi',
sticky: false,
timeout: timeoutDefault,
destroyMessage
}));
this.set('flash', FlashMessage.create({
message: 'hi',
sticky: false,
timeout: timeoutDefault
}));

this.render(hbs`
{{#flash-message flash=flash as |component flash|}}
{{flash.message}}
{{/flash-message}}
`);
this.render(hbs`
{{#flash-message flash=flash as |component flash|}}
{{flash.message}}
{{/flash-message}}
`);

assert.equal(this.$().text().trim(), 'hi');
assert.notOk(destroyMessage.calledOnce, 'flash has not been destroyed yet');
assert.equal(this.$().text().trim(), 'hi');
assert.notOk(this.get('flash').isDestroyed, 'Flash is not destroyed immediately');

return wait().then(() => {
assert.ok(destroyMessage.calledOnce, 'flash is destroyed after timeout');
});
return wait().then(() => {
assert.ok(this.get('flash').isDestroyed, 'Flash Object is destroyed');
});
});

test('flash message is removed after timeout', function(assert) {
assert.expect(3);

let destroyMessage = sinon.spy();
test('flash message is removed after timeout if mouse enters', function(assert) {
assert.expect(3);

this.set('flash', FlashMessage.create({
message: 'hi',
sticky: false,
timeout: timeoutDefault,
destroyMessage
}));
let foo = FlashMessage.create({
message: 'hi',
sticky: false,
timeout: timeoutDefault
});

this.render(hbs`
{{#flash-message flash=flash as |component flash|}}
<span id="testFlash">{{flash.message}}</span>
{{/flash-message}}
`);
this.set('flash', foo);

assert.equal(this.$().text().trim(), 'hi');
this.render(hbs`
{{#flash-message elementId="testFlash" flash=flash as |component flash|}}
{{flash.message}}
{{/flash-message}}
`);

this.$('#testFlash').mouseenter();
assert.equal(this.$().text().trim(), 'hi');
this.$('#testFlash').mouseenter();

assert.notOk(
destroyMessage.calledOnce,
'flash is not destroyed after enough elapsed time'
);
assert.notOk(foo.isDestroyed, 'Flash Object is not destroyed');
this.$('#testFlash').mouseleave();

this.$('#testFlash').mouseleave();

return wait().then(() => {
assert.ok(
destroyMessage.calledOnce,
'flash waits remaining time from original timeout'
);
});
});
later(() => {
assert.ok(foo.isDestroyed, 'Flash Object is destroyed');
}, 1001);
return wait();
});

test('a custom component can use the close closure action', function(assert) {
assert.expect(3);
test('a custom component can use the close closure action', function(assert) {
assert.expect(3);

let destroyMessage = sinon.spy();
this.set('flash', FlashMessage.create({
message: 'flash message content',
sticky: true,
destroyOnClick: false,
destroyMessage
}));
this.set('flash', FlashMessage.create({
message: 'flash message content',
sticky: true,
destroyOnClick: false
}));

this.render(hbs`
{{#flash-message flash=flash as |component flash close|}}
{{flash.message}}
<a href="#" {{action close}}>close</a>
{{/flash-message}}
`);
this.render(hbs`
{{#flash-message flash=flash as |component flash close|}}
{{flash.message}}
<a href="#" {{action close}}>close</a>
{{/flash-message}}
`);

assert.notOk(destroyMessage.calledOnce, 'flash has not been destroyed yet');
this.$(":contains(flash message content)").click();
assert.notOk(destroyMessage.calledOnce, 'flash has not been destroyed yet');
this.$(":contains(close)").click();
assert.ok(destroyMessage.calledOnce, 'flash is destroyed after clicking close');
});
}
assert.notOk(this.get('flash').isDestroyed, 'flash has not been destroyed yet');
this.$(":contains(flash message content)").click();
assert.notOk(this.get('flash').isDestroyed, 'flash has not been destroyed yet');
this.$(":contains(close)").click();
assert.ok(this.get('flash').isDestroyed, 'flash is destroyed after clicking close');
});
1 change: 1 addition & 0 deletions tests/unit/components/flash-message-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import $ from 'jquery';
import Ember from 'ember';
import {
moduleForComponent,
Expand Down
Loading

0 comments on commit 126161e

Please sign in to comment.