-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
56 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import BoltActions from "../enums/bolt-actions.enum"; | ||
import Action from "../enums/action.enum"; | ||
import BoltAction, { BOLT_ACTION_KEY } from "./bolt-action.decorator"; | ||
|
||
describe("@BoltAction", () => { | ||
class TestController { | ||
@BoltAction(BoltActions.SYNC_USERS) | ||
@BoltAction(Action.SYNC_USERS) | ||
public static syncUsers() {} | ||
|
||
@BoltAction(BoltActions.SET_OFFICE_PRESENCE) | ||
@BoltAction(Action.SET_OFFICE_PRESENCE) | ||
public static setOfficePresence() {} | ||
} | ||
|
||
it("Assigns correct metadata to decorated class", () => { | ||
const metaValueForSync = Reflect.getMetadata(BOLT_ACTION_KEY, TestController.syncUsers); | ||
expect(metaValueForSync).toEqual(BoltActions.SYNC_USERS); | ||
expect(metaValueForSync).toEqual(Action.SYNC_USERS); | ||
|
||
const metaValueForSet = Reflect.getMetadata(BOLT_ACTION_KEY, TestController.setOfficePresence); | ||
expect(metaValueForSet).toEqual(BoltActions.SET_OFFICE_PRESENCE); | ||
expect(metaValueForSet).toEqual(Action.SET_OFFICE_PRESENCE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { SetMetadata } from "@nestjs/common"; | ||
import BoltActions from "../enums/bolt-actions.enum"; | ||
import Action from "../enums/action.enum"; | ||
|
||
export const BOLT_ACTION_KEY = "BoltAction"; | ||
|
||
const BoltAction = (actionName: BoltActions) => SetMetadata(BOLT_ACTION_KEY, actionName); | ||
const BoltAction = (actionName: Action) => SetMetadata(BOLT_ACTION_KEY, actionName); | ||
|
||
export default BoltAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import BoltEvents from "../enums/bolt-events.enum"; | ||
import Event from "../enums/event.enum"; | ||
import BoltEvent, { BOLT_EVENT_KEY } from "./bolt-event.decorator"; | ||
|
||
describe("@BoltEvent", () => { | ||
class TestController { | ||
@BoltEvent(BoltEvents.APP_HOME_OPENED) | ||
@BoltEvent(Event.APP_HOME_OPENED) | ||
public static appHomeOpened() {} | ||
|
||
@BoltEvent(BoltEvents.USER_PROFILE_CHANGED) | ||
@BoltEvent(Event.USER_PROFILE_CHANGED) | ||
public static userProfileChanged() {} | ||
} | ||
|
||
it("Assigns correct metadata to decorated class", () => { | ||
const metaValueForSync = Reflect.getMetadata(BOLT_EVENT_KEY, TestController.appHomeOpened); | ||
expect(metaValueForSync).toEqual(BoltEvents.APP_HOME_OPENED); | ||
expect(metaValueForSync).toEqual(Event.APP_HOME_OPENED); | ||
|
||
const metaValueForSet = Reflect.getMetadata(BOLT_EVENT_KEY, TestController.userProfileChanged); | ||
expect(metaValueForSet).toEqual(BoltEvents.USER_PROFILE_CHANGED); | ||
expect(metaValueForSet).toEqual(Event.USER_PROFILE_CHANGED); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { SetMetadata } from "@nestjs/common"; | ||
import BoltEvents from "../enums/bolt-events.enum"; | ||
import Event from "../enums/event.enum"; | ||
|
||
export const BOLT_EVENT_KEY = "BoltEvent"; | ||
|
||
const BoltEvent = (eventName: BoltEvents) => SetMetadata(BOLT_EVENT_KEY, eventName); | ||
const BoltEvent = (eventName: Event) => SetMetadata(BOLT_EVENT_KEY, eventName); | ||
|
||
export default BoltEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/src/bolt/enums/bolt-events.enum.ts → app/src/bolt/enums/event.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
enum BoltEvents { | ||
enum Event { | ||
APP_HOME_OPENED = "app_home_opened", | ||
USER_PROFILE_CHANGED = "user_profile_changed", | ||
} | ||
|
||
export default BoltEvents; | ||
export default Event; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AllMiddlewareArgs, AppHomeOpenedEvent, SlackEventMiddlewareArgs } from "@slack/bolt"; | ||
import { StringIndexed } from "@slack/bolt/dist/types/helpers"; | ||
|
||
export type AppHomeOpenedArgs = SlackEventMiddlewareArgs<AppHomeOpenedEvent["type"]> & | ||
AllMiddlewareArgs<StringIndexed>; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AllMiddlewareArgs, SlackEventMiddlewareArgs, UserProfileChangedEvent } from "@slack/bolt"; | ||
import { StringIndexed } from "@slack/bolt/dist/types/helpers"; | ||
|
||
export type UserProfileChangedArgs = SlackEventMiddlewareArgs<UserProfileChangedEvent["type"]> & | ||
AllMiddlewareArgs<StringIndexed>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters