Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
e8ff7acf
Commit
e8ff7acf
authored
Jul 11, 2017
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert search-filter tests to JS
parent
21c38686
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
65 deletions
+59
-65
search-filter-test.coffee
src/sidebar/test/search-filter-test.coffee
+0
-65
search-filter-test.js
src/sidebar/test/search-filter-test.js
+59
-0
No files found.
src/sidebar/test/search-filter-test.coffee
deleted
100644 → 0
View file @
21c38686
{
module
,
inject
}
=
angular
.
mock
describe
'searchFilter'
,
->
sandbox
=
null
searchFilter
=
null
before
->
angular
.
module
(
'h'
,
[])
.
service
(
'searchFilter'
,
require
(
'../search-filter'
))
beforeEach
module
(
'h'
)
beforeEach
->
sandbox
=
sinon
.
sandbox
.
create
()
beforeEach
inject
(
_searchFilter_
)
->
searchFilter
=
_searchFilter_
afterEach
->
sandbox
.
restore
()
describe
'toObject'
,
->
it
'puts a simple search string under the any filter'
,
->
query
=
'foo'
result
=
searchFilter
.
toObject
(
query
)
assert
.
equal
(
result
.
any
[
0
],
query
)
it
'uses the filters as keys in the result object'
,
->
query
=
'user:john text:foo quote:bar group:agroup other'
result
=
searchFilter
.
toObject
(
query
)
assert
.
equal
(
result
.
any
[
0
],
'other'
)
assert
.
equal
(
result
.
user
[
0
],
'john'
)
assert
.
equal
(
result
.
text
[
0
],
'foo'
)
assert
.
equal
(
result
.
quote
[
0
],
'bar'
)
assert
.
equal
(
result
.
group
[
0
],
'agroup'
)
it
'collects the same filters into a list'
,
->
query
=
'user:john text:foo quote:bar other user:doe text:fuu text:fii'
result
=
searchFilter
.
toObject
(
query
)
assert
.
equal
(
result
.
any
[
0
],
'other'
)
assert
.
equal
(
result
.
user
[
0
],
'john'
)
assert
.
equal
(
result
.
user
[
1
],
'doe'
)
assert
.
equal
(
result
.
text
[
0
],
'foo'
)
assert
.
equal
(
result
.
text
[
1
],
'fuu'
)
assert
.
equal
(
result
.
text
[
2
],
'fii'
)
assert
.
equal
(
result
.
quote
[
0
],
'bar'
)
it
'preserves data with semicolon characters'
,
->
query
=
'uri:http://test.uri'
result
=
searchFilter
.
toObject
(
query
)
assert
.
equal
(
result
.
uri
[
0
],
'http://test.uri'
)
it
'collects valid filters and puts invalid into the any category'
,
->
query
=
'uri:test foo:bar text:hey john:doe quote:according hi-fi a:bc'
result
=
searchFilter
.
toObject
(
query
)
assert
.
isFalse
(
result
.
foo
?
)
assert
.
isFalse
(
result
.
john
?
)
assert
.
isFalse
(
result
.
a
?
)
assert
.
equal
(
result
.
uri
[
0
],
'test'
)
assert
.
equal
(
result
.
text
[
0
],
'hey'
)
assert
.
equal
(
result
.
quote
[
0
],
'according'
)
assert
.
equal
(
result
.
any
[
0
],
'foo:bar'
)
assert
.
equal
(
result
.
any
[
1
],
'john:doe'
)
assert
.
equal
(
result
.
any
[
2
],
'hi-fi'
)
assert
.
equal
(
result
.
any
[
3
],
'a:bc'
)
src/sidebar/test/search-filter-test.js
0 → 100644
View file @
e8ff7acf
'use strict'
;
var
searchFilter
=
require
(
'../search-filter'
)();
describe
(
'sidebar.search-filter'
,
function
()
{
describe
(
'#toObject'
,
function
()
{
it
(
'puts a simple search string under the any filter'
,
function
()
{
var
query
=
'foo'
;
var
result
=
searchFilter
.
toObject
(
query
);
assert
.
equal
(
result
.
any
[
0
],
query
);
});
it
(
'uses the filters as keys in the result object'
,
function
()
{
var
query
=
'user:john text:foo quote:bar group:agroup other'
;
var
result
=
searchFilter
.
toObject
(
query
);
assert
.
equal
(
result
.
any
[
0
],
'other'
);
assert
.
equal
(
result
.
user
[
0
],
'john'
);
assert
.
equal
(
result
.
text
[
0
],
'foo'
);
assert
.
equal
(
result
.
quote
[
0
],
'bar'
);
assert
.
equal
(
result
.
group
[
0
],
'agroup'
);
});
it
(
'collects the same filters into a list'
,
function
()
{
var
query
=
'user:john text:foo quote:bar other user:doe text:fuu text:fii'
;
var
result
=
searchFilter
.
toObject
(
query
);
assert
.
equal
(
result
.
any
[
0
],
'other'
);
assert
.
equal
(
result
.
user
[
0
],
'john'
);
assert
.
equal
(
result
.
user
[
1
],
'doe'
);
assert
.
equal
(
result
.
text
[
0
],
'foo'
);
assert
.
equal
(
result
.
text
[
1
],
'fuu'
);
assert
.
equal
(
result
.
text
[
2
],
'fii'
);
assert
.
equal
(
result
.
quote
[
0
],
'bar'
);
});
it
(
'preserves data with semicolon characters'
,
function
()
{
var
query
=
'uri:http://test.uri'
;
var
result
=
searchFilter
.
toObject
(
query
);
assert
.
equal
(
result
.
uri
[
0
],
'http://test.uri'
);
});
it
(
'collects valid filters and puts invalid into the "any" category'
,
function
()
{
var
query
=
'uri:test foo:bar text:hey john:doe quote:according hi-fi a:bc'
;
var
result
=
searchFilter
.
toObject
(
query
);
assert
.
isUndefined
(
result
.
foo
);
assert
.
isUndefined
(
result
.
john
);
assert
.
isUndefined
(
result
.
a
);
assert
.
equal
(
result
.
uri
[
0
],
'test'
);
assert
.
equal
(
result
.
text
[
0
],
'hey'
);
assert
.
equal
(
result
.
quote
[
0
],
'according'
);
assert
.
equal
(
result
.
any
[
0
],
'foo:bar'
);
assert
.
equal
(
result
.
any
[
1
],
'john:doe'
);
assert
.
equal
(
result
.
any
[
2
],
'hi-fi'
);
assert
.
equal
(
result
.
any
[
3
],
'a:bc'
);
});
});
});
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