spec: convert IAP and GC specs to expect (#13272)
* spec: convert IAP and GC specs to expect * address review
This commit is contained in:
parent
994f613450
commit
b4cce8e240
2 changed files with 34 additions and 19 deletions
|
@ -1,8 +1,12 @@
|
||||||
const {globalShortcut} = require('electron').remote
|
const {globalShortcut} = require('electron').remote
|
||||||
|
|
||||||
const assert = require('assert')
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
const isCI = require('electron').remote.getGlobal('isCi')
|
const isCI = require('electron').remote.getGlobal('isCi')
|
||||||
|
|
||||||
|
const {expect} = chai
|
||||||
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
describe('globalShortcut module', () => {
|
describe('globalShortcut module', () => {
|
||||||
before(function () {
|
before(function () {
|
||||||
if (isCI && process.platform === 'win32') {
|
if (isCI && process.platform === 'win32') {
|
||||||
|
@ -17,16 +21,16 @@ describe('globalShortcut module', () => {
|
||||||
it('can register and unregister accelerators', () => {
|
it('can register and unregister accelerators', () => {
|
||||||
const accelerator = 'CommandOrControl+A+B+C'
|
const accelerator = 'CommandOrControl+A+B+C'
|
||||||
|
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
||||||
globalShortcut.register(accelerator, () => {})
|
globalShortcut.register(accelerator, () => {})
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), true)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.true()
|
||||||
globalShortcut.unregister(accelerator)
|
globalShortcut.unregister(accelerator)
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
||||||
|
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
||||||
globalShortcut.register(accelerator, () => {})
|
globalShortcut.register(accelerator, () => {})
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), true)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.true()
|
||||||
globalShortcut.unregisterAll()
|
globalShortcut.unregisterAll()
|
||||||
assert.equal(globalShortcut.isRegistered(accelerator), false)
|
expect(globalShortcut.isRegistered(accelerator)).to.be.false()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const assert = require('assert')
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
|
||||||
|
const {expect} = chai
|
||||||
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
const {remote} = require('electron')
|
const {remote} = require('electron')
|
||||||
|
|
||||||
|
@ -12,38 +16,45 @@ describe('inAppPurchase module', function () {
|
||||||
const {inAppPurchase} = remote
|
const {inAppPurchase} = remote
|
||||||
|
|
||||||
it('canMakePayments() does not throw', () => {
|
it('canMakePayments() does not throw', () => {
|
||||||
inAppPurchase.canMakePayments()
|
expect(() => {
|
||||||
|
inAppPurchase.canMakePayments()
|
||||||
|
}).to.not.throw()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finishAllTransactions() does not throw', () => {
|
it('finishAllTransactions() does not throw', () => {
|
||||||
inAppPurchase.finishAllTransactions()
|
expect(() => {
|
||||||
|
inAppPurchase.finishAllTransactions()
|
||||||
|
}).to.not.throw()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finishTransactionByDate() does not throw', () => {
|
it('finishTransactionByDate() does not throw', () => {
|
||||||
inAppPurchase.finishTransactionByDate(new Date().toISOString())
|
expect(() => {
|
||||||
|
inAppPurchase.finishTransactionByDate(new Date().toISOString())
|
||||||
|
}).to.not.throw()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getReceiptURL() returns receipt URL', () => {
|
it('getReceiptURL() returns receipt URL', () => {
|
||||||
assert.ok(inAppPurchase.getReceiptURL().endsWith('_MASReceipt/receipt'))
|
const correctUrlEnd = inAppPurchase.getReceiptURL().endsWith('_MASReceipt/receipt')
|
||||||
|
expect(correctUrlEnd).to.be.true()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('purchaseProduct() fails when buying invalid product', (done) => {
|
it('purchaseProduct() fails when buying invalid product', done => {
|
||||||
inAppPurchase.purchaseProduct('non-exist', 1, (success) => {
|
inAppPurchase.purchaseProduct('non-exist', 1, success => {
|
||||||
assert.ok(!success)
|
expect(success).to.be.false()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('purchaseProduct() accepts optional arguments', (done) => {
|
it('purchaseProduct() accepts optional arguments', done => {
|
||||||
inAppPurchase.purchaseProduct('non-exist', () => {
|
inAppPurchase.purchaseProduct('non-exist', () => {
|
||||||
inAppPurchase.purchaseProduct('non-exist', 1)
|
inAppPurchase.purchaseProduct('non-exist', 1)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getProducts() returns an empty list when getting invalid product', (done) => {
|
it('getProducts() returns an empty list when getting invalid product', done => {
|
||||||
inAppPurchase.getProducts(['non-exist'], (products) => {
|
inAppPurchase.getProducts(['non-exist'], products => {
|
||||||
assert.ok(products.length === 0)
|
expect(products).to.be.an('array').of.length(0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue