electron/spec/api-in-app-purchase-spec.js
Adrien Fery 5486a65702 Improve in-app purchase for MacOS (#12464)
* Add methods to finish transactions

* Add a method to get the product descriptions from the App Store

* Improve the documentation of a transaction structure

* Add a tutorial for In App Purchase

* Fix typo in In-App Purchase tutorial

* Fix style of In-App Purchase files

* Fix In-App-Purchase product structure conversion in amr64

* Fix code style in In-App Purchase tutorial documentation

* Fix typos in In-App Purchase documentation

* Fix typo in In-App Purchase spec

* Slight style fixes
2018-04-05 15:33:13 +09:00

50 lines
1.3 KiB
JavaScript

'use strict'
const assert = require('assert')
const {remote} = require('electron')
describe('inAppPurchase module', function () {
if (process.platform !== 'darwin') return
this.timeout(3 * 60 * 1000)
const {inAppPurchase} = remote
it('canMakePayments() does not throw', () => {
inAppPurchase.canMakePayments()
})
it('finishAllTransactions() does not throw', () => {
inAppPurchase.finishAllTransactions()
})
it('finishTransactionByDate() does not throw', () => {
inAppPurchase.finishTransactionByDate(new Date().toISOString())
})
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()
})
})
it('purchaseProduct() accepts optional arguments', (done) => {
inAppPurchase.purchaseProduct('non-exist', () => {
inAppPurchase.purchaseProduct('non-exist', 1)
done()
})
})
it('getProducts() returns an empty list when getting invalid product', (done) => {
inAppPurchase.getProducts(['non-exist'], (products) => {
assert.ok(products.length === 0)
done()
})
})
})