Skip to content

Commit

Permalink
bugfix(transform): Disable handlebars transform pre-Ember-1.13 (#150)
Browse files Browse the repository at this point in the history
* bugfix(transform): Disable handlebars transform pre-Ember-1.13

* enable tests for 1.11+

* optionally exclude tests
  • Loading branch information
pzuraq authored and marcoow committed Nov 3, 2017
1 parent fb30ded commit 251be25
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 175 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ module.exports = {
let host = this._findHost();
this._assignOptions(host);

// we can't use the setupPreprocessorRegistry() hook as it is called to
// early and we do not have reliable access to `app.tests` there yet
this._setupPreprocessorRegistry(app.registry);
let emberChecker = new VersionChecker(app).forEmber();

if (emberChecker.isAbove('1.13.0')) {
// we can't use the setupPreprocessorRegistry() hook as it is called to
// early and we do not have reliable access to `app.tests` there yet
this._setupPreprocessorRegistry(app.registry);
}

// add the StripDataTestPropertiesPlugin to the list of plugins used by
// the `ember-cli-babel` addon
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ember-cli-inject-live-reload": "^1.6.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-compatibility-helpers": "^0.1.2",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.3.0",
Expand All @@ -55,7 +56,7 @@
"ember-addon": {
"configPath": "tests/dummy/config",
"versionCompatibility": {
"ember": ">=1.13"
"ember": ">=1.11"
}
},
"greenkeeper": {
Expand Down
34 changes: 19 additions & 15 deletions tests/acceptance/bind-data-test-attributes-in-components-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';

import config from 'dummy/config/environment';

import { GTE_EMBER_1_13 } from 'ember-compatibility-helpers';

if (!config.stripTestSelectors) {

/*
Expand Down Expand Up @@ -47,23 +49,25 @@ if (!config.stripTestSelectors) {
assert.equal(find('.test6').find('div[data-non-test]').length, 0, 'data-non-test does not exists');
});

test('it binds data-test-* attributes with boolean values on components', function(assert) {
assert.equal(find('.test7').find('div[data-test-with-boolean-value]').length, 1, 'data-test-with-boolean-value exists');
});
if (GTE_EMBER_1_13) {
test('it binds data-test-* attributes with boolean values on components', function(assert) {
assert.equal(find('.test7').find('div[data-test-with-boolean-value]').length, 1, 'data-test-with-boolean-value exists');
});

test('it binds data-test-* attributes without values on components', function(assert) {
assert.equal(find('.test8').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});
test('it binds data-test-* attributes without values on components', function(assert) {
assert.equal(find('.test8').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});

test('it binds data-test-* attributes without values on block components', function(assert) {
assert.equal(find('.test9').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});
test('it binds data-test-* attributes without values on block components', function(assert) {
assert.equal(find('.test9').find('div[data-test-without-value]').length, 1, 'data-test-without-value exists');
});

test('it leaves data-test attribute without value untouched on components', function(assert) {
assert.equal(find('.test10').find('div[data-test]').length, 0, 'data-test does not exists');
});
test('it leaves data-test attribute without value untouched on components', function(assert) {
assert.equal(find('.test10').find('div[data-test]').length, 0, 'data-test does not exists');
});

test('it transforms data-test params to hash pairs on components', function(assert) {
assert.equal(find('.test11').find('div[data-test-something]').length, 1, 'data-test-something exists');
});
test('it transforms data-test params to hash pairs on components', function(assert) {
assert.equal(find('.test11').find('div[data-test-something]').length, 1, 'data-test-something exists');
});
}
}
8 changes: 8 additions & 0 deletions tests/dummy/app/controllers/bind-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Ember from 'ember';
import { GTE_EMBER_1_13 } from 'ember-compatibility-helpers';

const { Controller } = Ember;

export default Controller.extend({
shouldRenderParamTests: GTE_EMBER_1_13
});
10 changes: 6 additions & 4 deletions tests/dummy/app/templates/bind-test.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

<div class="test7">{{data-test-component data-test-with-boolean-value=true}}</div>

<div class="test8">{{data-test-component data-test-without-value}}</div>
{{#if shouldRenderParamTests}}
<div class="test8">{{data-test-component data-test-without-value}}</div>

<div class="test9">{{#data-test-component data-test-without-value}}foo{{/data-test-component}}</div>
<div class="test9">{{#data-test-component data-test-without-value}}foo{{/data-test-component}}</div>

<div class="test10">{{data-test-component data-test}}</div>
<div class="test10">{{data-test-component data-test}}</div>

<div class="test11">{{data-test-component data-test-something some-prop="prop"}}</div>
<div class="test11">{{data-test-component data-test-something some-prop="prop"}}</div>
{{/if}}
Loading

0 comments on commit 251be25

Please sign in to comment.