-
-
Save ross-u/e3a814d3e6d3a82d701d1a577df0f85e to your computer and use it in GitHub Desktop.
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
/* | |
FOR TEST EXAMPLES AND DIFFERENT MATCHERS (`toEqual`, `toBe`, `not.toBe`, etc): | |
https://jasmine.github.io/api/3.4/global | |
*/ | |
describe('centsToDecimals function', () => { | |
// Describes the suite / group of tests | |
// Use this test suite as a starting point/reference. | |
it('Returns undefined when parameter passed is a string.', () => { | |
// console.log(centsToDecimals('abcdef') === undefined); | |
expect(centsToDecimals('abcdef')).toEqual(undefined); | |
}); | |
// Fix the below test suites: | |
it('Returns undefined when parameter passed is a string containing number characters.', () => { | |
// console.log(centsToDecimals('12345') === undefined); | |
// ... complete the test assertion below | |
expect(centsToDecimals('12345')).toEqual(undefined); | |
}); | |
it('Returns undefined when NaN value is passed as a parameter.', () => { | |
// console.log(centsToDecimals(NaN) === undefined); | |
// ... complete the test assertion below | |
expect(centsToDecimals(NaN)).toEqual(undefined); | |
}); | |
it('Returns undefined when undefined value is passed as a parameter', () => { | |
// console.log(centsToDecimals(undefined) === undefined); | |
// ... complete the test assertion below | |
expect(centsToDecimals(undefined)).toEqual(undefined); | |
}); | |
it('Returns undefined when parameter is not passed.', () => { | |
// console.log(centsToDecimals() === undefined); | |
// ... complete the test assertion below | |
expect(centsToDecimals()).toEqual(undefined); | |
}); | |
it('Should convert a number of cents to a string representation in a floating number format.', () => { | |
// console.log(centsToDecimals(1000).slice(0, 5) === '10.00'); | |
// ... complete the test assertion below | |
expect(centsToDecimals(1000).slice(0, 5)).toEqual('10.00'); | |
// console.log(centsToDecimals(50273).slice(0, 6) === '502.73'); | |
// ... complete the test assertion below | |
expect(centsToDecimals(50273).slice(0, 6)).toEqual('502.73'); | |
// console.log(centsToDecimals(0).slice(0, 4) === '0.00'); | |
// ... complete the test assertion below | |
expect(centsToDecimals(0).slice(0, 4)).toEqual('0.00'); | |
}); | |
it('Should return a string representation of a number with `$` sign appended at the end.', () => { | |
// console.log(centsToDecimals(1000) === '10.00$'); | |
// ... complete the test assertion below | |
expect(centsToDecimals(1000)).toEqual('10.00$'); | |
// console.log(centsToDecimals(0) === '0.00$'); | |
// ... complete the test assertion below | |
expect(centsToDecimals(0)).toEqual('0.00$'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment