Skip to content

Commit

Permalink
tests/integration: Replace moduleForComponent() with `setupRenderin…
Browse files Browse the repository at this point in the history
…gTest()`
  • Loading branch information
Turbo87 committed Nov 12, 2019
1 parent d7bff04 commit a8e2866
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 96 deletions.
112 changes: 55 additions & 57 deletions tests/integration/strip-data-test-attributes-from-components-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { moduleForComponent, test, skip } from 'ember-qunit';
import { module, test, skip } 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';
Expand All @@ -7,80 +9,76 @@ import {
hasEmberVersion
} from 'dummy/version-checks';

moduleForComponent('print-test-attributes', 'StripTestSelectorsTransform plugin', {
integration: true
});

if (config.stripTestSelectors) {

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with single positional params', function(assert) {
this.render(hbs`{{print-test-attributes data-test-should-not-be}}`);
module('StripTestSelectorsTransform plugin', function(hooks) {
setupRenderingTest(hooks);

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

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with positional params data-test-* as first param', function(assert) {
this.render(hbs`{{print-test-attributes data-test-should-not-be "param1"}}`);
assert.dom('.data-test-positional-params').hasText(hasEmberVersion(2, 10) || !hasEmberVersion(2, 3) ? '' : '0', 'there should be no params');
});

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 positional params data-test-* as first param', async function(assert) {
await render(hbs`{{print-test-attributes data-test-should-not-be "param1"}}`);

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with multiple positional params', function(assert) {
this.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');
});

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}}`);

(hasReliablePositionalParams ? test : skip)('it strips data-test-* attributes from components with block and multiple positional params', function(assert) {
this.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');
});

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}}`);

test('it strips data-test-* attributes from components', function(assert) {
this.render(hbs`{{print-test-attributes data-test-first="foobar"}}`);
assert.dom('.data-test-positional-params').hasText('1', 'there should be only one param');
});

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

test('it strips data-test-* attributes from components in block form', function(assert) {
this.render(hbs`{{#print-test-attributes data-test-first="foobar"}}hello{{/print-test-attributes}}`);
assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
});

assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
});
test('it strips data-test-* attributes from components in block form', async function(assert) {
await render(hbs`{{#print-test-attributes data-test-first="foobar"}}hello{{/print-test-attributes}}`);

test('it works with multiple data-test-* attributes on components', function(assert) {
this.render(hbs`{{print-test-attributes data-test-first="foobar" data-test-second="second"}}`);
assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
});

assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
assert.dom('.data-test-second').hasText('', 'the data-test-second attribute was stripped');
});
test('it works with multiple data-test-* attributes on components', async function(assert) {
await render(hbs`{{print-test-attributes data-test-first="foobar" data-test-second="second"}}`);

test('it leaves other data attributes untouched, when a data-test-* attribute is present as well on components', function(assert) {
this.render(hbs`{{print-test-attributes data-test-first="foobar" data-non-test="baz"}}`);
assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
assert.dom('.data-test-second').hasText('', 'the data-test-second attribute was stripped');
});

assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
assert.dom('.data-non-test').hasText('baz', 'the data-non-test attribute was not stripped');
});
test('it leaves other data attributes untouched, when a data-test-* attribute is present as well on components', async function(assert) {
await render(hbs`{{print-test-attributes data-test-first="foobar" data-non-test="baz"}}`);

test('it leaves data-test attributes untouched on components', function(assert) {
this.render(hbs`{{print-test-attributes data-test="foo"}}`);
assert.dom('.data-test-first').hasText('', 'the data-test-first was stripped');
assert.dom('.data-non-test').hasText('baz', 'the data-non-test attribute was not stripped');
});

assert.dom('.data-test').hasText('foo', 'the data-test attribute was stripped');
});
test('it leaves data-test attributes untouched on components', async function(assert) {
await render(hbs`{{print-test-attributes data-test="foo"}}`);

test('it leaves other data attributes untouched on components', function(assert) {
this.render(hbs`{{print-test-attributes data-non-test="foo"}}`);
assert.dom('.data-test').hasText('foo', 'the data-test attribute was stripped');
});

assert.dom('.data-non-test').hasText('foo', 'the data-non-test attribute was not stripped');
});
test('it leaves other data attributes untouched on components', async function(assert) {
await render(hbs`{{print-test-attributes data-non-test="foo"}}`);

} else {
assert.dom('.data-non-test').hasText('foo', 'the data-non-test attribute was not stripped');
});
} else {
test('it does not strip data-test-* attributes from components', async function(assert) {
await render(hbs`{{print-test-attributes data-test-first="foobar"}}`);

test('it does not strip data-test-* attributes from components', function(assert) {
this.render(hbs`{{print-test-attributes data-test-first="foobar"}}`);

assert.dom('.data-test-first').hasText('foobar', 'the data-test-first attribute was not stripped');
});

}
assert.dom('.data-test-first').hasText('foobar', 'the data-test-first attribute was not stripped');
});
}
});
80 changes: 41 additions & 39 deletions tests/integration/strip-data-test-attributes-from-tags-test.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
import { moduleForComponent, test } from 'ember-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';

