First bug found with jasmine, Ordering.items was a globally shared
instance.
Showing
2 changed files
with
18 additions
and
1 deletions
... | @@ -3,9 +3,11 @@ define(function(require) { | ... | @@ -3,9 +3,11 @@ define(function(require) { |
3 | var Backbone = require('backbone'); | 3 | var Backbone = require('backbone'); |
4 | 4 | ||
5 | var Ordering = Backbone.Model.extend({ | 5 | var Ordering = Backbone.Model.extend({ |
6 | defaults: { | 6 | defaults: function defaults() { |
7 | return { | ||
7 | value: null, | 8 | value: null, |
8 | items: new Backbone.Collection(), | 9 | items: new Backbone.Collection(), |
10 | }; | ||
9 | }, | 11 | }, |
10 | initialize: function(data, options) { | 12 | initialize: function(data, options) { |
11 | if (this.get('value') === null) { | 13 | if (this.get('value') === null) { | ... | ... |
test/specs/Ordering.spec.js
0 → 100644
1 | define(function(require) { | ||
2 | 'use strict'; | ||
3 | var Backbone = require('backbone'); | ||
4 | var Ordering = require('solr/model/Ordering'); | ||
5 | |||
6 | describe('Ordering', function() { | ||
7 | it('loads', function() { | ||
8 | expect(Ordering).toBeDefined(); | ||
9 | }); | ||
10 | it('items are different instances', function() { | ||
11 | var o1 = new Ordering(), o2 = new Ordering(); | ||
12 | expect(o1.get('items')).not.toBe(o2.get('items')); | ||
13 | }); | ||
14 | }); | ||
15 | }); |
-
Please register or sign in to post a comment