/api/administrator/organizations/organizations-count (GET)
Account information like email addresses is generated with faker-js it is not real user information.
await global.api.administrator.organizations.OrganizationsCount.get(req)NodeJS source (view on github)
const organizations = require('../../../../../index.js')
module.exports = {
get: async (req) => {
const where = {
appid: req.appid || global.appid
}
if (req.query) {
if (req.query.accountid) {
where.accountid = req.query.accountid
}
}
return organizations.Storage.Organization.count({
where
})
}
}
Test source (view on github)
/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')
describe('/api/administrator/organizations/organizations-count', () => {
describe('returns', () => {
it('integer', async () => {
const administrator = await TestHelper.createOwner()
for (let i = 0, len = global.pageSize + 1; i < len; i++) {
const user = await TestHelper.createUser()
global.userProfileFields = ['display-email', 'display-name']
await TestHelper.createProfile(user, {
'display-name': user.profile.fullName,
'display-email': user.profile.contactEmail
})
await TestHelper.createOrganization(user, {
email: user.profile.displayEmail,
name: 'My organization',
profileid: user.profile.profileid,
pin: `1234${i}`
})
}
const req = TestHelper.createRequest('/api/administrator/organizations/organizations-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)
})
})
})