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
4dd1fd2d
Commit
4dd1fd2d
authored
Nov 10, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils): add tests for `includes`
parent
e92e44f2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
utils.js
tests/ui/scripts/Utils/utils.js
+5
-1
utils.spec.qml
tests/ui/scripts/Utils/utils.spec.qml
+36
-2
No files found.
tests/ui/scripts/Utils/utils.js
View file @
4dd1fd2d
...
@@ -343,7 +343,11 @@ function includes (obj, value, startIndex) {
...
@@ -343,7 +343,11 @@ function includes (obj, value, startIndex) {
var
length
=
obj
.
length
var
length
=
obj
.
length
for
(
var
i
=
startIndex
;
i
<
length
;
i
++
)
{
for
(
var
i
=
startIndex
;
i
<
length
;
i
++
)
{
if
(
value
===
obj
[
i
])
{
if
(
value
===
obj
[
i
]
||
// Check `NaN`.
(
value
!==
value
&&
obj
[
i
]
!==
obj
[
i
])
)
{
return
true
return
true
}
}
}
}
...
...
tests/ui/scripts/Utils/utils.spec.qml
View file @
4dd1fd2d
...
@@ -181,6 +181,39 @@ TestCase {
...
@@ -181,6 +181,39 @@ TestCase {
// -----------------------------------------------------------------
// -----------------------------------------------------------------
function
test_includes_data
()
{
return
[
// Test arrays.
{
input
:
[],
value
:
0
,
output
:
false
},
{
input
:
[
1
,
2
,
3
],
value
:
4
,
output
:
false
},
{
input
:
[
6
],
value
:
6
,
output
:
true
},
{
input
:
[
4
,
8
,
'
foo
'
],
value
:
8
,
output
:
true
},
{
input
:
[
12
,
NaN
,
47
],
value
:
NaN
,
output
:
true
},
{
input
:
Array
(
1
),
value
:
undefined
,
output
:
true
},
{
input
:
[
'
a
'
,
'
b
'
,
'
c
'
],
startIndex
:
1
,
value
:
'
a
'
,
output
:
false
},
{
input
:
[
6
,
5
,
4
,
9
],
startIndex
:
3
,
value
:
9
,
output
:
true
},
// Test objects.
{
input
:
{},
value
:
0
,
output
:
false
},
{
input
:
{
a
:
1
,
b
:
2
,
c
:
3
},
value
:
4
,
output
:
false
},
{
input
:
{
a
:
6
},
value
:
6
,
output
:
true
},
{
input
:
{
a
:
4
,
b
:
8
,
c
:
'
foo
'
},
value
:
8
,
output
:
true
},
{
input
:
{
a
:
12
,
b
:
NaN
,
c
:
47
},
value
:
NaN
,
output
:
true
},
{
input
:
new
Object
(),
value
:
undefined
,
output
:
false
},
{
input
:
{
a
:
'
a
'
,
b
:
'
b
'
,
c
:
'
c
'
},
startIndex
:
1
,
value
:
'
a
'
,
output
:
false
},
{
input
:
{
a
:
6
,
b
:
5
,
c
:
4
,
d
:
9
},
startIndex
:
3
,
value
:
9
,
output
:
true
},
]
}
function
test_includes
(
data
)
{
compare
(
Utils
.
includes
(
data
.
input
,
data
.
value
,
data
.
startIndex
),
data
.
output
)
}
// -----------------------------------------------------------------
function
test_isArray_data
()
{
function
test_isArray_data
()
{
return
[
return
[
{
input
:
[],
output
:
true
},
{
input
:
[],
output
:
true
},
...
@@ -190,7 +223,8 @@ TestCase {
...
@@ -190,7 +223,8 @@ TestCase {
{
input
:
new
Error
,
output
:
false
},
{
input
:
new
Error
,
output
:
false
},
{
input
:
true
,
output
:
false
},
{
input
:
true
,
output
:
false
},
{
input
:
42
,
output
:
false
},
{
input
:
42
,
output
:
false
},
{
input
:
new
Array
(),
output
:
true
}
{
input
:
new
Array
(),
output
:
true
},
{
input
:
[
15
,
new
Date
(),
'
ij
'
],
output
:
true
}
]
]
}
}
...
...
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