-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rossum Sheets: gracefully handle datetime
- Loading branch information
Showing
5 changed files
with
186 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// @flow | ||
|
||
import processRossumPayload from '../../processRossumPayload'; | ||
import createMockPayload from '../createMockPayload'; | ||
|
||
it('correctly deals with currencies', () => { | ||
const config = { | ||
sheets: { | ||
headers: { | ||
columns: { A: 'number_currency' }, | ||
formulas: [ | ||
{ | ||
fx: '=A1', | ||
target: 'notes', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const payload = createMockPayload(config); | ||
expect(processRossumPayload(payload)).toMatchInlineSnapshot(` | ||
{ | ||
"automation_blockers": [], | ||
"messages": [], | ||
"operations": [ | ||
{ | ||
"id": 9999, | ||
"op": "replace", | ||
"value": { | ||
"content": { | ||
"value": "42", | ||
}, | ||
}, | ||
}, | ||
], | ||
} | ||
`); | ||
}); |
108 changes: 108 additions & 0 deletions
108
src/rossum-sheets/src/__tests__/configs/datetime.test.js
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,108 @@ | ||
// @flow | ||
|
||
import processRossumPayload from '../../processRossumPayload'; | ||
import createMockPayload from '../createMockPayload'; | ||
|
||
it('correctly replaces date values', () => { | ||
const config = { | ||
sheets: { | ||
headers: { | ||
columns: { A: 'number_date' }, | ||
formulas: [ | ||
{ | ||
fx: '=A1', | ||
target: 'notes', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const payload = createMockPayload(config); | ||
expect(processRossumPayload(payload)).toMatchInlineSnapshot(` | ||
{ | ||
"automation_blockers": [], | ||
"messages": [], | ||
"operations": [ | ||
{ | ||
"id": 9999, | ||
"op": "replace", | ||
"value": { | ||
"content": { | ||
"value": "2024-1-24", | ||
}, | ||
}, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
|
||
it('correctly replaces datetime values', () => { | ||
const config = { | ||
sheets: { | ||
headers: { | ||
columns: { A: 'number_datetime' }, | ||
formulas: [ | ||
{ | ||
fx: '=A1', | ||
target: 'notes', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const payload = createMockPayload(config); | ||
expect(processRossumPayload(payload)).toMatchInlineSnapshot(` | ||
{ | ||
"automation_blockers": [], | ||
"messages": [], | ||
"operations": [ | ||
{ | ||
"id": 9999, | ||
"op": "replace", | ||
"value": { | ||
"content": { | ||
"value": "2024-1-24", | ||
}, | ||
}, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
|
||
it('correctly replaces time values', () => { | ||
const config = { | ||
sheets: { | ||
headers: { | ||
columns: { A: 'number_time' }, | ||
formulas: [ | ||
{ | ||
fx: '=A1', | ||
target: 'notes', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const payload = createMockPayload(config); | ||
|
||
// TODO: this is a bit unspecified I'd say: | ||
expect(processRossumPayload(payload)).toMatchInlineSnapshot(` | ||
{ | ||
"automation_blockers": [], | ||
"messages": [], | ||
"operations": [ | ||
{ | ||
"id": 9999, | ||
"op": "replace", | ||
"value": { | ||
"content": { | ||
"value": "0.516666666666667", | ||
}, | ||
}, | ||
}, | ||
], | ||
} | ||
`); | ||
}); |
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