@@ -35,20 +35,14 @@ Rectangle {
3535
3636 SignalSpy {
3737 id: spy
38+ target: previewPayments
3839 signalName: "triggered"
3940 }
4041
4142 PreviewPayments {
4243 id: previewPayments
4344 widgetId: "previewPayments"
44− widgetData: jsonPurchase
4545 width: units.gu(30)
46−
47− Rectangle {
48− anchors.fill: parent
49− color: "red"
50− opacity: 0.1
51− }
5246 }
5347
5448 UT.UnityTestCase {
@@ -60,16 +54,25 @@ Rectangle {
6054 spy.clear();
6155 }
6256
63− function test_purchase_completed() {
64− var button = findChild(root, "previewPayments");
65− verify(button != null);
66− spy.target = previewPayments;
57+ function test_purchase_text_display() {
58+ previewPayments.widgetData = jsonPurchase;
6759
60+ var button = findChild(root, "paymentButton");
61+ verify(button != null, "Button not found.");
62+ compare(button.text, "USD0.99");
63+ }
64+
65+ function test_purchase_completed() {
6866 // Exercise the purchaseCompleted signal here.
6967 previewPayments.widgetData = jsonPurchase;
68+
69+ var button = findChild(root, "paymentButton");
70+ verify(button != null, "Button not found.");
71+
7072 mouseClick(button, button.width / 2, button.height / 2);
7173
72− compare(spy.count, 1);
74+ spy.wait();
75+
7376 var args = spy.signalArguments[0];
7477 compare(args[0], "previewPayments");
7578 compare(args[1], "purchaseCompleted");
@@ -77,16 +80,17 @@ Rectangle {
7780 }
7881
7982 function test_purchase_error() {
80− var button = findChild(root, "previewPayments");
81− verify(button != null);
82− spy.target = previewPayments;
83−
8483 // The mock Payments triggers an error when com.example.invalid is
8584 // passed to it as store_item_id. Exercise it here
8685 previewPayments.widgetData = jsonPurchaseError;
86+
87+ var button = findChild(root, "paymentButton");
88+ verify(button != null, "Button not found.");
89+
8790 mouseClick(button, button.width / 2, button.height / 2);
8891
89− compare(spy.count, 1);
92+ spy.wait();
93+
9094 var args = spy.signalArguments[0];
9195 compare(args[0], "previewPayments");
9296 compare(args[1], "purchaseError");