diff --git a/test/support/helpers/charge_version.helper.js b/test/support/helpers/charge_version.helper.js index dd31238cea..07eaf4f1e6 100644 --- a/test/support/helpers/charge_version.helper.js +++ b/test/support/helpers/charge_version.helper.js @@ -9,7 +9,25 @@ const { db } = require('../../../db/db') const LicenceHelper = require('./licence.helper.js') class ChargeVersionHelper { - static async add (data, licence = {}) { + /** + * Add a new charge version + * + * A charge version is always linked to a licence. So, creating a charge version will automatically create a new + * licence and handle linking the two together by `licence_id`. + * + * If no `data` is provided, default values will be used. These are + * + * - `scheme` - sroc + * - `licence_ref` - 01/123 + * + * See `LicenceHelper` for the licence defaults + * + * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database + * @param {Object} [licence] Any licence data you want to use instead of the defaults used here or in the database + * + * @returns {string} The ID of the newly created record + */ + static async add (data = {}, licence = {}) { const licenceId = await this._addLicence(licence) const insertData = this._defaults({ ...data, licence_id: licenceId }) diff --git a/test/support/helpers/licence.helper.js b/test/support/helpers/licence.helper.js index 6712afe500..8cd1b0fd0c 100644 --- a/test/support/helpers/licence.helper.js +++ b/test/support/helpers/licence.helper.js @@ -7,6 +7,17 @@ const { db } = require('../../../db/db') class LicenceHelper { + /** + * Add a new licence + * + * If no `data` is provided, default values will be used. These are + * + * - `licence_ref` - 01/123 + * + * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database + * + * @returns {string} The ID of the newly created record + */ static async add (data) { const insertData = this._defaults(data) const result = await db.table('water.licences')