Skip to content

Commit 1c7deb3

Browse files
committed
Adds Logout Test
This commit revises the error catching capabilities of the logout method. This commit also adds a test to this functionality. Signed-off-by: Lui de la Parra <[email protected]>
1 parent b68bf75 commit 1c7deb3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/client.model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class Client extends Document {
262262
.then(body => this.connection.remove(body))
263263
.then(body => this._saveState(body))
264264
.then(body => resolve(body.messages[0]))
265-
.catch(error => reject(error))
265+
.catch(error => reject(error.response.data.messages[0]))
266266
: reject({ message: 'No session to log out.' })
267267
);
268268
}

tests/authentication.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,22 @@ describe('Authentication Capabilities', () => {
8686
.that.has.all.keys('message');
8787
});
8888

89-
it('reject if the authentication request fails', () => {
89+
it('should reject if the logout request fails', () => {
90+
return expect(
91+
client
92+
.authenticate()
93+
.then(token => {
94+
client.connection.token = 'invalid';
95+
return client;
96+
})
97+
.then(client => client.logout())
98+
.catch(error => error)
99+
)
100+
.to.eventually.be.a('object')
101+
.that.has.all.keys('code', 'message');
102+
});
103+
104+
it('should reject if the authentication request fails', () => {
90105
client.connection.credentials.password = 'incorrect';
91106
return expect(
92107
client

0 commit comments

Comments
 (0)