Started testing xos-backbone
diff --git a/xos/core/xoslib/karma.conf.js b/xos/core/xoslib/karma.conf.js
index d78c020..4beb3b7 100644
--- a/xos/core/xoslib/karma.conf.js
+++ b/xos/core/xoslib/karma.conf.js
@@ -35,6 +35,7 @@
// list of files to exclude
exclude: [
+ //'**/xos-utils.test.js' //skip this test, useful in dev, comment before commit
],
diff --git a/xos/core/xoslib/spec/xoslib/xos-backbone.test.js b/xos/core/xoslib/spec/xoslib/xos-backbone.test.js
new file mode 100644
index 0000000..ec1b939
--- /dev/null
+++ b/xos/core/xoslib/spec/xoslib/xos-backbone.test.js
@@ -0,0 +1,37 @@
+'use strict';
+
+describe('The XOSModel', () => {
+
+ var model;
+
+ beforeEach(() => {
+ model = new XOSModel();
+ });
+
+ describe('url method', () => {
+ it('should set the correct url', () => {
+ const ctx = {attributes: {resource_uri: 'onlab.us'}};
+ let res = model.url.apply(ctx);
+ expect(res).toEqual('onlab.us/?no_hyperlinks=1')
+ });
+
+ it('should remove query params', () => {
+ const ctx = {attributes: {resource_uri: 'onlab.us?query=params'}};
+ let res = model.url.apply(ctx);
+ expect(res).toEqual('onlab.us/?no_hyperlinks=1')
+ });
+ });
+
+ describe('listMethods method', () => {
+ it('should list all methods in instance', () => {
+ const instance = {
+ m1: () => {},
+ m2: () => {}
+ };
+
+ let res = model.listMethods.apply(instance);
+ expect(res.length).toBe(2);
+ expect(res[0]).toEqual('m1');
+ });
+ });
+});
\ No newline at end of file
diff --git a/xos/core/xoslib/spec/xoslib/utils.test.js b/xos/core/xoslib/spec/xoslib/xos-utils.test.js
similarity index 100%
rename from xos/core/xoslib/spec/xoslib/utils.test.js
rename to xos/core/xoslib/spec/xoslib/xos-utils.test.js
diff --git a/xos/core/xoslib/static/js/xoslib/xos-backbone.js b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
index 4ba763d..74f62ef 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -53,6 +53,7 @@
/* from backbone-tastypie.js */
url: function() {
+ // TODO handle error if no property
var url = this.attributes.resource_uri;
if (!url) {