Skip to content

Commit

Permalink
test: fix all unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
armand1m committed Mar 12, 2024
1 parent 20fa860 commit 22807e0
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions src/commands/deregisterMemberFrom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdDeregisterMemberFrom } from './deregisterMemberFrom';

it('renders error message when no location is specified', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.DeregisterMemberFrom,
args: '',
},
Expand All @@ -20,7 +20,7 @@ it('renders error message when no location is specified', async () => {

it('renders error message when the location specified is not found', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.DeregisterMemberFrom,
args: 'NXL',
},
Expand All @@ -35,7 +35,7 @@ it('renders error message when the location specified is not found', async () =>

it('removes member from location successfully', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.DeregisterMemberFrom,
args: 'NL',
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deregisterRemoteMember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdDeregisterRemoteMember } from './deregisterRemoteMember';

it('should always remove the user remote location', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.DeregisterRemoteMember,
args: '',
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/findMember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ it('returns message if member is not registered', async () => {
database: {
findMember: (_userId) => [],
},
command: {
userCommand: {
command: Command.FindMember,
args: '',
},
Expand All @@ -23,7 +23,7 @@ it('returns message if member is not registered', async () => {

it('returns member location if found', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.FindMember,
args: '',
},
Expand Down
10 changes: 5 additions & 5 deletions src/commands/findMembersAt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cmdFindMembersAt } from './findMembersAt';

it('renders error message when no location is specified', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.FindMembersAt,
args: '',
},
Expand All @@ -21,7 +21,7 @@ it('renders error message when no location is specified', async () => {

it('renders error message when the location is specified is not found', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.FindMembersAt,
args: 'NXL',
},
Expand All @@ -39,7 +39,7 @@ it('renders simple message when there are less than 5 members registered', async
database: {
getMembersAt: () => fakeUserIds.slice(0, 2),
},
command: {
userCommand: {
command: Command.FindMembersAt,
args: 'NL',
},
Expand All @@ -57,7 +57,7 @@ it('renders no members message when there are no members registered', async () =
database: {
getMembersAt: () => [],
},
command: {
userCommand: {
command: Command.FindMembersAt,
args: 'NL',
},
Expand All @@ -72,7 +72,7 @@ it('renders no members message when there are no members registered', async () =

it('lists all members of NL', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'NL',
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/listCountryMemberCount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ it('renders no members message count when there are no members registered', asyn
database: {
getLocationIndex: () => ({}),
},
command: {
userCommand: {
command: Command.ListCountryMemberCount,
text: '',
},
Expand All @@ -23,7 +23,7 @@ it('renders no members message count when there are no members registered', asyn

it('renders list for all countries', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.ListCountryMemberCount,
text: '',
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/pingAdmins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdPingAdmins } from './pingAdmins';

it('pings 5 admins', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingAdmins,
args: '',
},
Expand Down
12 changes: 6 additions & 6 deletions src/commands/pingMembersAt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cmdPingMembersAt } from './pingMembersAt';

it('renders error message when no location is specified', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingMembersAt,
args: '',
},
Expand All @@ -21,7 +21,7 @@ it('renders error message when no location is specified', async () => {

it('renders error message when the location is specified is not found', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'NXL',
},
Expand All @@ -39,7 +39,7 @@ it('renders simple message when there are less than 5 members registered', async
database: {
getMembersAt: () => fakeUserIds.slice(0, 2),
},
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'NL',
},
Expand All @@ -57,7 +57,7 @@ it('renders no members message when there are no members registered', async () =
database: {
getMembersAt: () => [],
},
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'NL',
},
Expand All @@ -72,7 +72,7 @@ it('renders no members message when there are no members registered', async () =

it('pings all members of NL', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'NL',
},
Expand All @@ -89,7 +89,7 @@ it('pings all members of NL', async () => {

it('pings all remote members if the arg is `remote`', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingMembersAt,
args: 'remote',
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/pingRemote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ it('renders simple message when there are less than 5 members registered', async
database: {
getAllRemoteMembers: () => [448150814, 7823597648],
},
command: {
userCommand: {
command: Command.PingRemote,
args: '',
},
Expand All @@ -26,7 +26,7 @@ it('renders no members message when there are no members registered', async () =
database: {
getAllRemoteMembers: () => [],
},
command: {
userCommand: {
command: Command.PingRemote,
args: '',
},
Expand All @@ -41,7 +41,7 @@ it('renders no members message when there are no members registered', async () =

it('pings all remote members', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.PingRemote,
args: '',
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/rankCountryMemberCount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ it('renders no members message count when there are no members registered', asyn
database: {
getLocationIndex: () => ({}),
},
command: {
userCommand: {
command: Command.RankCountryMemberCount,
text: '',
},
Expand All @@ -23,7 +23,7 @@ it('renders no members message count when there are no members registered', asyn

it('renders rank for all countries', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RankCountryMemberCount,
text: '',
},
Expand Down
8 changes: 4 additions & 4 deletions src/commands/rankCountryRemoteMemberCount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdRankCountryRemoteMemberCount } from './rankCountryRemoteMemberCount'

it('returns error message when country code is not given', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RankCountryRemoteMemberCount,
text: '',
args: '',
Expand All @@ -21,7 +21,7 @@ it('returns error message when country code is not given', async () => {

it('returns error message when country code is invalid', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RankCountryRemoteMemberCount,
text: 'foobar',
args: 'foobar',
Expand All @@ -40,7 +40,7 @@ it('returns no member count when empty', async () => {
database: {
getRemoteMembersFrom: () => ({}),
},
command: {
userCommand: {
command: Command.RankCountryRemoteMemberCount,
text: 'BR',
args: 'BR',
Expand All @@ -56,7 +56,7 @@ it('returns no member count when empty', async () => {

it('returns rank for a list', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RankCountryRemoteMemberCount,
text: 'BR',
args: 'BR',
Expand Down
10 changes: 5 additions & 5 deletions src/commands/registerMemberAt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdRegisterMemberAt } from './registerMemberAt';

it('replies with syntax error when command is issued with no locations', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterMemberAt,
args: '',
},
Expand All @@ -20,7 +20,7 @@ it('replies with syntax error when command is issued with no locations', async (

it('replies with error when command is issued with invalid country', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterMemberAt,
args: 'NXL',
},
Expand All @@ -35,7 +35,7 @@ it('replies with error when command is issued with invalid country', async () =>

it('registers user successfully to a country with no one', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterMemberAt,
args: 'NO',
},
Expand All @@ -50,7 +50,7 @@ it('registers user successfully to a country with no one', async () => {

it('registers user successfully to a country with people registered', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterMemberAt,
args: 'PT',
},
Expand All @@ -65,7 +65,7 @@ it('registers user successfully to a country with people registered', async () =

it('notifies user in case they try to register to a place they are already registered', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterMemberAt,
args: 'NL',
},
Expand Down
12 changes: 6 additions & 6 deletions src/commands/registerRemoteMember.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cmdRegisterRemoteMember } from './registerRemoteMember';

it('replies with syntax error when command is issued with single location', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: 'BR',
},
Expand All @@ -20,7 +20,7 @@ it('replies with syntax error when command is issued with single location', asyn

it('replies with syntax error when command is issued with no locations', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: '',
},
Expand All @@ -35,7 +35,7 @@ it('replies with syntax error when command is issued with no locations', async (

it('replies with error when command is issued with invalid source location', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: 'NXL BR',
},
Expand All @@ -50,7 +50,7 @@ it('replies with error when command is issued with invalid source location', asy

it('replies with error when command is issued with invalid destiny location', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: 'BR NXL',
},
Expand All @@ -65,7 +65,7 @@ it('replies with error when command is issued with invalid destiny location', as

it('registers user successfully', async () => {
const { ctx, next, reply } = await createTestBotContext({
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: 'BR ES',
text: 'BR ES',
Expand All @@ -84,7 +84,7 @@ it('notifies user in case they try to register to a place they are already regis
database: {
hasRemoteMemberRegistered: () => true,
},
command: {
userCommand: {
command: Command.RegisterRemoteMember,
args: 'BR ES',
text: 'BR ES',
Expand Down

0 comments on commit 22807e0

Please sign in to comment.