From 323729b30ef0a796365df7c43e74629dcf3e8600 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 11 Nov 2019 22:02:13 +0100 Subject: [PATCH] tests/integration: Replace `moduleForComponent()` with `setupRenderingTest()` --- ...ta-test-attributes-from-components-test.js | 112 +++++++++--------- ...rip-data-test-attributes-from-tags-test.js | 80 +++++++------ 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/tests/integration/strip-data-test-attributes-from-components-test.js b/tests/integration/strip-data-test-attributes-from-components-test.js index d983d9d0..5cdcb08c 100644 --- a/tests/integration/strip-data-test-attributes-from-components-test.js +++ b/tests/integration/strip-data-test-attributes-from-components-test.js @@ -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'; @@ -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'); + }); + } +}); diff --git a/tests/integration/strip-data-test-attributes-from-tags-test.js b/tests/integration/strip-data-test-attributes-from-tags-test.js index 793837c8..c780119e 100644 --- a/tests/integration/strip-data-test-attributes-from-tags-test.js +++ b/tests/integration/strip-data-test-attributes-from-tags-test.js @@ -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``); + test('it strips data-test-* attributes from HTML tags', async function(assert) { + await render(hbs``); - 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``); + test('it works with multiple data-test-* attributes on HTML tags', async function(assert) { + await render(hbs``); - 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``); + 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``); - 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``); + test('it leaves data-test attributes untouched on HTML tags', async function(assert) { + await render(hbs``); - 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``); + test('it leaves other data attributes untouched on HTML tags', async function(assert) { + await render(hbs``); - 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``); + test('it does not strip data-test-* attributes from HTML tags', async function(assert) { + await render(hbs``); - 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'); + }); -} + } +});