Skip to content

Commit

Permalink
fix: remove timestamp restriction on registerFeedback (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
figueredo authored Jul 24, 2024
1 parent d51499e commit 8c34eda
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/incogniaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export class IncogniaApi {
bodyParams: RegisterFeedbackBodyProps,
queryParams?: RegisterFeedbackParamsProps
): Promise<void> {
const { event, timestamp } = bodyParams || {}
if (!event || !timestamp) {
throw new IncogniaError('No event or timestamp provided')
const { event } = bodyParams || {}
if (!event) {
throw new IncogniaError('No event provided')
}

const params = queryParams && convertObjectToSnakeCase(queryParams)
Expand Down
42 changes: 38 additions & 4 deletions test/incogniaApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,40 @@ describe('API', () => {

await incogniaApi.registerFeedback(
{
installationId: 'installation_id',
accountId: 'account_id',
event: FeedbackEvent.AccountTakeover
},
{
dryRun: true
}
)

const expectedData = {
event: FeedbackEvent.AccountTakeover,
}

const expectedParams = {
dry_run: true
}

expect(incogniaApi.resourceRequest).toBeCalledWith({
url: apiEndpoints.FEEDBACKS,
method: 'post',
params: expectedParams,
data: expectedData
})
})

it('registers feedback when all params are filled', async () => {
incogniaApi.resourceRequest = vi.fn()

await incogniaApi.registerFeedback(
{
event: FeedbackEvent.AccountTakeover,
accountId: 'account_id',
installationId: 'installation_id',
loginId: 'login_id',
paymentId: 'payment_id',
signupId: 'signup_id',
timestamp: 123
},
{
Expand All @@ -239,9 +270,12 @@ describe('API', () => {
)

const expectedData = {
installation_id: 'installation_id',
account_id: 'account_id',
event: FeedbackEvent.AccountTakeover,
account_id: 'account_id',
installation_id: 'installation_id',
login_id: 'login_id',
payment_id: 'payment_id',
signup_id: 'signup_id',
timestamp: 123
}

Expand Down

0 comments on commit 8c34eda

Please sign in to comment.