Skip to content

Commit

Permalink
Merge pull request #758 from Turbo87/params
Browse files Browse the repository at this point in the history
Remove deprecated `TransformTestSelectorParamsToHashPairs` transform
  • Loading branch information
Turbo87 authored Jul 5, 2021
2 parents 93eb426 + aef3ddd commit b63ba2c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 172 deletions.
31 changes: 10 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ module.exports = {
},

_setupPreprocessorRegistry(registry) {
let pluginFnName = this._stripTestSelectors ? '_buildStripPlugin' : '_buildHashParamPlugin';

let plugin = this[pluginFnName]();
plugin.parallelBabel = {
requireFile: __filename,
buildUsing: pluginFnName,
params: {},
};

registry.add('htmlbars-ast-plugin', plugin);
if (this._stripTestSelectors) {
let plugin = this._buildStripPlugin();
plugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildStripPlugin',
params: {},
};

registry.add('htmlbars-ast-plugin', plugin);
}
},

included(appOrParent) {
Expand Down Expand Up @@ -119,15 +119,4 @@ module.exports = {
cacheKey: StripTestSelectorsTransform.cacheKey,
};
},

_buildHashParamPlugin() {
let TransformTestSelectorParamsToHashPairs = require('./transform-test-selector-params-to-hash-pairs');

return {
name: 'transform-test-selector-params-to-hash-pairs',
plugin: TransformTestSelectorParamsToHashPairs,
baseDir: TransformTestSelectorParamsToHashPairs.baseDir,
cacheKey: TransformTestSelectorParamsToHashPairs.cacheKey,
};
},
};
19 changes: 1 addition & 18 deletions tests/acceptance/bind-data-test-attributes-in-components-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { module, test, skip } from 'qunit';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit } from '@ember/test-helpers';

import config from 'dummy/config/environment';
import { hasPositionalParams } from 'dummy/version-checks';

if (!config.stripTestSelectors) {

Expand Down Expand Up @@ -54,22 +53,6 @@ if (!config.stripTestSelectors) {
assert.dom('.test7 div[data-test-with-boolean-value]').exists('data-test-with-boolean-value exists');
});

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

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

(hasPositionalParams ? test : skip)('it leaves data-test attribute without value untouched on components', function(assert) {
assert.dom('.test10 div[data-test]').doesNotExist('data-test does not exists');
});

test('it transforms data-test params to hash pairs on components', function(assert) {
assert.dom('.test11 div[data-test-something]').exists('data-test-something exists');
});

test('it binds data-test attributes on {{link-to}} components', function(assert) {
assert.dom('.test-link-to-block a').hasAttribute('data-test-foo', 'bar');
assert.dom('.test-link-to-inline a').hasAttribute('data-test-foo', 'bar');
Expand Down
6 changes: 0 additions & 6 deletions tests/dummy/app/controllers/bind-test.js

This file was deleted.

10 changes: 0 additions & 10 deletions tests/dummy/app/templates/bind-test.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@

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

<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>

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

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

<div class="test-link-to-block">{{#link-to "index" data-test-foo="bar"}}Label{{/link-to}}</div>

<div class="test-link-to-inline">{{link-to "Label" "index" data-test-foo="bar"}}</div>
Expand Down
21 changes: 0 additions & 21 deletions tests/dummy/app/version-checks.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
import { module, test, skip } from 'qunit';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

import config from 'dummy/config/environment';
import {
hasReliablePositionalParams,
hasEmberVersion
} from 'dummy/version-checks';

module('StripTestSelectorsTransform plugin', function(hooks) {
setupRenderingTest(hooks);

if (config.stripTestSelectors) {
(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with single positional params', async function(assert) {
await render(hbs`{{print-test-attributes data-test-should-not-be}}`);

assert.dom('.data-test-positional-params').hasText(hasEmberVersion(2, 10) || !hasEmberVersion(2, 3) ? '' : '0', 'there should be no params');
});

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with positional params data-test-* as first param', async function(assert) {
await render(hbs`{{print-test-attributes data-test-should-not-be "param1"}}`);

assert.dom('.data-test-positional-params').hasText('1', 'there should be only one param');
});

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with multiple positional params', async function(assert) {
await render(hbs`{{print-test-attributes "param1" data-test-should-not-be}}`);

assert.dom('.data-test-positional-params').hasText('1', 'there should be only one param');
});

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with block and multiple positional params', async function(assert) {
await render(hbs`{{#print-test-attributes "param1" data-test-should-not-be}}{{/print-test-attributes}}`);

assert.dom('.data-test-positional-params').hasText('1', 'there should be only one param');
});

test('it strips data-test-* attributes from components', async function(assert) {
await render(hbs`{{print-test-attributes data-test-first="foobar"}}`);

Expand Down
67 changes: 0 additions & 67 deletions transform-test-selector-params-to-hash-pairs.js

This file was deleted.

0 comments on commit b63ba2c

Please sign in to comment.