moduleForComponent('data-test-component', 'StripTestSelectorsTransform plugin', {
integration: true
});
module('StripTestSelectorsTransform plugin', function(hooks) {
setupRenderingTest(hooks);

if (config.stripTestSelectors) {
if (config.stripTestSelectors) {

test('it strips data-test-* attributes from HTML tags', function(assert) {
this.render(hbs`<span data-test-id="my-id" ></span>`);
test('it strips data-test-* attributes from HTML tags', async function(assert) {
await render(hbs`<span data-test-id="my-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-test-id="my-id"]').doesNotExist('data-test-id is stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-test-id="my-id"]').doesNotExist('data-test-id is stripped');
});

test('it works with multiple data-test-* attributes on HTML tags', function(assert) {
this.render(hbs`<span data-test-first data-test-second="second-id" ></span>`);
test('it works with multiple data-test-* attributes on HTML tags', async function(assert) {
await render(hbs`<span data-test-first data-test-second="second-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-test-first]').doesNotExist('data-test-first is stripped');
assert.dom('span[data-test-second="second-id"]').doesNotExist('data-test-second is stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-test-first]').doesNotExist('data-test-first is stripped');
assert.dom('span[data-test-second="second-id"]').doesNotExist('data-test-second is stripped');
});

test('it leaves other data attributes untouched, when a data-test-* attribute is present as well on HTML tags', function(assert) {
this.render(hbs`<span data-id="my-id" data-test-id="my-test-id" ></span>`);
test('it leaves other data attributes untouched, when a data-test-* attribute is present as well on HTML tags', async function(assert) {
await render(hbs`<span data-id="my-id" data-test-id="my-test-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-id="my-id"]').exists('data-id is not stripped');
assert.dom('span[data-test-id="my-test-id"]').doesNotExist('data-test-id is stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-id="my-id"]').exists('data-id is not stripped');
assert.dom('span[data-test-id="my-test-id"]').doesNotExist('data-test-id is stripped');
});

test('it leaves data-test attributes untouched on HTML tags', function(assert) {
this.render(hbs`<span data-test="my-id" ></span>`);
test('it leaves data-test attributes untouched on HTML tags', async function(assert) {
await render(hbs`<span data-test="my-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-test="my-id"]').exists('data-test-id is not stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-test="my-id"]').exists('data-test-id is not stripped');
});

test('it leaves other data attributes untouched on HTML tags', function(assert) {
this.render(hbs`<span data-id="my-id" ></span>`);
test('it leaves other data attributes untouched on HTML tags', async function(assert) {
await render(hbs`<span data-id="my-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-id="my-id"]').exists('data-id is not stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-id="my-id"]').exists('data-id is not stripped');
});

} else {
} else {

test('it does not strip data-test-* attributes from HTML tags', function(assert) {
this.render(hbs`<span data-test-id="my-id" ></span>`);
test('it does not strip data-test-* attributes from HTML tags', async function(assert) {
await render(hbs`<span data-test-id="my-id" ></span>`);

assert.dom('span').exists('the span is present');
assert.dom('span[data-test-id="my-id"]').exists('data-test-id is not stripped');
});
assert.dom('span').exists('the span is present');
assert.dom('span[data-test-id="my-id"]').exists('data-test-id is not stripped');
});

}
}
});

0 comments on commit a8e2866

Please sign in to comment.