diff --git a/spec/store/store-spec.js b/spec/store/store-spec.js new file mode 100644 index 0000000..542f29e --- /dev/null +++ b/spec/store/store-spec.js @@ -0,0 +1,30 @@ +var Store = require("../../src/store"); + +describe("store", function () { + + var store; + + beforeEach(function () { + store = new Store(); + }); + + describe("without an adapter", function () { + + it("must throw an error if CLUD methods are called when there isn't an adapter", function () { + expect(function () { + store.create(); + }).toThrowError("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + expect(function () { + store.load(); + }).toThrowError("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + expect(function () { + store.update(); + }).toThrowError("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + expect(function () { + store.destroy(); + }).toThrowError("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + }); + + }); + +}); diff --git a/src/store.js b/src/store.js index 29f217c..a441edc 100644 --- a/src/store.js +++ b/src/store.js @@ -129,6 +129,10 @@ export default class Store { } } + create() { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + /** * Defines a type of resource. * @@ -149,6 +153,10 @@ export default class Store { }); } + destroy() { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + /** * Find a resource or entire collection of resources. * @@ -194,6 +202,10 @@ export default class Store { } } + load() { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + /** * Unregister an event listener that was registered with on(). * @@ -328,6 +340,10 @@ export default class Store { } } + update() { + throw new Error("Adapter missing. Specify an adapter when creating the store: `var store = new Store(adapter);`"); + } + _addField(object, resource, definition, fieldName) { var field = definition[fieldName]; var newValue = field.deserialize.call(this, object, fieldName);