Skip to content

Commit

Permalink
Add helper.test.ts comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Nov 19, 2024
1 parent e3b14fd commit 1651e41
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/tests/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,47 @@ import * as helper from '../src/common/helper'

describe('Test string to boolean', () => {
it('should convert a string to boolean', () => {
// test success (true)
expect(helper.StringToBoolean('true')).toBeTruthy()
// test success (false)
expect(helper.StringToBoolean('false')).toBeFalsy()
// test success (falsy value)
expect(helper.StringToBoolean('')).toBeFalsy()
})
})

describe('Test join url', () => {
it('should join two url parts', () => {
// test success (second part starts with slash)
expect(helper.joinURL('part1/', '/part2')).toBe('part1/part2')
// test success (first part not ending with slash)
expect(helper.joinURL('part1', '/part2')).toBe('part1/part2')
// test success (second part not starting with slash)
expect(helper.joinURL('part1/', 'part2')).toBe('part1/part2')
})
})

describe('Test clone', () => {
it('should clone an object or an array', () => {
// test success (object)
expect(helper.clone({ foo: 'bar' })).toStrictEqual({ foo: 'bar' })
// test success (array)
expect(helper.clone([1, 2, 3])).toStrictEqual([1, 2, 3])
})
})

describe('Test trim', () => {
it('should test trim', () => {
// test success (begins and ends with spaces)
expect(helper.trim(' xxxxxxxx ', ' ')).toBe('xxxxxxxx')
})
})

describe('Test getStripeLocale', () => {
it('should test getStripeLocale', () => {
// test success (value found)
expect(helper.getStripeLocale('en')).toBe('en')
// test success (value not found so should return default one)
expect(helper.getStripeLocale('')).toBe('auto')
})
})

0 comments on commit 1651e41

Please sign in to comment.