Skip to content

Commit

Permalink
feat(warnings in tests) don't strip warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kybishop committed Aug 24, 2017
1 parent b32c61f commit 601fb15
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
language: node_js
node_js:
- "4"
- "6"

sudo: false
dist: trusty
Expand Down
3 changes: 1 addition & 2 deletions addon/-debug/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Ember from 'ember';
const { Logger } = Ember;

export function assert(msg, conditional) {
if (!conditional) {
Expand All @@ -8,7 +7,7 @@ export function assert(msg, conditional) {
}

export function debug() {
Logger.debug(...arguments);
Ember.Logger.debug(...arguments);
}

export function debugOnError(msg, conditional) {
Expand Down
34 changes: 16 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-env node */
'use strict';

const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck');
const FilterImports = require('babel-plugin-filter-imports');
const RemoveImports = require('./lib/babel-plugin-remove-imports');
const Funnel = require('broccoli-funnel');
const RemoveImports = require('./lib/babel-plugin-remove-imports');
const StripClassCallCheck = require('babel6-plugin-strip-class-callcheck');

module.exports = {
name: 'ember-attacher',
Expand All @@ -22,24 +22,24 @@ module.exports = {
return;
}

if (/production/.test(env) || /test/.test(env)) {
var strippedImports = {
'ember-attacher/-debug/helpers': [
'assert',
'debug',
'debugOnError',
'stripInProduction'
]
};

if (/production/.test(env)) {
// In some versions of Ember, this.options is undefined during tests
this.options = this.options || {};

// Make sure the babel options are accessible
let babelOptions = this.options.babel = this.options.babel || {};
const babelOptions = this.options.babel = this.options.babel || {};

babelOptions.plugins = babelOptions.plugins || [];
babelOptions.postTransformPlugins = babelOptions.postTransformPlugins || [];

const strippedImports = {
'ember-attacher/-debug/helpers': [
'assert',
'debug',
'debugOnError',
'stripInProduction'
]
};
babelOptions.plugins.push([FilterImports, strippedImports]);
babelOptions.plugins.push([RemoveImports, 'ember-attacher/-debug/helpers']);
babelOptions.postTransformPlugins.push(StripClassCallCheck);
Expand All @@ -48,13 +48,11 @@ module.exports = {
this._hasSetupBabelOptions = true;
},

treeForAddon: function() {
var tree = this._super.treeForAddon.apply(this, arguments);

if (/production/.test(this._env) || /test/.test(this._env)) {
treeForAddon: function(tree) {
if (/production/.test(this._env)) {
tree = new Funnel(tree, { exclude: [ /-debug/ ] });
}

return tree;
return this._super.treeForAddon.call(this, tree);
}
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"deploy": "ember github-pages:commit --message \"Deploy gh-pages from commit $(git rev-parse HEAD)\"; git push; git checkout -"
},
"dependencies": {
"babel-eslint": "^7.2.3",
"babel-plugin-filter-imports": "^0.3.1",
"babel6-plugin-strip-class-callcheck": "^6.0.0",
"broccoli-funnel": "^1.0.7",
"ember-cli-babel": "^6.8.1",
"ember-cli-htmlbars": "^2.0.2",
"ember-cli-sass": "^7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
  \{{
<span class="underlined">
#ember-attacher
{{#ember-attacher popperClass="ember-attacher-popper tooltip"}}
{{#ember-attacher popperClass="ember-attacher-popper ember-attacher-tooltip"}}
{{#if isConfiguringTooltip}}
The "Tooltip in a parent" ember-attacher is initially set to the default settings.
Twiddle some knobs to see what ember-attacher can do!
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/components/ember-attacher-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { click, find } from 'ember-native-dom-helpers';
import { moduleForComponent, test, todo } from 'ember-qunit';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('ember-attacher', 'Integration | Component | ember attacher', {
Expand Down Expand Up @@ -41,7 +41,7 @@ test('it renders', function(assert) {
assert.equal(innerHTML.indexOf('popper text'), 0);
});

todo('nested attachers open and close as expected', async function(assert) {
test('nested attachers open and close as expected', async function(assert) {
assert.expect(6);

this.on('openParentPopover', () => {
Expand All @@ -63,7 +63,6 @@ todo('nested attachers open and close as expected', async function(assert) {
showOn: 'none'
});

//TODO: figure out how to fire actions from inside components
this.render(hbs`
<button id="openParent" {{action 'openParentPopover'}}>
Open parent
Expand Down Expand Up @@ -118,7 +117,7 @@ todo('nested attachers open and close as expected', async function(assert) {
assert.equal(innerParentAttacher.style.display, '', 'parent still shown');
});

todo('isShown works with showOn/hideOn set to "click"', async function(assert) {
test('isShown works with showOn/hideOn set to "click"', async function(assert) {
assert.expect(3);
this.on('closePopover', () => {
this.set('isShown', false);
Expand Down Expand Up @@ -162,7 +161,7 @@ todo('isShown works with showOn/hideOn set to "click"', async function(assert) {
assert.equal(innerAttacher.style.display, 'none', 'Hidden again');
});

todo('isShown works with showOn/hideOn set to "none"', async function(assert) {
test('isShown works with showOn/hideOn set to "none"', async function(assert) {
assert.expect(3);
this.on('closePopover', () => {
this.set('isShown', false);
Expand Down Expand Up @@ -211,7 +210,7 @@ todo('isShown works with showOn/hideOn set to "none"', async function(assert) {
assert.equal(innerAttacher.style.display, 'none', 'Hidden again');
});

todo('showOn/hideOn set to "click"', async function(assert) {
test('showOn/hideOn set to "click"', async function(assert) {
assert.expect(3);

this.setProperties({
Expand Down

0 comments on commit 601fb15

Please sign in to comment.