discourse-subscriptions/test/javascripts/components/donation-form-test.js.es6

50 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-09-11 19:25:06 -04:00
import componentTest from "helpers/component-test";
moduleForComponent("donation-form", { integration: true });
componentTest("Discourse Patrons donation form has content", {
template: `{{donation-form}}`,
beforeEach() {
this.registry.register(
"component:stripe-card",
Ember.Component.extend({ tagName: "dummy-component-tag" })
);
2019-09-11 21:21:27 -04:00
Discourse.SiteSettings.discourse_patrons_amounts = "1.00|2.01";
2019-09-11 19:25:06 -04:00
},
2019-11-06 22:58:39 -05:00
async skip(assert) {
2019-09-11 19:25:06 -04:00
assert.ok(
find(".discourse-patrons-section-columns").length,
"The card section renders"
);
assert.ok(
find("dummy-component-tag").length,
"The stripe component renders"
);
}
});
componentTest("donation form has a confirmation", {
template: `{{donation-form confirmation=confirmation}}`,
beforeEach() {
this.registry.register("component:stripe-card", Ember.Component.extend());
2019-09-11 21:21:27 -04:00
Discourse.SiteSettings.discourse_patrons_amounts = "1.00|2.01";
2019-09-11 19:25:06 -04:00
},
async test(assert) {
this.set("confirmation", { card: { last4: "4242" } });
2019-09-12 01:52:30 -04:00
const confirmExists = find(".discourse-patrons-confirmation").length;
2019-09-11 19:25:06 -04:00
assert.ok(confirmExists, "The confirmation form renders");
2019-09-12 01:52:30 -04:00
const last4 = find(".discourse-patrons-last4")
2019-09-11 19:25:06 -04:00
.text()
.trim();
assert.equal(last4, ".... .... .... 4242", "The last 4 digits are correct");
}
});