Remove unecessary Api.getRoot method
authorFrank Bessou <frank.bessou@logilab.fr>
Thu, 13 Apr 2017 14:47:13 +0200
changeset 116 9ccdace2a88c
parent 115 706f374811ab
child 117 493b8bda31e8
Remove unecessary Api.getRoot method
src/Api.js
src/components/Root.js
test/index.js
--- a/src/Api.js	Thu Apr 13 11:51:58 2017 +0200
+++ b/src/Api.js	Thu Apr 13 14:47:13 2017 +0200
@@ -84,10 +84,6 @@
         return resourcePromise;
     }
 
-    getRoot() {
-        return this.getResource('');
-    }
-
     getRelatedSchema(etype, rtype, role = 'creation', targetType = null) {
         let url = `/${etype}/relationships/${rtype}/schema?role=${role}`;
         if (targetType !== null) {
--- a/src/components/Root.js	Thu Apr 13 11:51:58 2017 +0200
+++ b/src/components/Root.js	Thu Apr 13 14:47:13 2017 +0200
@@ -9,7 +9,7 @@
     }
 
     componentDidMount() {
-        Api.getRoot().then(resource => {
+        Api.getResource('').then(resource => {
             this.setState({resource: resource});
         });
     }
--- a/test/index.js	Thu Apr 13 11:51:58 2017 +0200
+++ b/test/index.js	Thu Apr 13 14:47:13 2017 +0200
@@ -399,32 +399,6 @@
         });
     });
 
-    describe('getRoot', () => {
-        it('should fetch the root schema ', done => {
-            const rootSchema = JSON.stringify({foo: 'bar'});
-            const options = {
-                headers: {
-                    "Content-Type": "application/json",
-                    'Link': '</schema>; rel=describedby'
-                },
-            };
-            const fakeFetch = sinon.stub().resolves(new Response('null', options));
-            fakeFetch.withArgs(baseUrl+'/schema', sinon.match({}))
-                    .resolves(new Response(rootSchema, options));
-            const api = new Api(baseUrl, fakeFetch);
-
-            api.getRoot().then(resource => {
-                const resourceSchema = resource.data.schemas()[0].data.value();
-
-                assert.calledWith(fakeFetch, baseUrl+'/schema', sinon.match({}));
-                expect(JSON.stringify(resourceSchema)).to.deep.equal(rootSchema);
-                done();
-            }).catch(done);
-
-        });
-
-    });
-
     describe('getResource', () => {
 
         const baseUrl = 'http://example.com';