forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi-in-app-purchase-spec.js
61 lines (48 loc) · 1.54 KB
/
api-in-app-purchase-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const { expect } = chai
chai.use(dirtyChai)
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', () => {
expect(() => {
inAppPurchase.canMakePayments()
}).to.not.throw()
})
it('finishAllTransactions() does not throw', () => {
expect(() => {
inAppPurchase.finishAllTransactions()
}).to.not.throw()
})
it('finishTransactionByDate() does not throw', () => {
expect(() => {
inAppPurchase.finishTransactionByDate(new Date().toISOString())
}).to.not.throw()
})
it('getReceiptURL() returns receipt URL', () => {
const correctUrlEnd = inAppPurchase.getReceiptURL().endsWith('_MASReceipt/receipt')
expect(correctUrlEnd).to.be.true()
})
it('purchaseProduct() fails when buying invalid product', done => {
inAppPurchase.purchaseProduct('non-exist', 1, success => {
expect(success).to.be.false()
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 => {
expect(products).to.be.an('array').of.length(0)
done()
})
})
})