|
1 |
| -import { moduleForComponent, test } from 'ember-qunit'; |
| 1 | +import { module, test } from 'qunit'; |
| 2 | +import { setupRenderingTest } from 'ember-qunit'; |
2 | 3 | import hbs from 'htmlbars-inline-precompile';
|
| 4 | +import { render } from '@ember/test-helpers'; |
3 | 5 | import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
|
4 | 6 | import env from 'dummy/config/environment';
|
| 7 | +import StripeService from 'dummy/services/stripev3'; |
5 | 8 |
|
6 |
| -moduleForComponent('stripe-card', 'Integration | Component | stripe card', { |
7 |
| - integration: true, |
8 |
| - beforeEach() { |
9 |
| - window.Stripe = StripeMock; |
| 9 | +module('Integration | Component | stripe card', function(hooks) { |
| 10 | + setupRenderingTest(hooks); |
10 | 11 |
|
11 |
| - let config = { |
| 12 | + hooks.beforeEach(function() { |
| 13 | + window.Stripe = StripeMock; |
| 14 | + const config = { |
12 | 15 | mock: true,
|
13 |
| - publishableKey: env.stripe.publishableKey |
| 16 | + publishableKey: env.stripe.publishableKey, |
14 | 17 | };
|
15 | 18 |
|
16 |
| - this.register('config:stripe', config, { instantiate: false }); |
17 |
| - this.inject.service('stripev3', 'config', 'config:stripe'); |
18 |
| - } |
19 |
| -}); |
| 19 | + this.owner.register( |
| 20 | + 'service:stripev3', |
| 21 | + StripeService.create({ config }), |
| 22 | + { instantiate: false } |
| 23 | + ); |
| 24 | + }); |
20 | 25 |
|
21 |
| -test('it renders', function(assert) { |
22 |
| - // Template block usage: |
23 |
| - this.render(hbs` |
24 |
| - {{#stripe-card}} |
25 |
| - template block text |
26 |
| - {{/stripe-card}} |
27 |
| - `); |
| 26 | + test('it renders', async function(assert) { |
| 27 | + // Template block usage: |
| 28 | + await render(hbs` |
| 29 | + {{#stripe-card}} |
| 30 | + template block text |
| 31 | + {{/stripe-card}} |
| 32 | + `); |
28 | 33 |
|
29 |
| - assert.equal(this.$().text().trim(), 'template block text'); |
30 |
| -}); |
| 34 | + assert.equal(this.element.textContent.trim(), 'template block text'); |
| 35 | + }); |
31 | 36 |
|
32 |
| -test('yields out error message', function(assert) { |
33 |
| - this.stripeError = { message: 'oops' }; |
34 |
| - this.render(hbs` |
35 |
| - {{#stripe-card stripeError=stripeError as |stripeElement stripeError|}} |
36 |
| - {{stripeError.message}} |
37 |
| - {{/stripe-card}} |
38 |
| - `); |
| 37 | + test('yields out error message', async function(assert) { |
| 38 | + this.stripeError = { message: 'oops' }; |
| 39 | + await this.render(hbs` |
| 40 | + {{#stripe-card stripeError=stripeError as |stripeElement stripeError|}} |
| 41 | + {{stripeError.message}} |
| 42 | + {{/stripe-card}} |
| 43 | + `); |
39 | 44 |
|
40 |
| - assert.equal(this.$().text().trim(), 'oops'); |
| 45 | + assert.equal(this.element.textContent.trim(), 'oops'); |
| 46 | + }); |
41 | 47 | });
|
0 commit comments