Skip to content

Commit

Permalink
add: add remark-react output tests
Browse files Browse the repository at this point in the history
Add `transformToReact` helper using `react-test-renderer`

Add `babel-preset-react` for transpiling JSX

Add `react` devDependency

Add `Icon` mock react component

Comment boolean prop test while waiting for [`remark-react`](https://github.com/mapbox/remark-react) and [`hast-to-hyperscript`](https://github.com/syntax-tree/hast-to-hyperscript) to be updated in remarkjs/remark-react#41
Ignore main function statement as it seems not covered in specific cases...
  • Loading branch information
medfreeman committed May 16, 2017
1 parent cad5cc5 commit 5b73407
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/__tests__/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ test(

test(
"should add an extension with an id",
t => t.snapshot(transformToReact("!icon{ #my-id }"))
t => t.snapshot(transformToReact("!Icon{ #my-id }"))
)

test(
"should add an extension with a class",
t => t.snapshot(transformToReact("!icon{ .my-class }"))
t => t.snapshot(transformToReact("!Icon{ .my-class }"))
)

test(
"should add an extension with an attribute",
t => t.snapshot(transformToReact("!icon{ attr=my-attr }"))
t => t.snapshot(transformToReact("!Icon{ attr=my-attr }"))
)

test(
"should add an extension with a quoted attribute",
t => t.snapshot(transformToReact(`!icon{ attr="my attribute" }`))
t => t.snapshot(transformToReact(`!Icon{ attr="my attribute" }`))
)

test(
"should add an extension with a lone attribute",
t => t.snapshot(transformToReact(`!icon{ attr }`))
t => t.snapshot(transformToReact(`!Icon{ attr }`))
)

test(
"should add an extension with a lone attribute with a default value",
t => t.snapshot(
transformToReact(
`!icon{ attr }`,
`!Icon{ attr }`,
{
elements: {
icon: {
Icon: {
attributeDefaultValues: {
attr: "default",
}
Expand All @@ -54,10 +54,10 @@ test(
"should add an extension with a lone attribute with a default boolean value",
t => t.snapshot(
transformToReact(
`!icon{ highlight }`,
`!Icon{ highlight }`,
{
elements: {
icon: {
Icon: {
attributeDefaultValues: {
highlight: true,
}
Expand All @@ -72,10 +72,10 @@ test(
"should add an extension with all types of parameters",
t => t.snapshot(
transformToReact(
`!icon{ #my-id .my-class attr attr2=my-attr attr3="my attribute" }`,
`!Icon{ #my-id .my-class attr attr2=my-attr attr3="my attribute" }`,
{
elements: {
icon: {
Icon: {
attributeDefaultValues: {
attr: "default",
}
Expand All @@ -90,10 +90,10 @@ test(
"should add an extension with a mapped content",
t => t.snapshot(
transformToReact(
"!icon[my-tooltip]",
"!Icon[my-tooltip]",
{
elements: {
icon: {
Icon: {
attributeMap: {
content: "tooltip",
}
Expand All @@ -108,10 +108,10 @@ test(
"should add an extension with a mapped argument",
t => t.snapshot(
transformToReact(
"!icon(my-icon)",
"!Icon(my-icon)",
{
elements: {
icon: {
Icon: {
attributeMap: {
argument: "icon",
}
Expand All @@ -128,7 +128,7 @@ test(
transformToReact(
`#heading
!icon(my-icon)`
!Icon(my-icon)`
)
)
)
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _.mixin({
}
})

/* istanbul ignore next */
function remarkGenericExtensions(options = {}) {
const settings = Object.assign({}, {
debug: false,
Expand Down

0 comments on commit 5b73407

Please sign in to comment.