-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved getter functionality into new quals util
- Loading branch information
1 parent
3e02084
commit 0d3c643
Showing
3 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
backend/server/test/unit/utils/qualificationsUtils.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const expect = require('chai').expect; | ||
|
||
const { formatQualificationTitle } = require('../../../utils/qualificationsUtils'); | ||
const { registrationWithUser, convertedRegistrationResponse } = require('../mockdata/registration'); | ||
|
||
describe('qualificationsUtils', () => { | ||
describe('formatQualificationTitle', () => { | ||
it('should return the title unchanged when no level is provided', () => { | ||
const title = 'This is a qual'; | ||
const level = null; | ||
|
||
const returnedValue = formatQualificationTitle(title, level); | ||
|
||
expect(returnedValue).to.deep.equal(title); | ||
}); | ||
|
||
describe('level is provided', () => { | ||
it('should return the title with the level in brackets', () => { | ||
const title = 'This is a qual'; | ||
const level = '4'; | ||
|
||
const returnedValue = formatQualificationTitle(title, level); | ||
|
||
expect(returnedValue).to.deep.equal('This is a qual (level 4)'); | ||
}); | ||
}) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
module.exports.formatQualificationTitle = (title, level) => { | ||
if (level) { | ||
if (title.endsWith(')')) { | ||
const sub = title.substring(0, title.length - 1); | ||
return `${sub}, level ${level})`; | ||
} else { | ||
return `${title} (level ${level})`; | ||
} | ||
} | ||
return title; | ||
} |