api-in-app-purchase-spec.js 821 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict'
  2. const assert = require('assert')
  3. const {remote} = require('electron')
  4. describe('inAppPurchase module', () => {
  5. if (process.platform !== 'darwin') return
  6. const {inAppPurchase} = remote
  7. it('canMakePayments() does not throw', () => {
  8. inAppPurchase.canMakePayments()
  9. })
  10. it('getReceiptURL() returns receipt URL', () => {
  11. assert.ok(inAppPurchase.getReceiptURL().endsWith('_MASReceipt/receipt'))
  12. })
  13. it('purchaseProduct() fails when buying invalid product', (done) => {
  14. inAppPurchase.purchaseProduct('non-exist', 1, (success) => {
  15. assert.ok(!success)
  16. done()
  17. })
  18. })
  19. it('purchaseProduct() accepts optional arguments', (done) => {
  20. inAppPurchase.purchaseProduct('non-exist', () => {
  21. inAppPurchase.purchaseProduct('non-exist', 1)
  22. done()
  23. })
  24. })
  25. })