From 2cfbb36e58807085c0d8d91204b87f428f9b99c8 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 24 Oct 2018 11:56:18 +0200 Subject: [PATCH 1/3] Add channels.delete --- lib/api/channels.js | 4 ++++ test/channels.test.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/api/channels.js b/lib/api/channels.js index 80ccf04..1f6302e 100644 --- a/lib/api/channels.js +++ b/lib/api/channels.js @@ -46,6 +46,10 @@ class Channels { return this.client.request("POST", "channels.create", { name }, callback); } + delete (roomId, callback) { + return this.client.request("POST", "channels.delete", {roomId}, callback); + } + getIntegrations(roomId, { offset = 0, count = 0, sort = undefined, fields = undefined, query = undefined} ={}, callback) { let options = {roomId}; Object.assign(options, pageQueryMapping(arguments[1])); diff --git a/test/channels.test.js b/test/channels.test.js index 70689a3..a8ddece 100644 --- a/test/channels.test.js +++ b/test/channels.test.js @@ -407,4 +407,15 @@ describe("channels", function () { }); }); }); -}); \ No newline at end of file + + describe("deleting channel", function () { + it("should delete the channel successfully", function (done) { + rocketChatClient.channels.delete(addedRoomId, function (err, result) { + should(err).be.null(); + should(result).not.be.null(); + should(result.success).be.true(); + done(); + }); + }); + }); +}); From 4f69bfa06ee9f80a0e34271c15c90038332ecff4 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 24 Oct 2018 11:58:23 +0200 Subject: [PATCH 2/3] Add groups.delete --- lib/api/groups.js | 4 ++++ test/groups.test.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/api/groups.js b/lib/api/groups.js index cb40fae..f45459d 100644 --- a/lib/api/groups.js +++ b/lib/api/groups.js @@ -40,6 +40,10 @@ class Groups { return this.client.request("POST", "groups.create", { name, members}, callback); } + delete (roomId, callback) { + return this.client.request("POST", "groups.delete", {roomId}, callback); + } + getIntegrations(roomId, { offset = 0, count = 0, sort = undefined, fields = undefined, query = undefined} ={}, callback) { let options = {roomId}; Object.assign(options, pageQueryMapping(arguments[1])); diff --git a/test/groups.test.js b/test/groups.test.js index 87e4550..c2f38cd 100644 --- a/test/groups.test.js +++ b/test/groups.test.js @@ -375,4 +375,15 @@ describe("groups", () => { }); }); }); + + describe("deleting group", function () { + it("should delete the group successfully", function (done) { + rocketChatClient.groups.delete(createGroupId, function (err, result) { + should(err).be.null(); + should(result).not.be.null(); + should(result.success).be.true(); + done(); + }); + }); + }); }); From 5f8f8fc8899d695ce191303e605ead46de2a3312 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 24 Oct 2018 15:19:09 +0200 Subject: [PATCH 3/3] Fix test cases --- test/channels.test.js | 7 ++++--- test/groups.test.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/channels.test.js b/test/channels.test.js index a8ddece..2527481 100644 --- a/test/channels.test.js +++ b/test/channels.test.js @@ -406,14 +406,15 @@ describe("channels", function () { readonlyChannel.channel.ro.should.equal(true); }); }); - }); - describe("deleting channel", function () { - it("should delete the channel successfully", function (done) { + it("Deletes the channel", function (done) { rocketChatClient.channels.delete(addedRoomId, function (err, result) { should(err).be.null(); should(result).not.be.null(); should(result.success).be.true(); + + addedRoomId = null; + done(); }); }); diff --git a/test/groups.test.js b/test/groups.test.js index c2f38cd..d30fe7a 100644 --- a/test/groups.test.js +++ b/test/groups.test.js @@ -374,14 +374,15 @@ describe("groups", () => { createGroupId = null; }); }); - }); - describe("deleting group", function () { - it("should delete the group successfully", function (done) { + it("Deletes the group", function (done) { rocketChatClient.groups.delete(createGroupId, function (err, result) { should(err).be.null(); should(result).not.be.null(); should(result.success).be.true(); + + createGroupId = null; + done(); }); });