-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for checking resolved links and update misc assertion…
… syntax
- Loading branch information
1 parent
baf7917
commit db91eb2
Showing
3 changed files
with
107 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Block, LinkBlock } from '@contensis/canvas-types'; | ||
|
||
export const getAllBlockTypes = (blocks: Block[], types: Block['type'][] = []) => { | ||
for (const block of blocks) { | ||
types.push(block.type); | ||
if (Array.isArray(block.value)) getAllBlockTypes(block.value, types); | ||
} | ||
return types; | ||
}; | ||
|
||
export const getAllLinkBlocks = (blocks: Block[], links: LinkBlock[] = []) => { | ||
for (const block of blocks) { | ||
if (block.type === '_link') links.push(block); | ||
if (Array.isArray(block.value)) getAllLinkBlocks(block.value, links); | ||
} | ||
return links; | ||
}; |