Skip to content

Instantly share code, notes, and snippets.

@djalmajr
Created March 4, 2022 19:49
Show Gist options
  • Save djalmajr/3f17f587e0b9ea9a59be3f79a22697ed to your computer and use it in GitHub Desktop.
Save djalmajr/3f17f587e0b9ea9a59be3f79a22697ed to your computer and use it in GitHub Desktop.
Capitalize Test
/**
* capitalize.js
*
* @param {string} str
* @returns string
*/
function capitalize(str) {
}
module.exports = { capitalize };
/**
* capitalize.test.js
*
* npx jest --runTestsByPath capitalize.test.js
*/
const { capitalize } = require('./capitalize.js');
describe('Capitalize', function () {
it('Single Word', function () {
expect(capitalize("hello")).toEqual("Hello");
});
it('Multiple Words', function () {
expect(capitalize("hello world")).toEqual("Hello World");
});
it('Outter Spaces', function () {
expect(capitalize(" hello world ")).toEqual("Hello World");
});
it('Inner Spaces', function () {
expect(capitalize("hello world")).toEqual("Hello World");
});
it('Multiple UpperCase', function () {
expect(capitalize("heLLo woRLd")).toEqual("Hello World");
});
it('All In', function () {
expect(capitalize(" heLLo woRLd ")).toEqual("Hello World");
});
});
{ "verbose": true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment