Ordering.spec.js
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
define(function(require) {
'use strict';
var Backbone = require('backbone');
var Ordering = require('solr/model/Ordering');
describe('Ordering', function() {
it('loads', function() {
expect(Ordering).toBeDefined();
});
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');
});
});
});
});