Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add toSetRolePosition and manual test for it * feat: add tests for toSetRolePosition * feat: add testes for new function on cordeBot
- Loading branch information
1 parent
266de6d
commit 5e6a4bd
Showing
14 changed files
with
326 additions
and
45 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,2 +1,6 @@ | ||
export { toSetRoleColor } from "./toSetRoleColor"; | ||
export { toDeleteRole } from "./toDeleteRole"; | ||
export { ToSetRolePosition } from "./toSetRolePosition"; | ||
export { ToSetRoleMentionable } from "./toSetRoleMentionable"; | ||
export { ToSetRoleHoist } from "./toSetRoleHoist"; | ||
export { ToRenameRole } from "./toRenameRole"; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ExpectOperation } from "../operation"; | ||
import { TestReport } from "../.."; | ||
import { RoleData } from "../../../types"; | ||
|
||
export class ToSetRolePosition extends ExpectOperation<number, RoleData> { | ||
public async action(newPosition: number, roleData: RoleData): Promise<TestReport> { | ||
try { | ||
let role = await this.cordeBot.findRole(roleData); | ||
const lastRole = this.cordeBot | ||
.getRoles() | ||
.sort((r1, r2) => r2.position - r1.position) | ||
.first(); | ||
|
||
if (!role) { | ||
this.isEqual = false; | ||
this.forceIsEqualValue = true; | ||
this.output = "Role not found"; | ||
} else if (newPosition > lastRole.position) { | ||
this.forceIsEqualValue = true; | ||
this.customReturnMessage = `the maximum position possible is ${lastRole.position}. Attempted value: ${newPosition}`; | ||
} else { | ||
await this.cordeBot.sendTextMessage(this.command); | ||
role = await this.cordeBot.findRole(roleData); | ||
if (role.position === newPosition) { | ||
this.isEqual = true; | ||
} else { | ||
this.customReturnMessage = `expected position: ${newPosition}, actual position: ${role.position}`; | ||
} | ||
} | ||
} catch (error) { | ||
this.catchExecutionError(error); | ||
} | ||
|
||
return this.generateReport(); | ||
} | ||
} |
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
Oops, something went wrong.