Skip to content

Commit 8b7834a

Browse files
authoredOct 20, 2017
Merge pull request #91 from asmundg/explode-when-out-of-emoji
Have a violent reaction when out of emoji
2 parents fface50 + 22b6213 commit 8b7834a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎lib/interpolateName.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ function encodeStringToEmoji(content, length) {
1313
length = length || 1;
1414
const emojis = [];
1515
do {
16+
if(!emojiList.length) {
17+
throw new Error("Ran out of emoji");
18+
}
19+
1620
const index = Math.floor(Math.random() * emojiList.length);
1721
emojis.push(emojiList[index]);
1822
emojiList.splice(index, 1);

‎test/interpolateName.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ describe("interpolateName()", () => {
6666
assert.equal(result1, result2);
6767
});
6868

69+
it("should throw error when out of emoji", () => {
70+
assert.throws(() => {
71+
loaderUtils.interpolateName.apply(loaderUtils, [{}, "[emoji:5000]", { content: "foo" }]);
72+
}, Error, "Ran out of emoji");
73+
});
74+
6975
context("no loader context", () => {
7076
const loaderContext = {};
7177
run([

0 commit comments

Comments
 (0)
Please sign in to comment.