Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
735bd32b
Commit
735bd32b
authored
Nov 10, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils): add tests for `startsWith`
parent
c7319281
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
27 deletions
+56
-27
utils.js
tests/ui/scripts/Utils/utils.js
+4
-0
utils.spec.qml
tests/ui/scripts/Utils/utils.spec.qml
+52
-27
No files found.
tests/ui/scripts/Utils/utils.js
View file @
735bd32b
...
@@ -376,6 +376,10 @@ function snakeToCamel (s) {
...
@@ -376,6 +376,10 @@ function snakeToCamel (s) {
// Test if a string starts by a given string.
// Test if a string starts by a given string.
function
startsWith
(
str
,
searchStr
)
{
function
startsWith
(
str
,
searchStr
)
{
if
(
searchStr
==
null
)
{
searchStr
=
''
}
return
str
.
slice
(
0
,
searchStr
.
length
)
===
searchStr
return
str
.
slice
(
0
,
searchStr
.
length
)
===
searchStr
}
}
...
...
tests/ui/scripts/Utils/utils.spec.qml
View file @
735bd32b
...
@@ -138,33 +138,6 @@ TestCase {
...
@@ -138,33 +138,6 @@ TestCase {
// -----------------------------------------------------------------
// -----------------------------------------------------------------
function
test_times1_data
()
{
return
[
{
cb
:
function
(
n
)
{
return
n
*
2
},
n
:
10
,
output
:
[
0
,
2
,
4
,
6
,
8
,
10
,
12
,
14
,
16
,
18
]
},
{
cb
:
function
(
n
)
{
return
n
%
2
},
n
:
6
,
output
:
[
0
,
1
,
0
,
1
,
0
,
1
]
}
]
}
function
test_times1
(
data
)
{
compare
(
Utils
.
times
(
data
.
n
,
data
.
cb
),
data
.
output
)
}
function
test_times2
()
{
var
sum
=
0
Utils
.
times
(
5
,
function
(
i
)
{
sum
+=
(
i
+
1
)
})
compare
(
sum
,
15
)
}
// -----------------------------------------------------------------
function
test_isString_data
()
{
function
test_isString_data
()
{
return
[
return
[
{
input
:
'
foo
'
,
output
:
true
},
{
input
:
'
foo
'
,
output
:
true
},
...
@@ -238,4 +211,56 @@ TestCase {
...
@@ -238,4 +211,56 @@ TestCase {
)
)
})
})
}
}
// -----------------------------------------------------------------
function
test_startsWith_data
()
{
return
[
{
string
:
'
foo
'
,
searchStr
:
undefined
,
result
:
true
},
{
string
:
'
bar
'
,
searchStr
:
null
,
result
:
true
},
{
string
:
'
abitbol
'
,
searchStr
:
'
abitboll
'
,
result
:
false
},
{
string
:
''
,
searchStr
:
NaN
,
result
:
false
},
{
string
:
''
,
searchStr
:
''
,
result
:
true
},
{
string
:
''
,
searchStr
:
Infinity
,
result
:
false
},
{
string
:
''
,
searchStr
:
0
,
result
:
false
},
{
string
:
'
george
'
,
searchStr
:
'
geo
'
,
result
:
true
},
{
string
:
'
george
'
,
searchStr
:
'
george
'
,
result
:
true
},
{
string
:
'
george
'
,
searchStr
:
'
georg
'
,
result
:
true
},
{
string
:
'
ruby
'
,
searchStr
:
''
,
result
:
true
}
]
}
function
test_startsWith
(
data
)
{
compare
(
Utils
.
startsWith
(
data
.
string
,
data
.
searchStr
),
data
.
result
)
}
// -----------------------------------------------------------------
function
test_times1_data
()
{
return
[
{
cb
:
function
(
n
)
{
return
n
*
2
},
n
:
10
,
output
:
[
0
,
2
,
4
,
6
,
8
,
10
,
12
,
14
,
16
,
18
]
},
{
cb
:
function
(
n
)
{
return
n
%
2
},
n
:
6
,
output
:
[
0
,
1
,
0
,
1
,
0
,
1
]
}
]
}
function
test_times1
(
data
)
{
compare
(
Utils
.
times
(
data
.
n
,
data
.
cb
),
data
.
output
)
}
function
test_times2
()
{
var
sum
=
0
Utils
.
times
(
5
,
function
(
i
)
{
sum
+=
(
i
+
1
)
})
compare
(
sum
,
15
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment