mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 15:22:46 +00:00
test button click
This commit is contained in:
parent
2ce314fc8d
commit
d3eed3546d
@ -0,0 +1,7 @@
|
|||||||
|
export default Ember.Component.extend({
|
||||||
|
actions: {
|
||||||
|
clickPlan(plan) {
|
||||||
|
this.selectPlan(plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -9,7 +9,10 @@ export default Ember.Controller.extend({
|
|||||||
);
|
);
|
||||||
const elements = this.get("stripe").elements();
|
const elements = this.get("stripe").elements();
|
||||||
|
|
||||||
this.set("cardElement", elements.create("card", { hidePostalCode: true, disabled: true }));
|
this.set(
|
||||||
|
"cardElement",
|
||||||
|
elements.create("card", { hidePostalCode: true, disabled: true })
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
<button class="btn btn-primary btn-discourse-subscriptions-subscribe">
|
<button class="btn btn-primary">
|
||||||
Purchase a subscription
|
Purchase a subscription
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-discourse-subscriptions-subscribe">
|
<button class="btn">
|
||||||
Make just one payment
|
Make just one payment
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@ -11,10 +11,14 @@
|
|||||||
<p>Select subscription period</p>
|
<p>Select subscription period</p>
|
||||||
|
|
||||||
<div id="subscribe-buttons">
|
<div id="subscribe-buttons">
|
||||||
{{#each plans as plan}}
|
{{#each plans as |plan|}}
|
||||||
<button class="btn btn-discourse-subscriptions-subscribe">
|
{{#d-button
|
||||||
|
action="clickPlan"
|
||||||
|
actionParam=plan
|
||||||
|
class="btn btn-discourse-subscriptions-subscribe"
|
||||||
|
}}
|
||||||
<div>Monthly</div>
|
<div>Monthly</div>
|
||||||
AUD $5.00
|
AUD $5.00
|
||||||
</button>
|
{{/d-button}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#subscribe-buttons {
|
#subscribe-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
|
@ -2,28 +2,28 @@ import componentTest from "helpers/component-test";
|
|||||||
|
|
||||||
moduleForComponent("payment-options", { integration: true });
|
moduleForComponent("payment-options", { integration: true });
|
||||||
|
|
||||||
componentTest("Discourse Subscriptions has no plans", {
|
componentTest("Discourse Subscriptions payment options have no plans", {
|
||||||
template: `{{payment-options plans=plans}}`,
|
template: `{{payment-options plans=plans}}`,
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
this.set('plans', false);
|
this.set("plans", false);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#subscribe-buttons .btn-discourse-subscriptions-subscribe").length,
|
find(".btn-discourse-subscriptions-subscribe").length,
|
||||||
0,
|
0,
|
||||||
"The plan buttons are not shown"
|
"The plan buttons are not shown"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
componentTest("Discourse Subscriptions has content", {
|
componentTest("Discourse Subscriptions payment options has content", {
|
||||||
template: `{{payment-options plans=plans}}`,
|
template: `{{payment-options plans=plans}}`,
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
this.set('plans', [1, 2]);
|
this.set("plans", [1, 2]);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#subscribe-buttons .btn-discourse-subscriptions-subscribe").length,
|
find(".btn-discourse-subscriptions-subscribe").length,
|
||||||
2,
|
2,
|
||||||
"The plan buttons are shown"
|
"The plan buttons are shown"
|
||||||
);
|
);
|
||||||
@ -34,3 +34,20 @@ componentTest("Discourse Subscriptions has content", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest("Discourse Subscriptions payment options plan is selected", {
|
||||||
|
template: `{{payment-options plans=plans selectPlan=selectPlan}}`,
|
||||||
|
|
||||||
|
beforeEach() {},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
this.set("plans", [1, 2]);
|
||||||
|
|
||||||
|
this.set("selectPlan", function(plan) {
|
||||||
|
assert.equal(plan, 1, "the plan is selected");
|
||||||
|
});
|
||||||
|
|
||||||
|
await click(".btn-discourse-subscriptions-subscribe:first-child");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user