-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
binds roamJsonToBlocks and validateRoam to importText
- Loading branch information
1 parent
ddafbfd
commit 0679694
Showing
2 changed files
with
100 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,97 @@ it('two root thoughts', async () => { | |
expect(exported.trim()) | ||
.toBe(text) | ||
}) | ||
|
||
it('imports Roam json', async () => { | ||
const roamString = JSON.stringify([ | ||
{ | ||
title: 'Fruits', | ||
children: [ | ||
{ | ||
string: 'Apple', | ||
'create-email': '[email protected]', | ||
'edit-email': '[email protected]', | ||
'create-time': 1600111381583, | ||
'edit-time': 1600111381580, | ||
uid: 'UK11200', | ||
}, | ||
{ | ||
string: 'Orange', | ||
'create-email': '[email protected]', | ||
'edit-email': '[email protected]', | ||
'create-time': 1600111383054, | ||
'edit-time': 1600111383050, | ||
uid: 'UK11233', | ||
}, | ||
{ | ||
string: 'Banana', | ||
'create-email': '[email protected]', | ||
'edit-email': '[email protected]', | ||
'create-time': 1600111383911, | ||
'edit-time': 1600111383910, | ||
uid: 'HMN_YQtZZ', | ||
} | ||
], | ||
}, | ||
{ | ||
title: 'Veggies', | ||
children: [ | ||
{ | ||
string: 'Broccoli', | ||
'create-email': '[email protected]', | ||
'edit-email': '[email protected]', | ||
'create-time': 1600111381600, | ||
'edit-time': 1600111381599, | ||
uid: 'BK11200', | ||
}, | ||
{ | ||
string: 'Spinach', | ||
'create-email': '[email protected]', | ||
'edit-email': '[email protected]', | ||
'create-time': 1600111389054, | ||
'edit-time': 1600111389050, | ||
uid: 'BK11233', | ||
} | ||
], | ||
} | ||
]) | ||
// /** | ||
// * Parses Roam and generates { contextIndexUpdates, thoughtIndexUpdates } that can be sync'd to state. | ||
// */ | ||
// export const importRoam = (state: State, simplePath: SimplePath, roam: RoamPage[]) => { | ||
// const thoughtsJSON = roamJsonToBlocks(roam) | ||
// return importJSON(state, simplePath, thoughtsJSON, { skipRoot: false }) | ||
// } | ||
|
||
const exported = await importExport(roamString) | ||
expect(exported) | ||
.toBe(` | ||
- Fruits | ||
- Apple | ||
- =create-email | ||
- [email protected] | ||
- =edit-email | ||
- [email protected] | ||
- Orange | ||
- =create-email | ||
- [email protected] | ||
- =edit-email | ||
- [email protected] | ||
- Banana | ||
- =create-email | ||
- [email protected] | ||
- =edit-email | ||
- [email protected] | ||
- Veggies | ||
- Broccoli | ||
- =create-email | ||
- [email protected] | ||
- =edit-email | ||
- [email protected] | ||
- Spinach | ||
- =create-email | ||
- [email protected] | ||
- =edit-email | ||
- [email protected] | ||
`) | ||
}) |