Skip to content

Commit

Permalink
fix(remove-from): rename removeString and fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed Dec 21, 2020
1 parent ecf9376 commit 883c90e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 65 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center"><a href="https://www.npmjs.com/package/polyfig"><img src="./img/logo.png" height="69"></a></p>
<p align="center">
<b>A simple JavaScript utilities library</b>
<b>A simple JavaScript utility library</b>
<br />
<br />
<a href="https://www.npmjs.com/package/polyfig"><img alt="npm" src="https://img.shields.io/npm/v/polyfig?color=%23301934"></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center"><a href="https://www.npmjs.com/package/polyfig"><img src="https://github.com/JamieSlome/polyfig/raw/main/img/logo.png" height="69"></a></p>
<p align="center">
<b>A simple JavaScript utilities library</b>
<b>A simple JavaScript utility library</b>
<br />
<br />
<a href="https://www.npmjs.com/package/polyfig"><img alt="npm" src="https://img.shields.io/npm/v/polyfig?color=%23301934"></a>
Expand Down
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const getEasterEgg = require("./util/getEasterEgg");
const removeString = require("./util/removeString");
const removeFrom = require("./util/removeFrom");

module.exports = {
getEasterEgg,
removeString
removeFrom
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "polyfig",
"version": "1.0.0",
"description": "A simple JavaScript utilities library",
"description": "A simple JavaScript utility library",
"main": "index.js",
"scripts": {
"test": "mocha ./test"
Expand Down
28 changes: 6 additions & 22 deletions test/polyfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,16 @@ const expect = require("chai").expect;
require("chai").should();

describe("polyfig", function () {
describe("getEasterEgg", function () {
describe("removeFrom", function () {
it("should exist as a method", function () {
expect(polyfig.getEasterEgg).to.exist;
});

it("should get the easter egg", function () {
const outcome = polyfig.getEasterEgg();
outcome.should.equal(
"A package with a great name, but no great meaning; yet."
);
});
});

describe("removeString", function () {
it("should exist as a method", function () {
expect(polyfig.removeString).to.exist;
expect(polyfig.removeFrom).to.exist;
});

it("should remove all occurrences of a string from another", function () {
const item = "polyfig";
const otherItem =
"polyfig is a package with a great name, but no great meaning; yet.";
const outcome = polyfig.removeString(item, otherItem);
outcome.should.equal(
" is a package with a great name, but no great meaning; yet."
);
const x = "polyfig is a simple JavaScript utility library";
const y = "polyfig";
const outcome = polyfig.removeFrom(x, y);
outcome.should.equal(" is a simple JavaScript utility library");
});
});
});
15 changes: 0 additions & 15 deletions util/getEasterEgg.js

This file was deleted.

23 changes: 23 additions & 0 deletions util/removeFrom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
*
* Summary - Remove from `x` all of `y`
*
* Description - This method removes
* all occurrences of *string* `y` from *string* `x`
*
* @name removeFrom
*
* @param {string} x - string
* @param {string} y - string
*
* @since 1.0.0
* @access public
*
* @return `x` with all occurrences of `y` removed
*/

module.exports = (x, y) => {
return typeof x === "string" && typeof y === "string"
? x.split(y).join("")
: new Error("Both inputs are not of type string");
};
21 changes: 0 additions & 21 deletions util/removeString.js

This file was deleted.

0 comments on commit 883c90e

Please sign in to comment.