From bdeb979d412e727bf5727da4fe053bcf94420966 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 10 Jan 2018 15:21:53 +0900 Subject: [PATCH] spec: Simple tests for inAppPurchase module --- spec/api-in-app-purchase-spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/api-in-app-purchase-spec.js diff --git a/spec/api-in-app-purchase-spec.js b/spec/api-in-app-purchase-spec.js new file mode 100644 index 0000000000..541a2af2f6 --- /dev/null +++ b/spec/api-in-app-purchase-spec.js @@ -0,0 +1,25 @@ +'use strict' + +const assert = require('assert') + +const {remote} = require('electron') +const {inAppPurchase} = remote + +describe('inAppPurchase module', () => { + if (process.platform !== 'darwin') return + + it('canMakePayments() does not throw', () => { + inAppPurchase.canMakePayments() + }) + + it('getReceiptURL() returns receipt URL', () => { + assert.ok(inAppPurchase.getReceiptURL().endsWith('_MASReceipt/receipt')) + }) + + it('purchaseProduct() fails when buying invalid product', (done) => { + inAppPurchase.purchaseProduct('non-exist', 1, (success) => { + assert.ok(!success) + done() + }) + }) +})