{"action":"created","comment":{"url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/comments/47902027","id":47902027,"diff_hunk":"@@ -0,0 +1,197 @@\n+import request from 'superagent';\n+import faker from 'faker';\n+import check from './helpers';\n+\n+const Url = 'http://localhost:3000';\n+const user = {\n+  username: faker.internet.userName(),\n+  firstname: faker.name.firstName(),\n+  lastname: faker.name.lastName(),\n+  email: faker.internet.email(),\n+  password: faker.name.findName()\n+};\n+\n+const doc = {\n+  title: faker.lorem.sentence(),\n+  access: 'public',\n+  content: faker.lorem.paragraph()\n+};\n+\n+let docId, id, token;\n+\n+describe('Document resource testing', () => {\n+  // create the user\n+  beforeAll((done) => {\n+    request\n+      .post(Url + '/api/users')\n+      .send(user)\n+      .end((err, res) => {\n+        let response = res.body;\n+        if (res.status === 200) {\n+          id = response._id;\n+        }\n+        done();\n+      });\n+  });\n+\n+  //Login the user\n+\n+  beforeAll((done) => {\n+    request\n+      .post(Url + '/api/users/login')\n+      .send(user)\n+      .end((err, res) => {\n+        let response = res.body;\n+        if (res.status === 200) {\n+          token = response.token;\n+        }\n+        done();\n+      });\n+  });\n+\n+\n+  describe('Create a new document', () => {\n+    it('should create new document', (done) => {\n+      request\n+        .post(Url + '/api/documents')\n+        .set('x-access-token', token)\n+        .send(doc)\n+        .accept('application/json')\n+        .end((err, res) => {\n+          let response = res.body;\n+          if (res.status === 200) {\n+            docId = response._id;\n+            id = response.ownerId;\n+            expect(response._id).toBeDefined();\n+            expect(response.owner).toBeDefined();\n+            expect(response.title).toBe(doc.title);\n+            expect(response.content).toBe(doc.content);\n+            expect(response.created_at).toBeDefined();\n+            expect(response.updated_at).toBeDefined();\n+          } else if (res.status == 400) {\n+            expect(response.error).toBe('Document not created');\n+          } else {\n+            expect(response.error).toBe('No token provided');\n+          }\n+          done();\n+        });\n+    });\n+  });\n+  describe('Retrieve all the documents from the db', () => {\n+    it('should return all the documents', (done) => {\n+      request\n+        .get(Url + '/api/documents')\n+        .set('x-access-token', token)\n+        .end((err, res) => {\n+          let response = res.body;\n+          if (res.status === 200) {\n+            expect(res.type).toBe('application/json');\n+            expect(typeof response).toBe('object');\n+            expect(response.length).toBeGreaterThan(0);\n+            expect(check.isDocData).toBeTruthy();\n+          } else if (res.status === 404) {\n+            expect(response.error).toBe('Document not found');\n+          } else {\n+            expect(response.error).toBe('No token provided');\n+          }\n+          done();\n+        });\n+    });\n+  });\n+\n+\n+  describe('Retrieve one document', () => {\n+    it('should return one document of the specified id', (done) => {\n+      request\n+        .get(Url + '/api/documents/' + docId)\n+        .set('x-access-token', token)\n+        .end((err, res) => {\n+          let response = res.body;\n+          if (res.status === 200) {\n+            expect(res.type).toBe('application/json');\n+            expect(typeof response).toBe('object');\n+            expect(response._id).toBeDefined();\n+            expect(response.title).toBeDefined();\n+            expect(response.content).toBeDefined();\n+            expect(response.created_at).toBeDefined();\n+            expect(response.updated_at).toBeDefined();\n+          } else if (res.status === 404) {\n+            expect(response.error).toBe('Document not found');\n+          } else {\n+            expect(response.error).toBe('No token provided');\n+          }\n+          done();\n+        });\n+    });\n+  });\n+\n+  describe('Retrieve User documents', () => {\n+    it('should return a document of specified userId', (done) => {\n+      request\n+        .get(Url + '/api/users/' + id + '/documents')\n+        .set('x-access-token', token)\n+        .end((err, res) => {\n+          let response = res.body;\n+          if (res.status === 200) {\n+            expect(res.type).toBe('application/json');\n+            expect(typeof response).toBe('object');\n+            expect(response.length).toBeGreaterThan(0);\n+            expect(check.isDocData).toBeTruthy();\n+          } else if (res.status === 404) {\n+            expect(response.error).toBe('Document not found');\n+          } else {\n+            expect(response.error).toBe('No token provided');\n+          }\n+          done();\n+        });\n+    });\n+  });\n+\n+  describe('Update documents', () => {\n+    it('should update document of specified id', (done) => {\n+      request\n+        .put(Url + '/api/documents/' + docId)\n+        .set('x-access-token', token)\n+        .send(doc)\n+        .accept('application/json')\n+        .end((err, res) => {\n+          let response = res.body;\n+          if (res.status === 200) {\n+            expect(res.type).toBe('application/json');\n+            expect(typeof response).toBe('object');\n+            expect(response.message).toBe('Update succesful');\n+          } else if (res.status === 500) {\n+            expect(response.error).toBe('Update failed');\n+          } else {\n+            expect(response.error).toBe('No token provided');\n+          }\n+          done();\n+        });\n+    });\n+  });\n+\n+\n+  describe('Delete Document', () => {\n+    it('should delete document of specified id', (done) => {\n+      request\n+        .del(Url + '/api/documents/' + docId + '?token=' + token)\n+        .set('x-access-token', token)\n+        .end((err, res) => {","path":"src/tests/documents.spec.js","position":179,"original_position":179,"commit_id":"b0f6d38cd9bec2db183371892b6315d2b4355d0b","original_commit_id":"b0f6d38cd9bec2db183371892b6315d2b4355d0b","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"'arrow function syntax (=>)' is only available in ES6 (use esnext option).","created_at":"2015-12-17T12:55:36Z","updated_at":"2015-12-17T12:55:36Z","html_url":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2#discussion_r47902027","pull_request_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/comments/47902027"},"html":{"href":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2#discussion_r47902027"},"pull_request":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2","id":53827845,"html_url":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2","diff_url":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2.diff","patch_url":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2.patch","issue_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/2","number":2,"state":"open","locked":false,"title":"Merge feature/bend-test to develop","user":{"login":"Andela-thomas","id":12892110,"avatar_url":"https://avatars.githubusercontent.com/u/12892110?v=3","gravatar_id":"","url":"https://api.github.com/users/Andela-thomas","html_url":"https://github.com/Andela-thomas","followers_url":"https://api.github.com/users/Andela-thomas/followers","following_url":"https://api.github.com/users/Andela-thomas/following{/other_user}","gists_url":"https://api.github.com/users/Andela-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/Andela-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andela-thomas/subscriptions","organizations_url":"https://api.github.com/users/Andela-thomas/orgs","repos_url":"https://api.github.com/users/Andela-thomas/repos","events_url":"https://api.github.com/users/Andela-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/Andela-thomas/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-16T11:14:27Z","updated_at":"2015-12-17T12:55:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be0b06768c3423aa533cfe0ccbc975da9f0e4d9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/2/comments","statuses_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/statuses/b0f6d38cd9bec2db183371892b6315d2b4355d0b","head":{"label":"Andela-thomas:feature/bend-test","ref":"feature/bend-test","sha":"b0f6d38cd9bec2db183371892b6315d2b4355d0b","user":{"login":"Andela-thomas","id":12892110,"avatar_url":"https://avatars.githubusercontent.com/u/12892110?v=3","gravatar_id":"","url":"https://api.github.com/users/Andela-thomas","html_url":"https://github.com/Andela-thomas","followers_url":"https://api.github.com/users/Andela-thomas/followers","following_url":"https://api.github.com/users/Andela-thomas/following{/other_user}","gists_url":"https://api.github.com/users/Andela-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/Andela-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andela-thomas/subscriptions","organizations_url":"https://api.github.com/users/Andela-thomas/orgs","repos_url":"https://api.github.com/users/Andela-thomas/repos","events_url":"https://api.github.com/users/Andela-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/Andela-thomas/received_events","type":"User","site_admin":false},"repo":{"id":47978640,"name":"Express-app-Es6-","full_name":"Andela-thomas/Express-app-Es6-","owner":{"login":"Andela-thomas","id":12892110,"avatar_url":"https://avatars.githubusercontent.com/u/12892110?v=3","gravatar_id":"","url":"https://api.github.com/users/Andela-thomas","html_url":"https://github.com/Andela-thomas","followers_url":"https://api.github.com/users/Andela-thomas/followers","following_url":"https://api.github.com/users/Andela-thomas/following{/other_user}","gists_url":"https://api.github.com/users/Andela-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/Andela-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andela-thomas/subscriptions","organizations_url":"https://api.github.com/users/Andela-thomas/orgs","repos_url":"https://api.github.com/users/Andela-thomas/repos","events_url":"https://api.github.com/users/Andela-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/Andela-thomas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Andela-thomas/Express-app-Es6-","description":"Document management system Api using Es6","fork":false,"url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-","forks_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/forks","keys_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/teams","hooks_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/hooks","issue_events_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/events{/number}","events_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/events","assignees_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/assignees{/user}","branches_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/branches{/branch}","tags_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/tags","blobs_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/refs{/sha}","trees_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/statuses/{sha}","languages_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/languages","stargazers_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/stargazers","contributors_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/contributors","subscribers_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/subscribers","subscription_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/subscription","commits_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/commits{/sha}","git_commits_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/commits{/sha}","comments_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/comments{/number}","issue_comment_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/comments{/number}","contents_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/contents/{+path}","compare_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/merges","archive_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/downloads","issues_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues{/number}","pulls_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls{/number}","milestones_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/milestones{/number}","notifications_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/labels{/name}","releases_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/releases{/id}","created_at":"2015-12-14T14:06:02Z","updated_at":"2015-12-14T14:07:46Z","pushed_at":"2015-12-17T12:55:29Z","git_url":"git://github.com/Andela-thomas/Express-app-Es6-.git","ssh_url":"git@github.com:Andela-thomas/Express-app-Es6-.git","clone_url":"https://github.com/Andela-thomas/Express-app-Es6-.git","svn_url":"https://github.com/Andela-thomas/Express-app-Es6-","homepage":null,"size":9962,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Andela-thomas:master","ref":"master","sha":"8729dbac26154147490e256f3711133f01e85200","user":{"login":"Andela-thomas","id":12892110,"avatar_url":"https://avatars.githubusercontent.com/u/12892110?v=3","gravatar_id":"","url":"https://api.github.com/users/Andela-thomas","html_url":"https://github.com/Andela-thomas","followers_url":"https://api.github.com/users/Andela-thomas/followers","following_url":"https://api.github.com/users/Andela-thomas/following{/other_user}","gists_url":"https://api.github.com/users/Andela-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/Andela-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andela-thomas/subscriptions","organizations_url":"https://api.github.com/users/Andela-thomas/orgs","repos_url":"https://api.github.com/users/Andela-thomas/repos","events_url":"https://api.github.com/users/Andela-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/Andela-thomas/received_events","type":"User","site_admin":false},"repo":{"id":47978640,"name":"Express-app-Es6-","full_name":"Andela-thomas/Express-app-Es6-","owner":{"login":"Andela-thomas","id":12892110,"avatar_url":"https://avatars.githubusercontent.com/u/12892110?v=3","gravatar_id":"","url":"https://api.github.com/users/Andela-thomas","html_url":"https://github.com/Andela-thomas","followers_url":"https://api.github.com/users/Andela-thomas/followers","following_url":"https://api.github.com/users/Andela-thomas/following{/other_user}","gists_url":"https://api.github.com/users/Andela-thomas/gists{/gist_id}","starred_url":"https://api.github.com/users/Andela-thomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andela-thomas/subscriptions","organizations_url":"https://api.github.com/users/Andela-thomas/orgs","repos_url":"https://api.github.com/users/Andela-thomas/repos","events_url":"https://api.github.com/users/Andela-thomas/events{/privacy}","received_events_url":"https://api.github.com/users/Andela-thomas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Andela-thomas/Express-app-Es6-","description":"Document management system Api using Es6","fork":false,"url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-","forks_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/forks","keys_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/teams","hooks_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/hooks","issue_events_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/events{/number}","events_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/events","assignees_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/assignees{/user}","branches_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/branches{/branch}","tags_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/tags","blobs_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/refs{/sha}","trees_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/statuses/{sha}","languages_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/languages","stargazers_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/stargazers","contributors_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/contributors","subscribers_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/subscribers","subscription_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/subscription","commits_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/commits{/sha}","git_commits_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/git/commits{/sha}","comments_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/comments{/number}","issue_comment_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/comments{/number}","contents_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/contents/{+path}","compare_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/merges","archive_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/downloads","issues_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues{/number}","pulls_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls{/number}","milestones_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/milestones{/number}","notifications_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/labels{/name}","releases_url":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/releases{/id}","created_at":"2015-12-14T14:06:02Z","updated_at":"2015-12-14T14:07:46Z","pushed_at":"2015-12-17T12:55:29Z","git_url":"git://github.com/Andela-thomas/Express-app-Es6-.git","ssh_url":"git@github.com:Andela-thomas/Express-app-Es6-.git","clone_url":"https://github.com/Andela-thomas/Express-app-Es6-.git","svn_url":"https://github.com/Andela-thomas/Express-app-Es6-","homepage":null,"size":9962,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2"},"html":{"href":"https://github.com/Andela-thomas/Express-app-Es6-/pull/2"},"issue":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/2"},"comments":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Andela-thomas/Express-app-Es6-/statuses/b0f6d38cd9bec2db183371892b6315d2b4355d0b"}}}}