Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
solr-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2c0f2df7
authored
2016-02-05 18:22:25 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Very close to full coverage now on Facet.
1 parent
8534addb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
15 deletions
test/specs/Facet.js
test/specs/Facet.js
View file @
2c0f2df
...
...
@@ -70,6 +70,12 @@ define(function(require) {
});
expect
(
got
).
toEqual
(
wantedCheckedKeys
);
});
var
item2
=
ascItemOrder
[
2
];
it
(
'foobar'
,
function
()
{
console
.
log
(
JSON
.
stringify
(
items
.
models
));
items
.
remove
(
item2
);
console
.
log
(
item2
,
JSON
.
stringify
(
items
.
models
));
});
}
describe
(
'type[field]'
,
function
()
{
var
facetOptions
=
{
...
...
@@ -226,55 +232,102 @@ define(function(require) {
});
createExpects
(
true
,
[
false
,
false
,
false
,
false
,
false
]);
});
describe
(
'type[year; before]'
,
function
()
{
function
rangeSupportHelper
(
hasBefore
,
hasAfter
)
{
function
createBeforeAfterExpects
(
all
,
orderedItems
)
{
if
(
!
hasBefore
)
{
orderedItems
.
shift
();
}
if
(
!
hasAfter
)
{
orderedItems
.
pop
();
}
createExpects
(
all
,
orderedItems
);
}
describe
(
'type[year]'
+
(
hasBefore
?
' hasBefore'
:
''
)
+
(
hasAfter
?
' hasAfter'
:
''
),
function
()
{
var
facetOptions
=
{
queryField
:
'value_d'
,
facetType
:
'year'
,
facetStats
:
true
,
other
:
'all'
,
formatter
:
function
(
item
)
{
var
value
=
parseInt
(
item
.
get
(
'key'
));
return
'$'
+
value
+
' - $'
+
(
value
+
1000
);
},
};
if
(
hasBefore
)
{
if
(
hasAfter
)
{
facetOptions
.
other
=
'all'
;
}
else
{
facetOptions
.
other
=
'before'
;
}
}
else
if
(
hasAfter
)
{
facetOptions
.
other
=
'after'
;
}
var
pojoItems
=
[
{
key
:
'before'
,
value
:
2000
},
{
key
:
'2005'
,
value
:
500
},
{
key
:
'2004'
,
value
:
400
},
{
key
:
'2003'
,
value
:
300
},
{
key
:
'2002'
,
value
:
200
},
{
key
:
'2001'
,
value
:
100
},
{
key
:
'after'
,
value
:
1500
},
];
ascItemOrder
=
[
'before'
,
'2001'
,
'2002'
,
'2003'
,
'2004'
,
'2005'
,
'after'
];
var
beforeItem
=
{
key
:
'before'
,
value
:
2000
};
var
afterItem
=
{
key
:
'after'
,
value
:
1500
};
ascItemOrder
=
[
'2001'
,
'2002'
,
'2003'
,
'2004'
,
'2005'
];
var
c0
;
beforeEach
(
function
()
{
f
=
new
Facet
(
null
,
facetOptions
);
items
=
f
.
get
(
'items'
);
c0
=
f
.
get
(
'checkedKeys'
);
});
if
(
hasAfter
)
{
ascItemOrder
.
push
(
'after'
);
pojoItems
.
push
(
afterItem
);
}
if
(
hasBefore
)
{
ascItemOrder
.
unshift
(
'before'
);
pojoItems
.
unshift
(
beforeItem
);
}
createPojoItems
(
pojoItems
);
describe
(
'query'
,
function
()
{
describe
(
'has'
,
function
()
{
it
(
'min'
,
function
()
{
f
.
set
({
queryMin
:
1000
,
queryMax
:
undefined
});
describe
(
'min'
,
function
()
{
beforeEach
(
function
()
{
f
.
set
({
queryMin
:
'2002'
,
queryMax
:
undefined
});
});
createBeforeAfterExpects
(
true
,
[
false
,
false
,
false
,
false
,
false
,
false
,
false
]);
it
(
'result'
,
function
()
{
expect
(
f
.
get
(
'hasQuery'
)).
toBe
(
false
);
});
it
(
'max'
,
function
()
{
f
.
set
({
queryMin
:
undefined
,
queryMax
:
5000
});
});
describe
(
'max'
,
function
()
{
beforeEach
(
function
()
{
f
.
set
({
queryMin
:
undefined
,
queryMax
:
'2004'
});
});
createBeforeAfterExpects
(
true
,
[
false
,
false
,
false
,
false
,
false
,
false
,
false
]);
it
(
'result'
,
function
()
{
expect
(
f
.
get
(
'hasQuery'
)).
toBe
(
false
);
});
it
(
'min+max'
,
function
()
{
f
.
set
({
queryMin
:
1000
,
queryMax
:
5000
});
});
describe
(
'min+max'
,
function
()
{
beforeEach
(
function
()
{
f
.
set
({
queryMin
:
'1980'
,
queryMax
:
'1984'
});
});
createBeforeAfterExpects
(
false
,
[
false
,
false
,
false
,
false
,
false
,
false
,
false
]);
it
(
'result'
,
function
()
{
expect
(
f
.
get
(
'hasQuery'
)).
toBe
(
true
);
});
describe
(
'checkedKeys: [2002, 2003]'
,
function
()
{
beforeEach
(
function
()
{
f
.
set
(
'checkedKeys'
,
[
'2002'
,
'2003'
]);
});
createBeforeAfterExpects
(
false
,
[
false
,
false
,
true
,
true
,
false
,
false
,
false
]);
});
});
createExpects
(
true
,
[
false
,
false
,
false
,
false
,
false
,
false
,
false
]);
it
(
'foo'
,
function
()
{
console
.
log
(
JSON
.
stringify
(
items
.
models
));
});
createBeforeAfterExpects
(
true
,
[
false
,
false
,
false
,
false
,
false
,
false
,
false
]);
});
}
rangeSupportHelper
(
true
,
true
);
rangeSupportHelper
(
true
,
false
);
rangeSupportHelper
(
false
,
false
);
rangeSupportHelper
(
false
,
true
);
});
});
});
...
...
Please
register
or
sign in
to post a comment