Skip to content

Commit

Permalink
feat: rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
demetriusfeijoo committed Jan 2, 2025
1 parent 6ef345a commit b91e983
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('createPluginActions', () => {
expect(postToContainer).toHaveBeenLastCalledWith(
expect.objectContaining({
event: 'promptAI',
promptAI: promptAIPayload,
payload: promptAIPayload,
} satisfies Partial<PluginPromptAIMessage>),
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const stub: PluginPromptAIMessage = {
action: 'prompt-ai',
event: 'promptAI',
uid,
promptAI: {
payload: {
action: 'prompt',
text: 'Some text to prompt',
},
Expand Down Expand Up @@ -45,15 +45,15 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: undefined,
payload: undefined,
}),
).toEqual(false)
})
it('has the payload all required fields', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
action: '',
},
}),
Expand All @@ -62,7 +62,7 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
text: '',
},
}),
Expand All @@ -71,7 +71,7 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
action: 'prompt',
text: 'random text',
},
Expand All @@ -81,7 +81,7 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
action: 'prompt',
text: 123,
},
Expand All @@ -91,7 +91,7 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
action: null,
text: 123,
},
Expand All @@ -101,7 +101,7 @@ describe('PromptAIMessage', () => {
expect(
isPluginPromptAIMessage({
...stub,
promptAI: {
payload: {
action: null,
text: null,
},
Expand All @@ -112,14 +112,13 @@ describe('PromptAIMessage', () => {
describe('constructor', () => {
it('includes the uid', () => {
expect(
getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }),
getPluginPromptAIMessage(stub.payload, { uid, callbackId }),
).toHaveProperty('uid', uid)
})
console.log(getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }))
it('includes the promptAI data added to the message', () => {
expect(
getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }),
).toHaveProperty('promptAI')
getPluginPromptAIMessage(stub.payload, { uid, callbackId }),
).toHaveProperty('payload')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ export type PluginPromptAIMessage = Omit<
'action'
> & {
action: 'prompt-ai'
promptAI: PromptAIPayload
payload: PromptAIPayload
}

export const isPluginPromptAIMessage = (
obj: unknown,
): obj is PluginPromptAIMessage =>
isMessageToContainer(obj) &&
obj.event === 'promptAI' &&
hasKey(obj, 'promptAI') &&
isPromptAIPayloadValid(obj.promptAI as PromptAIPayload)
obj.event === 'payload' &&
hasKey(obj, 'payload') &&
isPromptAIPayloadValid(obj.payload as PromptAIPayload)

export const getPluginPromptAIMessage = (
message: PromptAIPayload,
Expand All @@ -65,7 +65,7 @@ export const getPluginPromptAIMessage = (
action: 'prompt-ai',
event: 'promptAI',
...options,
promptAI: { ...message },
payload: { ...message },
})

const isPromptAIPayloadValid = (promptAIPayload: PromptAIPayload) =>
Expand Down

0 comments on commit b91e983

Please sign in to comment.