-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathrepeated-string.test.js
More file actions
25 lines (21 loc) · 930 Bytes
/
repeated-string.test.js
File metadata and controls
25 lines (21 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const repeatedString = require("../../src/Strings/repeated-string");
const { describe, it } = require("mocha");
const { expect } = require("chai");
describe("Repeated String", () => {
it("should return 7 with input string 'aba' and a string length of 10 to search in", () => {
expect(repeatedString("aba", 10)).to.eq(7);
});
it("should return 1 with input string 'aaaaaa' and a string length of 1 to search in", () => {
expect(repeatedString("aaaaaa", 1)).to.eq(1);
});
it("should return n if input string is 'a'", () => {
expect(repeatedString("a", 100000)).to.eq(100000);
expect(repeatedString("a", 300)).to.eq(300);
expect(repeatedString("a", 5)).to.eq(5);
});
it("should return 0 if the input string does not contain 'a'", () => {
expect(repeatedString("test", 20)).to.eq(0);
expect(repeatedString("bbbb", 7)).to.eq(0);
expect(repeatedString("cdcdcd", 5)).to.eq(0);
});
});