Skip to content

Commit

Permalink
feat: add other comp to strings lib (#18)
Browse files Browse the repository at this point in the history
* other comp

* tests

* add new key to readme

* some tests for customizing new key

---------

Co-authored-by: nexdrew <[email protected]>
  • Loading branch information
kylescarbx and nexdrew authored Oct 29, 2024
1 parent ecdb6d1 commit e22b796
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Shortcut to get the plural value defined for `key`. If a singular value is defin
- `Strings.EXTENDED_AMOUNT`
- `Strings.GROSS_MARGIN`
- `Strings.MEMBER`
- `Strings.OTHER_COMP`
- `Strings.PLAN`
- `Strings.PRODUCT`
- `Strings.PUBLISHED`
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ Strings.QUOTA = 'quota'
Strings.RULE = 'rule'
Strings.SALE = 'sale'
Strings.TRANSACTION_DATE = 'transaction_date'
Strings.OTHER_COMP = 'other_comp'
Strings.COMPENSATION = 'compensation'
Strings.REPORT = 'report'
Strings.DRAFT = 'draft'
Expand Down Expand Up @@ -347,6 +348,10 @@ Strings.DEFAULTS = {
[Strings.RULE]: 'Rule',
[Strings.SALE]: 'Sale',
[Strings.TRANSACTION_DATE]: 'Transaction Date',
[Strings.OTHER_COMP]: {
singular: 'Other Compensation',
plural: 'Other Compensation'
},
[Strings.COMPENSATION]: {
singular: 'Compensation',
plural: 'Compensation'
Expand Down
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ const strings = {
singular: 'Profit',
plural: 'Profit'
},
[Strings.OTHER_COMP]: 'Restricted Stock Unit',
[Strings.PLAN]: 'Program',
[Strings.QUOTA]: {
one: 'Plan',
Expand Down Expand Up @@ -825,6 +826,8 @@ tap.test('instance get', t => {
t.strictEqual(d.get(Strings.ANNUAL_CONTRACT_VALUE, { abbrev: true }), 'ACV')
t.strictEqual(s.get(Strings.ANNUAL_CONTRACT_VALUE, { abbrev: true }), 'ACV')
t.strictEqual(d.get(Strings.TRANSACTION_DATE, { abbrev: true }), 'TD')
t.strictEqual(d.get(Strings.OTHER_COMP, { abbrev: true }), 'OC')
t.strictEqual(s.get(Strings.OTHER_COMP, { abbrev: true }), 'RSU')

// 2rd arg object as opts with plural boolean and flu boolean
t.strictEqual(d.get(Strings.REPORT, { plural: false, flu: true }), 'Report')
Expand Down Expand Up @@ -868,6 +871,7 @@ tap.test('instance getSingular', t => {
t.strictEqual(s.getSingular(Strings.QUOTA), 'Plan')
t.strictEqual(d.getSingular(Strings.ANNUAL_CONTRACT_VALUE), 'Annual Contract Value')
t.strictEqual(s.getSingular(Strings.ANNUAL_CONTRACT_VALUE), 'Annual Contract Value')
t.strictEqual(s.getSingular(Strings.OTHER_COMP), 'Restricted Stock Unit')
t.strictEqual(d.getSingular(invalidKey), '')
t.strictEqual(s.getSingular(invalidKey), '')

Expand Down Expand Up @@ -901,6 +905,7 @@ tap.test('instance getPlural', t => {
t.strictEqual(s.getPlural(Strings.QUOTA), 'Plans')
t.strictEqual(d.getPlural(Strings.ANNUAL_CONTRACT_VALUE), 'Annual Contract Value')
t.strictEqual(s.getPlural(Strings.ANNUAL_CONTRACT_VALUE), 'Annual Contract Value')
t.strictEqual(s.getPlural(Strings.OTHER_COMP), 'Restricted Stock Units')
t.strictEqual(d.getPlural(invalidKey), '')
t.strictEqual(s.getPlural(invalidKey), '')

Expand Down Expand Up @@ -967,6 +972,8 @@ tap.test('defaults', t => {
t.strictEqual(d.getPlural(Strings.SALE), 'Sales')
t.strictEqual(d.getSingular(Strings.TRANSACTION_DATE), 'Transaction Date')
t.strictEqual(d.getPlural(Strings.TRANSACTION_DATE), 'Transaction Dates')
t.strictEqual(d.getSingular(Strings.OTHER_COMP), 'Other Compensation')
t.strictEqual(d.getPlural(Strings.OTHER_COMP), 'Other Compensation')
t.strictEqual(d.getSingular(Strings.COMPENSATION), 'Compensation')
t.strictEqual(d.getPlural(Strings.COMPENSATION), 'Compensation')
t.strictEqual(d.getSingular(Strings.REPORT), 'Report')
Expand Down

0 comments on commit e22b796

Please sign in to comment.