Skip to content

Commit

Permalink
Add some documentation to our helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks committed Nov 13, 2022
1 parent b26c828 commit d749826
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/support/helpers/charge_version.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand Down
11 changes: 11 additions & 0 deletions test/support/helpers/licence.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit d749826

Please sign in to comment.