Skip to content

Commit 8c5a508

Browse files
Merge pull request #52 from pablobm/fix-build
Fix tests
2 parents 74540fc + ed5badd commit 8c5a508

9 files changed

+185
-147
lines changed

addon/components/stripe-element.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ export default Component.extend({
66
classNames: ['ember-stripe-element'],
77

88
autofocus: false,
9-
options: {},
9+
options: null,
1010
stripeElement: null,
1111
stripeError: null,
1212
type: null, // Set in components that extend from `stripe-element`
1313

14+
init() {
15+
this._super(...arguments);
16+
set(this, 'options', {});
17+
},
18+
1419
stripev3: service(),
1520
elements: computed(function() {
1621
return get(this, 'stripev3.elements')();

ember-cli-build.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
55

66
module.exports = function(defaults) {
77
let app = new EmberAddon(defaults, {
8-
// Add options here
8+
'ember-cli-babel': {
9+
includePolyfill: true,
10+
}
911
});
1012

1113
/*

tests/dummy/app/controllers/application.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ export default Controller.extend({
2424
stripev3: service(),
2525

2626
token: null,
27+
cardOptions: null,
28+
options: null,
2729

28-
cardOptions: {
29-
hidePostalCode: true,
30-
style
31-
},
32-
33-
options: {
34-
style
30+
init() {
31+
this._super(...arguments);
32+
set(this, 'cardOptions', { hidePostalCode: true, style });
33+
set(this, 'options', { style });
3534
},
3635

3736
actions: {
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import { moduleForComponent, test } from 'ember-qunit';
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
23
import hbs from 'htmlbars-inline-precompile';
4+
import { render } from '@ember/test-helpers';
35
import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
46
import env from 'dummy/config/environment';
7+
import StripeService from 'dummy/services/stripev3';
58

6-
moduleForComponent('stripe-card-cvc', 'Integration | Component | stripe card cvc', {
7-
integration: true,
8-
beforeEach() {
9-
window.Stripe = StripeMock;
9+
module('Integration | Component | stripe card cvc', function(hooks) {
10+
setupRenderingTest(hooks);
1011

11-
let config = {
12+
hooks.beforeEach(function() {
13+
window.Stripe = StripeMock;
14+
const config = {
1215
mock: true,
13-
publishableKey: env.stripe.publishableKey
16+
publishableKey: env.stripe.publishableKey,
1417
};
1518

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+
});
2025

21-
test('it renders', function(assert) {
22-
this.render(hbs`{{stripe-card-cvc}}`);
26+
test('it renders', async function(assert) {
27+
await render(hbs`{{stripe-card-cvc}}`);
2328

24-
assert.equal(this.$().text().trim(), '');
29+
assert.equal(this.element.textContent.trim(), '');
30+
});
2531
});
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import { moduleForComponent, test } from 'ember-qunit';
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
23
import hbs from 'htmlbars-inline-precompile';
4+
import { render } from '@ember/test-helpers';
35
import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
46
import env from 'dummy/config/environment';
7+
import StripeService from 'dummy/services/stripev3';
58

6-
moduleForComponent('stripe-card-expiry', 'Integration | Component | stripe card expiry', {
7-
integration: true,
8-
beforeEach() {
9-
window.Stripe = StripeMock;
9+
module('Integration | Component | stripe card expiry', function(hooks) {
10+
setupRenderingTest(hooks);
1011

11-
let config = {
12+
hooks.beforeEach(function() {
13+
window.Stripe = StripeMock;
14+
const config = {
1215
mock: true,
13-
publishableKey: env.stripe.publishableKey
16+
publishableKey: env.stripe.publishableKey,
1417
};
1518

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+
});
2025

21-
test('it renders', function(assert) {
22-
this.render(hbs`{{stripe-card-expiry}}`);
26+
test('it renders', async function(assert) {
27+
await render(hbs`{{stripe-card-expiry}}`);
2328

24-
assert.equal(this.$().text().trim(), '');
29+
assert.equal(this.element.textContent.trim(), '');
30+
});
2531
});
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
import { moduleForComponent, test } from 'ember-qunit';
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
23
import hbs from 'htmlbars-inline-precompile';
4+
import { render } from '@ember/test-helpers';
35
import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
46
import env from 'dummy/config/environment';
7+
import StripeService from 'dummy/services/stripev3';
58

6-
moduleForComponent('stripe-card-number', 'Integration | Component | stripe card number', {
7-
integration: true,
8-
beforeEach() {
9-
window.Stripe = StripeMock;
9+
module('Integration | Component | stripe card number', function(hooks) {
10+
setupRenderingTest(hooks);
1011

11-
let config = {
12+
hooks.beforeEach(function() {
13+
window.Stripe = StripeMock;
14+
const config = {
1215
mock: true,
13-
publishableKey: env.stripe.publishableKey
16+
publishableKey: env.stripe.publishableKey,
1417
};
1518

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+
});
2025

21-
test('it renders', function(assert) {
22-
this.render(hbs`{{stripe-card-number}}`);
26+
test('it renders', async function(assert) {
27+
await render(hbs`{{stripe-card-number}}`);
2328

24-
assert.equal(this.$().text().trim(), '');
29+
assert.equal(this.element.textContent.trim(), '');
30+
});
2531
});
32+
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
1-
import { moduleForComponent, test } from 'ember-qunit';
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
23
import hbs from 'htmlbars-inline-precompile';
4+
import { render } from '@ember/test-helpers';
35
import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
46
import env from 'dummy/config/environment';
7+
import StripeService from 'dummy/services/stripev3';
58

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);
1011

11-
let config = {
12+
hooks.beforeEach(function() {
13+
window.Stripe = StripeMock;
14+
const config = {
1215
mock: true,
13-
publishableKey: env.stripe.publishableKey
16+
publishableKey: env.stripe.publishableKey,
1417
};
1518

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+
});
2025

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+
`);
2833

29-
assert.equal(this.$().text().trim(), 'template block text');
30-
});
34+
assert.equal(this.element.textContent.trim(), 'template block text');
35+
});
3136

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+
`);
3944

40-
assert.equal(this.$().text().trim(), 'oops');
45+
assert.equal(this.element.textContent.trim(), 'oops');
46+
});
4147
});
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import { moduleForComponent, test } from 'ember-qunit';
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
23
import hbs from 'htmlbars-inline-precompile';
4+
import { render } from '@ember/test-helpers';
35
import StripeMock from 'ember-stripe-elements/utils/stripe-mock';
46
import env from 'dummy/config/environment';
7+
import StripeService from 'dummy/services/stripev3';
58

6-
moduleForComponent('stripe-postal-code', 'Integration | Component | stripe postal code', {
7-
integration: true,
8-
beforeEach() {
9-
window.Stripe = StripeMock;
9+
module('Integration | Component | stripe postal code', function(hooks) {
10+
setupRenderingTest(hooks);
1011

11-
let config = {
12+
hooks.beforeEach(function() {
13+
window.Stripe = StripeMock;
14+
const config = {
1215
mock: true,
13-
publishableKey: env.stripe.publishableKey
16+
publishableKey: env.stripe.publishableKey,
1417
};
1518

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+
});
2025

21-
test('it renders', function(assert) {
22-
this.render(hbs`{{stripe-postal-code}}`);
26+
test('it renders', async function(assert) {
27+
await render(hbs`{{stripe-postal-code}}`);
2328

24-
assert.equal(this.$().text().trim(), '');
29+
assert.equal(this.element.textContent.trim(), '');
30+
});
2531
});

0 commit comments

Comments
 (0)