Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Le Cam committed Apr 3, 2018
1 parent 5976a9b commit 51073c1
Show file tree
Hide file tree
Showing 31 changed files with 6,819 additions and 772 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__tests__
coverage
flow-typed
src
.babelrc
.editorconfig
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## v0.6.0 (2018-04-03)

* Updated minimum supported version of React to v16.2.0.
* Added support for `Fragment` component introduced in v16.2.0.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Paul Le Cam and contributors
Copyright (c) 2018 Mainframe and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 15 additions & 0 deletions __tests__/__snapshots__/lib.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Fragment works end-to-end 1`] = `
Array [
<span
className="text"
>
hello
</span>,
<span
className="text"
>
test
</span>,
]
`;

exports[`works end-to-end 1`] = `
<div
className="view view-wrapper"
Expand Down
11 changes: 11 additions & 0 deletions __tests__/__snapshots__/renderer.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ exports[`Renderer returns the processed tree 1`] = `
</div>
`;

exports[`Renderer supports Fragment 1`] = `
Array [
<span>
Hello
</span>,
<span>
world
</span>,
]
`;

exports[`Renderer supports nesting children arrays 1`] = `
<div>
<span>
Expand Down
32 changes: 31 additions & 1 deletion __tests__/converter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global describe it */

import React, { Component } from 'react'
import React, { Component, Fragment } from 'react'

import { convertToObject, convertToJSON } from '../src/converter'

Expand Down Expand Up @@ -227,6 +227,36 @@ describe('convertToObject', () => {
})
})

it('supports Fragment', () => {
expect(
convertToObject(
<Fragment>
<Child key="a" test />
<Child key="b" />
</Fragment>,
),
).toEqual({
type: 'Fragment',
props: {
children: [
{
type: 'Child',
props: {
key: 'a',
test: true,
},
},
{
type: 'Child',
props: {
key: 'b',
},
},
],
},
})
})

it('returns an unsupported component with empty props if the type is unknow', () => {
expect(
convertToObject({
Expand Down
23 changes: 22 additions & 1 deletion __tests__/lib.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global it */

import React, { Component } from 'react'
import React, { Component, Fragment } from 'react'
import renderer from 'react-test-renderer'

import {
Expand Down Expand Up @@ -52,3 +52,24 @@ it('works end-to-end', () => {
.toJSON()
expect(tree).toMatchSnapshot()
})

it('Fragment works end-to-end', () => {
const Text = 'Text'

const json = convertToJSON(
<Fragment>
<Text key="1">hello</Text>
<Text key="2">test</Text>
</Fragment>,
{ space: 2 },
)

const components = {
Text: ({ children }) => <span className="text">{children}</span>,
}

const tree = renderer
.create(<Renderer components={components} json={json} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
23 changes: 22 additions & 1 deletion __tests__/renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global describe it */

import React, { Component } from 'react'
import React, { Component, Fragment } from 'react'
import renderer from 'react-test-renderer'

import { renderFromObject, Renderer } from '../src/renderer'
Expand Down Expand Up @@ -120,6 +120,27 @@ describe('Renderer', () => {
expect(tree).toMatchSnapshot()
})

it('supports Fragment', () => {
const tree = renderer
.create(
<Renderer
tree={{
type: 'Fragment',
props: {
children: [
{ type: 'Text', props: { key: '1', value: 'Hello' } },
{ type: 'Text', props: { key: '2', value: 'world' } },
],
},
}}
components={components}
fallback={Fallback}
/>,
)
.toJSON()
expect(tree).toMatchSnapshot()
})

it('parses and renders the provided JSON string', () => {
const json = JSON.stringify(tree1)
const tree = renderer
Expand Down
108 changes: 108 additions & 0 deletions flow-typed/npm/babel-cli_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// flow-typed signature: c84ee8c86512a8c2d753726ebf0ea9eb
// flow-typed version: <<STUB>>/babel-cli_v^6.26.0/flow_v0.69.0

/**
* This is an autogenerated libdef stub for:
*
* 'babel-cli'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'babel-cli' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babel-cli/bin/babel-doctor' {
declare module.exports: any;
}

declare module 'babel-cli/bin/babel-external-helpers' {
declare module.exports: any;
}

declare module 'babel-cli/bin/babel-node' {
declare module.exports: any;
}

declare module 'babel-cli/bin/babel' {
declare module.exports: any;
}

declare module 'babel-cli/lib/_babel-node' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel-external-helpers' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel-node' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel/dir' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel/file' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel/index' {
declare module.exports: any;
}

declare module 'babel-cli/lib/babel/util' {
declare module.exports: any;
}

// Filename aliases
declare module 'babel-cli/bin/babel-doctor.js' {
declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>;
}
declare module 'babel-cli/bin/babel-external-helpers.js' {
declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>;
}
declare module 'babel-cli/bin/babel-node.js' {
declare module.exports: $Exports<'babel-cli/bin/babel-node'>;
}
declare module 'babel-cli/bin/babel.js' {
declare module.exports: $Exports<'babel-cli/bin/babel'>;
}
declare module 'babel-cli/index' {
declare module.exports: $Exports<'babel-cli'>;
}
declare module 'babel-cli/index.js' {
declare module.exports: $Exports<'babel-cli'>;
}
declare module 'babel-cli/lib/_babel-node.js' {
declare module.exports: $Exports<'babel-cli/lib/_babel-node'>;
}
declare module 'babel-cli/lib/babel-external-helpers.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>;
}
declare module 'babel-cli/lib/babel-node.js' {
declare module.exports: $Exports<'babel-cli/lib/babel-node'>;
}
declare module 'babel-cli/lib/babel/dir.js' {
declare module.exports: $Exports<'babel-cli/lib/babel/dir'>;
}
declare module 'babel-cli/lib/babel/file.js' {
declare module.exports: $Exports<'babel-cli/lib/babel/file'>;
}
declare module 'babel-cli/lib/babel/index.js' {
declare module.exports: $Exports<'babel-cli/lib/babel/index'>;
}
declare module 'babel-cli/lib/babel/util.js' {
declare module.exports: $Exports<'babel-cli/lib/babel/util'>;
}
Loading

0 comments on commit 51073c1

Please sign in to comment.