Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding tests for list properties

  • Loading branch information...
commit 54961ef0b8c34010c8e11a3f2be71b1280e6c46e 1 parent 1e3bd76
@HenrikJoreteg authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests.js
View
28 tests.js
@@ -4,6 +4,7 @@ capsule = require('../capsule');
var Person = capsule.Model.extend({
type: 'person',
+ lists: ['nicknames'],
exposedServerMethods: ['dance'],
initialize: function () {
this.register();
@@ -240,4 +241,31 @@ exports.testSafeCall = function (test) {
test.equal(model, u);
test.done();
});
+};
+
+exports.testListProperties = function (test) {
+ var person = new Person(),
+ arr = ['first', 'second'];
+
+ person.set({nicknames: arr});
+
+ test.equal('object', typeof person.get('nicknames'));
+ test.equal('string', typeof person.attributes.nicknames);
+
+ test.ok(person.get('nicknames') !== person.get('nicknames'), "should not refer to the same array");
+ test.deepEqual(person.get('nicknames'), person.get('nicknames'), "but should be deep equal");
+
+ person.bind('change:nicknames', function (model, val) {
+ test.ok(typeof val === 'string');
+ test.equal(val, '["something","first","second"]');
+ test.done();
+ });
+
+ person.set({nicknames: arr});
+
+ arr.unshift('something');
+
+ // this is just so we can see
+ test.ok(true);
+ person.set({nicknames: arr});
};
Please sign in to comment.
Something went wrong with that request. Please try again.