-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowed codemod to run on test files (#2)
* chore: Added the file extension to fixtures for v2 addon * chore: Added fixtures (failing tests) * feature: Allowed codemod to run on test files * chore: Updated fixtures * chore: Added changeset --------- Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
- Loading branch information
Showing
22 changed files
with
435 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"ember-codemod-remove-inject-as-service": minor | ||
--- | ||
|
||
Allowed codemod to run on test files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/fixtures/my-app/input/tests/integration/components/example-1-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Service, { | ||
inject as service, | ||
type Registry as Services, | ||
} from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-1', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@service private declare readonly intl: Services['intl']; | ||
|
||
get message(): string { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example1 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
tests/fixtures/my-app/input/tests/integration/components/example-5-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Service, { inject } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-5', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@inject intl; | ||
|
||
get message() { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example5 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
tests/fixtures/my-app/input/tests/integration/components/example-6-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { computed } from '@ember/object'; | ||
import Service, { inject as s } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-6', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
Service.extend({ | ||
intl: s('intl'), | ||
|
||
message: computed(function () { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
}), | ||
}), | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example6 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
tests/fixtures/my-app/input/tests/unit/services/domain-1/business-logic-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Registry as Services } from '@ember/service'; | ||
import Service from '@ember/service'; | ||
import type { TestContext as BaseTestContext } from '@ember/test-helpers'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
interface TestContext extends BaseTestContext { | ||
service: Services['domain-1/business-logic']; | ||
} | ||
|
||
module('Unit | Service | domain-1/business-logic', function (hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(function (this: TestContext) { | ||
this.owner.register( | ||
'service:current-user', | ||
class CurrentUserService extends Service { | ||
user = { | ||
name: 'Tomster', | ||
}; | ||
}, | ||
); | ||
|
||
this.service = this.owner.lookup( | ||
'service:domain-1/business-logic', | ||
) as Services['domain-1/business-logic']; | ||
}); | ||
|
||
test('message', function (this: TestContext, assert) { | ||
assert.strictEqual(this.service.message, 'Hello, Tomster!'); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
tests/fixtures/my-app/output/tests/integration/components/example-1-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Service, { | ||
service, | ||
type Registry as Services, | ||
} from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-1', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@service | ||
declare intl: Services['intl']; | ||
|
||
get message(): string { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example1 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
tests/fixtures/my-app/output/tests/integration/components/example-5-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Service, { service } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-5', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@service intl; | ||
|
||
get message() { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example5 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
tests/fixtures/my-app/output/tests/integration/components/example-6-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { computed } from '@ember/object'; | ||
import Service, { service } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-6', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
Service.extend({ | ||
intl: service('intl'), | ||
|
||
message: computed(function () { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
}), | ||
}), | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example6 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
tests/fixtures/my-app/output/tests/unit/services/domain-1/business-logic-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Registry as Services } from '@ember/service'; | ||
import Service from '@ember/service'; | ||
import type { TestContext as BaseTestContext } from '@ember/test-helpers'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
interface TestContext extends BaseTestContext { | ||
service: Services['domain-1/business-logic']; | ||
} | ||
|
||
module('Unit | Service | domain-1/business-logic', function (hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(function (this: TestContext) { | ||
this.owner.register( | ||
'service:current-user', | ||
class CurrentUserService extends Service { | ||
user = { | ||
name: 'Tomster', | ||
}; | ||
}, | ||
); | ||
|
||
this.service = this.owner.lookup( | ||
'service:domain-1/business-logic', | ||
) as Services['domain-1/business-logic']; | ||
}); | ||
|
||
test('message', function (this: TestContext, assert) { | ||
assert.strictEqual(this.service.message, 'Hello, Tomster!'); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
tests/fixtures/my-v1-addon/input/tests/integration/components/example-1-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Service, { service, type Registry as Services } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-1', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@service declare intl: Services['intl']; | ||
|
||
get message(): string { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example1 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
tests/fixtures/my-v1-addon/input/tests/integration/components/example-6-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Service, { service as s } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-6', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@s intl; | ||
|
||
get message() { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example6 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
tests/fixtures/my-v1-addon/input/tests/unit/services/domain-1/business-logic-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Registry as Services } from '@ember/service'; | ||
import Service from '@ember/service'; | ||
import type { TestContext as BaseTestContext } from '@ember/test-helpers'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
interface TestContext extends BaseTestContext { | ||
service: Services['domain-1/business-logic']; | ||
} | ||
|
||
module('Unit | Service | domain-1/business-logic', function (hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(function (this: TestContext) { | ||
this.owner.register( | ||
'service:current-user', | ||
class CurrentUserService extends Service { | ||
user = { | ||
name: 'Tomster', | ||
}; | ||
}, | ||
); | ||
|
||
this.service = this.owner.lookup( | ||
'service:domain-1/business-logic', | ||
) as Services['domain-1/business-logic']; | ||
}); | ||
|
||
test('message', function (this: TestContext, assert) { | ||
assert.strictEqual(this.service.message, 'Hello, Tomster!'); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
tests/fixtures/my-v1-addon/output/tests/integration/components/example-1-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Service, { service, type Registry as Services } from '@ember/service'; | ||
import { click, render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Integration | Component | example-1', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function (assert) { | ||
this.owner.register( | ||
'service:domain-1/business-logic', | ||
class Domain1BusinessLogicService extends Service { | ||
@service | ||
declare intl: Services['intl']; | ||
|
||
get message(): string { | ||
return this.intl.t('hello.message', { name: 'Tomster' }); | ||
} | ||
}, | ||
); | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
await render(hbs`<Example1 />`); | ||
|
||
assert.ok(true); | ||
}); | ||
}); |
Oops, something went wrong.