FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/String/test/CountSubstrings.test.js at master · TheAlgorithms/JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TheAlgorithms
/
JavaScript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
5.8k
Star
34.2k
Code
Issues
21
Pull requests
192
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
String
/
test
/
CountSubstrings.test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (45 loc) · 1.61 KB
Breadcrumbs
JavaScript
/
String
/
test
/
CountSubstrings.test.js
Copy path
File metadata and controls
52 lines (45 loc) · 1.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import
{
countSubstrings
}
from
'../CountSubstrings'
describe
(
'CountSubstrings'
,
(
)
=>
{
it
(
'count multiple occurrences of substring in a string'
,
(
)
=>
{
const
str
=
'This is a string'
const
substring
=
'is'
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
2
)
}
)
it
(
'should return 0 when input substring has no occurrences'
,
(
)
=>
{
const
str
=
'Jurassic Park'
const
substring
=
'World'
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
0
)
}
)
it
(
'should return 1 when input substring is of length 1 that is equal to string'
,
(
)
=>
{
const
str
=
's'
const
substring
=
's'
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
1
)
}
)
it
(
'should return the correct result when input string contains spaces'
,
(
)
=>
{
const
str
=
'ab cd ef ghi'
const
substring
=
' '
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
4
)
}
)
it
(
'should return the correct result when input substring contains number or special characters'
,
(
)
=>
{
const
str
=
'abc1@2def1@2'
const
substring
=
'1@2'
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
2
)
}
)
it
(
'should return string.length + 1 when the input substring is an empty string'
,
(
)
=>
{
const
str
=
'empty'
const
substring
=
''
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
6
)
}
)
it
(
'should return correct result when input is overlapping substring'
,
(
)
=>
{
const
str
=
'aaa'
const
substring
=
'aa'
const
count
=
countSubstrings
(
str
,
substring
)
expect
(
count
)
.
toBe
(
2
)
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL