Skip to content

Commit

Permalink
fix: move slack status defs
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Feb 1, 2024
1 parent ac6f532 commit 8a351fb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ import SlackUser from '../models/slack-user.js';

import BaseSlackClient from './base-slack-client.js';

/**
* The possible statuses for a user invites and channel creations.
*
* @type {{
* USER_ALREADY_IN_CHANNEL: string,
* GENERAL_ERROR: string,
* USER_ALREADY_IN_ANOTHER_CHANNEL: string,
* USER_INVITED_TO_CHANNEL: string,
* USER_NEEDS_INVITATION_TO_WORKSPACE: string,
* CHANNEL_ALREADY_EXISTS: string
* }}
*/
export const SLACK_STATUSES = {
USER_ALREADY_IN_CHANNEL: 'user_already_in_channel',
USER_ALREADY_IN_ANOTHER_CHANNEL: 'user_already_in_another_channel',
Expand Down
12 changes: 12 additions & 0 deletions packages/spacecat-shared-slack-client/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ export declare const SLACK_TARGETS: {
ADOBE_EXTERNAL: string;
};

/**
* The possible statuses for a user invites and channel creations.
*/
export declare const SLACK_STATUSES : {
USER_ALREADY_IN_CHANNEL: string;
GENERAL_ERROR: string;
USER_ALREADY_IN_ANOTHER_CHANNEL: string;
USER_INVITED_TO_CHANNEL: string;
USER_NEEDS_INVITATION_TO_WORKSPACE: string;
CHANNEL_ALREADY_EXISTS: string;
};

export {
BaseSlackClient,
ElevatedSlackClient,
Expand Down
3 changes: 2 additions & 1 deletion packages/spacecat-shared-slack-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
*/

import BaseSlackClient from './clients/base-slack-client.js';
import ElevatedSlackClient from './clients/elevated-slack-client.js';
import ElevatedSlackClient, { SLACK_STATUSES } from './clients/elevated-slack-client.js';

const SLACK_TARGETS = {
ADOBE_INTERNAL: 'ADOBE_INTERNAL',
ADOBE_EXTERNAL: 'ADOBE_EXTERNAL',
};

export {
SLACK_STATUSES,
SLACK_TARGETS,
BaseSlackClient,
ElevatedSlackClient,
Expand Down
12 changes: 12 additions & 0 deletions packages/spacecat-shared-slack-client/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import { expect } from 'chai';
import {
SLACK_STATUSES,
SLACK_TARGETS,
BaseSlackClient,
ElevatedSlackClient,
Expand All @@ -24,6 +25,17 @@ describe('SLACK_TARGETS Object', () => {
expect(SLACK_TARGETS).to.be.an('object').that.includes.all.keys('ADOBE_INTERNAL', 'ADOBE_EXTERNAL');
});

it('SLACK_STATUSES must have required properties', () => {
expect(SLACK_STATUSES).to.be.an('object').that.includes.all.keys(
'USER_ALREADY_IN_CHANNEL',
'GENERAL_ERROR',
'USER_ALREADY_IN_ANOTHER_CHANNEL',
'USER_INVITED_TO_CHANNEL',
'USER_NEEDS_INVITATION_TO_WORKSPACE',
'CHANNEL_ALREADY_EXISTS',
);
});

it('should have correct values for properties', () => {
expect(SLACK_TARGETS.ADOBE_INTERNAL).to.equal('ADOBE_INTERNAL');
expect(SLACK_TARGETS.ADOBE_EXTERNAL).to.equal('ADOBE_EXTERNAL');
Expand Down

0 comments on commit 8a351fb

Please sign in to comment.