-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add exports util with tests (#1045)
[![PR App][icn]][demo] | Fix RM-XYZ :-------------------:|:----------: ## 🧰 Changes - Adds a util for parsing out the export names from an MDX string - Adds tests for a few different cases ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
- Loading branch information
1 parent
bf9ed34
commit e5180a4
Showing
13 changed files
with
1,194 additions
and
5 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,19 @@ | ||
import singleExportMdx from './input/singleExport.mdx?raw'; | ||
import multipleExportsMdx from './input/multipleExports.mdx?raw'; | ||
import weirdExportsMdx from './input/weirdExports.mdx?raw'; | ||
import { exports } from '../../../lib'; | ||
|
||
describe('export tags', () => { | ||
it('returns a single export name', () => { | ||
|
||
expect(exports(singleExportMdx)).toStrictEqual(['Foo']); | ||
}); | ||
it('returns multiple export names', () => { | ||
|
||
expect(exports(multipleExportsMdx)).toStrictEqual(['Foo', 'Bar']); | ||
}); | ||
it('returns different types of export names', () => { | ||
|
||
expect(exports(weirdExportsMdx)).toStrictEqual(['Foo', 'bar', 'doSomethingFunction', 'YELLING']); | ||
}); | ||
}); |
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,12 @@ | ||
import React from 'react'; | ||
|
||
export const Foo = () => { | ||
return <div>Hello World</div>; | ||
} | ||
|
||
export const Bar = () => { | ||
return <Foo />; | ||
} | ||
|
||
## Hey there | ||
<Foo /> |
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,8 @@ | ||
import React from 'react'; | ||
|
||
export const Foo = () => { | ||
return <div>Hello World</div>; | ||
} | ||
|
||
## Hey there | ||
<Foo /> |
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,19 @@ | ||
import React from 'react'; | ||
|
||
export function Foo() { | ||
return <div>Hello World</div>; | ||
} | ||
|
||
export const bar = () => { | ||
return <Foo />; | ||
} | ||
|
||
export function doSomethingFunction(input) { | ||
return input.trim(); | ||
} | ||
|
||
export const | ||
YELLING = () => {} | ||
|
||
## Hey there | ||
<Foo /> |
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
Oops, something went wrong.