/api/administrator/subscriptions/invoices-count (GET)
Account information like email addresses is generated with faker-js it is not real user information.
await global.api.administrator.subscriptions.InvoicesCount.get(req)NodeJS source (view on github)
const subscriptions = require('../../../../../index.js')
module.exports = {
get: async (req) => {
return subscriptions.Storage.Invoice.count({
where: {
appid: req.appid || global.appid
}
})
}
}
Test source (view on github)
/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')
const TestStripeAccounts = require('../../../../../test-stripe-accounts.js')
describe('/api/administrator/subscriptions/invoices-count', function () {
before(TestHelper.disableMetrics)
after(TestHelper.enableMetrics)
describe('returns', () => {
it('integer', async () => {
const administrator = await TestStripeAccounts.createOwnerWithPrice({
active: 'true',
currency: 'usd',
recurring_interval: 'month',
recurring_interval_count: '1',
recurring_usage_type: 'metered',
recurring_aggregate_usage: 'sum',
billing_scheme: 'tiered',
tax_behavior: 'inclusive',
tiers_mode: 'volume',
tier1_up_to: '1000',
tier1_flat_amount: '9999',
tier2_up_to: 'inf',
tier2_flat_amount: '8999'
})
for (let i = 0, len = global.pageSize + 1; i < len; i++) {
await TestStripeAccounts.createUserWithPaidSubscription(administrator.price)
}
const req = TestHelper.createRequest('/api/administrator/subscriptions/invoices-count')
req.account = administrator.account
req.session = administrator.session
req.filename = __filename
req.saveResponse = true
const result = await req.get()
assert.strictEqual(result, global.pageSize + 1)
})
})
})