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
9542d73d
authored
2016-02-04 17:12:53 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Full test coverage on Ordering, few more bugs found as well.
1 parent
476e2d53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
src/scripts/solr/model/Ordering.js
test/specs/Ordering.spec.js
src/scripts/solr/model/Ordering.js
View file @
9542d73
define
(
function
(
require
)
{
'use strict'
;
var
_
=
require
(
'underscore'
);
var
Backbone
=
require
(
'backbone'
);
var
Ordering
=
Backbone
.
Model
.
extend
({
constructor
:
function
(
data
,
options
)
{
options
=
_
.
extend
({},
options
,
{
parse
:
true
});
return
Backbone
.
Model
.
call
(
this
,
data
,
options
);
},
defaults
:
function
defaults
()
{
return
{
value
:
null
,
...
...
test/specs/Ordering.spec.js
View file @
9542d73
...
...
@@ -7,9 +7,33 @@ define(function(require) {
it
(
'loads'
,
function
()
{
expect
(
Ordering
).
toBeDefined
();
});
it
(
'items are different instances'
,
function
()
{
var
o1
=
new
Ordering
(),
o2
=
new
Ordering
();
expect
(
o1
.
get
(
'items'
)).
not
.
toBe
(
o2
.
get
(
'items'
));
describe
(
':items'
,
function
()
{
var
items
=
[
{
value
:
'a'
,
label
:
'A'
},
{
value
:
'b'
,
label
:
'B'
},
{
value
:
'c'
,
label
:
'C'
},
];
it
(
'default value is not shared globally'
,
function
()
{
var
o1
=
new
Ordering
(),
o2
=
new
Ordering
();
expect
(
o1
.
get
(
'items'
)).
not
.
toBe
(
o2
.
get
(
'items'
));
});
it
(
'array is converted to collection without specifying parse'
,
function
()
{
var
o
=
new
Ordering
({
items
:
items
});
expect
(
o
.
get
(
'items'
)).
not
.
toBe
(
items
);
});
it
(
'same passed value is not shared globally'
,
function
()
{
var
o1
=
new
Ordering
({
items
:
items
},
{
parse
:
false
});
var
o2
=
new
Ordering
({
items
:
items
},
{
parse
:
false
});
expect
(
o1
.
get
(
'items'
)).
not
.
toBe
(
o2
.
get
(
'items'
));
});
it
(
':value is first item'
,
function
()
{
var
o
=
new
Ordering
({
items
:
items
});
expect
(
o
.
get
(
'value'
)).
toBe
(
'a'
);
});
it
(
':value is not changed'
,
function
()
{
var
o
=
new
Ordering
({
items
:
items
,
value
:
'1'
});
expect
(
o
.
get
(
'value'
)).
toBe
(
'1'
);
});
});
});
});
...
...
Please
register
or
sign in
to post a comment