-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30410 from wlegolas/bugfix/issue-30303
Fix bug when editing any IOU information the date is automatically reduced by one
- Loading branch information
Showing
4 changed files
with
110 additions
and
7 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
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,64 @@ | ||
import * as TransactionUtils from '../../src/libs/TransactionUtils'; | ||
import type {Transaction} from '../../src/types/onyx'; | ||
|
||
function generateTransaction(values: Partial<Transaction> = {}): Transaction { | ||
const reportID = '1'; | ||
const amount = 100; | ||
const currency = 'USD'; | ||
const comment = ''; | ||
const created = '2023-10-01'; | ||
const baseValues = TransactionUtils.buildOptimisticTransaction(amount, currency, reportID, comment, created); | ||
|
||
return {...baseValues, ...values}; | ||
} | ||
|
||
describe('TransactionUtils', () => { | ||
describe('getCreated', () => { | ||
describe('when the transaction property "modifiedCreated" has value', () => { | ||
const transaction = generateTransaction({ | ||
created: '2023-10-01', | ||
modifiedCreated: '2023-10-25', | ||
}); | ||
|
||
it('returns the "modifiedCreated" date with the correct format', () => { | ||
const expectedResult = '2023-10-25'; | ||
|
||
const result = TransactionUtils.getCreated(transaction); | ||
|
||
expect(result).toEqual(expectedResult); | ||
}); | ||
}); | ||
|
||
describe('when the transaction property "modifiedCreated" does not have value', () => { | ||
describe('and the transaction property "created" has value', () => { | ||
const transaction = generateTransaction({ | ||
created: '2023-10-01', | ||
modifiedCreated: undefined, | ||
}); | ||
|
||
it('returns the "created" date with the correct format', () => { | ||
const expectedResult = '2023-10-01'; | ||
|
||
const result = TransactionUtils.getCreated(transaction); | ||
|
||
expect(result).toEqual(expectedResult); | ||
}); | ||
}); | ||
|
||
describe('and the transaction property "created" does not have value', () => { | ||
const transaction = generateTransaction({ | ||
created: undefined, | ||
modifiedCreated: undefined, | ||
}); | ||
|
||
it('returns an empty string', () => { | ||
const expectedResult = ''; | ||
|
||
const result = TransactionUtils.getCreated(transaction); | ||
|
||
expect(result).toEqual(expectedResult); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |