Skip to content

Commit

Permalink
fix(tests): fix tests not using defaults and polls
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 17, 2024
1 parent 4705fc4 commit 7282979
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
24 changes: 16 additions & 8 deletions test/structures/interfaces/commandContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('CommandContext', () => {
done();
},
false,
false,
false,
undefined,
undefined,
undefined
);

Expand All @@ -48,29 +48,29 @@ describe('CommandContext', () => {
});

describe('For an interaction with no options', () => {
const ctx = new CommandContext(creator, basicInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(creator, basicInteraction, noop, false, undefined, undefined, undefined);

it('does not have options in the context', () => expect(ctx.options).to.deep.equal({}));
it('does not have subcommands in the context', () => expect(ctx.subcommands).to.deep.equal([]));
});

describe('For an interaction with options', () => {
const ctx = new CommandContext(creator, optionsInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(creator, optionsInteraction, noop, false, undefined, undefined, undefined);

it('has options in the context', () => expect(ctx.options).to.deep.equal({ string: 'hi', int: 2, bool: true }));
it('does not have subcommands in the context', () => expect(ctx.subcommands).to.deep.equal([]));
});

describe('For an interaction with a sub-command', () => {
const ctx = new CommandContext(creator, subCommandInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(creator, subCommandInteraction, noop, false, undefined, undefined, undefined);

it('has an empty options object within the sub-command', () =>
expect(ctx.options).to.deep.equal({ 'sub-command': {} }));
it('has a subcommand in the context', () => expect(ctx.subcommands).to.deep.equal(['sub-command']));
});

describe('For an interaction with a sub-command group', () => {
const ctx = new CommandContext(creator, subCommandGroupInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(creator, subCommandGroupInteraction, noop, false, undefined, undefined, undefined);

it('has an empty options object within the sub-command group', () =>
expect(ctx.options).to.deep.equal({ 'sub-command-group': { 'sub-command': {} } }));
Expand All @@ -79,15 +79,23 @@ describe('CommandContext', () => {
});

describe('For an interaction with a sub-command with options', () => {
const ctx = new CommandContext(creator, subCommandOptionsInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(
creator,
subCommandOptionsInteraction,
noop,
false,
undefined,
undefined,
undefined
);

it('has options within the sub-command', () =>
expect(ctx.options).to.deep.equal({ 'sub-command': { string: 'hi', int: 2, bool: true } }));
it('has subcommands in the context', () => expect(ctx.subcommands).to.deep.equal(['sub-command']));
});

it('assigns properties properly', async () => {
const ctx = new CommandContext(creator, basicInteraction, noop, false, false, false, undefined);
const ctx = new CommandContext(creator, basicInteraction, noop, false, undefined, undefined, undefined);
await ctx.defer();

expect(ctx.users.size).to.equal(0);
Expand Down
14 changes: 7 additions & 7 deletions test/structures/interfaces/componentContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ComponentContext', () => {
expect(treq.status).to.equal(200);
done();
},
false,
undefined,
undefined
);

Expand All @@ -45,7 +45,7 @@ describe('ComponentContext', () => {
});

it('assigns properties properly', async () => {
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, false, undefined);
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, undefined, undefined);
await ctx.acknowledge();

expect(ctx.message.id).to.equal(basicMessageInteraction.message.id);
Expand All @@ -54,7 +54,7 @@ describe('ComponentContext', () => {
});

it('assigns properties properly for select interactions', async () => {
const ctx = new ComponentContext(creator, selectMessageInteraction, noop, false, undefined);
const ctx = new ComponentContext(creator, selectMessageInteraction, noop, undefined, undefined);
await ctx.acknowledge();

expect(ctx.message.id).to.equal(selectMessageInteraction.message.id);
Expand All @@ -75,7 +75,7 @@ describe('ComponentContext', () => {
});
expect(treq.status).to.equal(200);
},
false,
undefined,
undefined
);
expect(ctx.initiallyResponded).to.equal(false);
Expand All @@ -85,7 +85,7 @@ describe('ComponentContext', () => {
});

it('returns false when already responded', async () => {
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, false, undefined);
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, undefined, undefined);
await ctx.acknowledge();
await expect(ctx.acknowledge()).to.eventually.equal(false);
});
Expand All @@ -110,7 +110,7 @@ describe('ComponentContext', () => {
});
expect(treq.status).to.equal(200);
},
false,
undefined,
undefined
);
expect(ctx.initiallyResponded).to.equal(false);
Expand All @@ -119,7 +119,7 @@ describe('ComponentContext', () => {
});

it('edits original message after acknowledging', async () => {
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, false, undefined);
const ctx = new ComponentContext(creator, basicMessageInteraction, noop, undefined, undefined);
const scope = editMessage(basicMessageInteraction.message.id, followUpMessage);

await ctx.acknowledge();
Expand Down
6 changes: 4 additions & 2 deletions test/structures/interfaces/messageInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ describe('MessageInteractionContext', () => {
flags: undefined,
tts: undefined,
components: undefined,
attachments: undefined
attachments: undefined,
poll: undefined
}
});
expect(treq.status).to.equal(200);
Expand Down Expand Up @@ -126,7 +127,8 @@ describe('MessageInteractionContext', () => {
flags: InteractionResponseFlags.EPHEMERAL,
tts: undefined,
components: undefined,
attachments: undefined
attachments: undefined,
poll: undefined
}
});
expect(treq.status).to.equal(200);
Expand Down
4 changes: 2 additions & 2 deletions test/structures/interfaces/modalInteractionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('ModalInteractionContext', () => {
expect(treq.status).to.equal(200);
done();
},
false,
undefined,
undefined
);

Expand All @@ -34,7 +34,7 @@ describe('ModalInteractionContext', () => {
});

it('assigns properties properly', async () => {
const ctx = new ModalInteractionContext(creator, modalInteraction, noop, false, undefined);
const ctx = new ModalInteractionContext(creator, modalInteraction, noop, undefined, undefined);

expect(ctx.values).to.deep.equal({ text: 'hi' });
expect(ctx.customID).to.equal('modal');
Expand Down

0 comments on commit 7282979

Please sign in to comment.