-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3b87107
Showing
16 changed files
with
3,648 additions
and
0 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,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,2 @@ | ||
* text=auto | ||
*.js text eol=lf |
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 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Build | ||
lib | ||
.merlin | ||
|
||
# Logs | ||
*.log | ||
|
||
# macOS | ||
.*DS_Store |
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 @@ | ||
sudo: false | ||
|
||
language: node_js | ||
|
||
node_js: | ||
- 7 | ||
- 6 | ||
- 4 | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache |
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,26 @@ | ||
{ | ||
"name": "bs-react-test-renderer", | ||
"reason": { | ||
"react-jsx": true | ||
}, | ||
"bs-dependencies": [ | ||
"reason-react" | ||
], | ||
"bs-dev-dependencies": [ | ||
"bs-jest" | ||
], | ||
"sources": [ | ||
{ | ||
"dir": "src", | ||
"subdirs": [ | ||
{ | ||
"dir": "__tests__", | ||
"subdirs": [ | ||
"fixtures" | ||
], | ||
"type": "dev" | ||
} | ||
] | ||
} | ||
] | ||
} |
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 @@ | ||
## Change Log |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Neil Kistner <neil.kistner@gmail.com> (neilkistner.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,52 @@ | ||
{ | ||
"name": "bs-react-test-renderer", | ||
"version": "0.0.0", | ||
"description": "BuckleScript bindings for react-test-renderer.", | ||
"repository": "BuckleTypes/bs-react-test-renderer", | ||
"author": { | ||
"name": "Neil Kistner", | ||
"email": "neil.kistner@gmail.com", | ||
"url": "neilkistner.com" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"src/*.re", | ||
"bsconfig.json" | ||
], | ||
"scripts": { | ||
"build": "bsb -make-world", | ||
"changelog": "changelog-maker --filter-release -- BuckleTypes bs-react-test-renderer", | ||
"clean": "npm-run-all clean:*", | ||
"clean:bsb": "bsb -clean-world", | ||
"clean:project": "rimraf lib .merlin", | ||
"jest": "jest", | ||
"prebuild": "npm run clean", | ||
"test": "npm-run-all build jest", | ||
"version": "node scripts/version.js" | ||
}, | ||
"dependencies": { | ||
"react-test-renderer": "^15.5.4" | ||
}, | ||
"peerDependencies": { | ||
"reason-react": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"bs-jest": "git+https://github.com/BuckleTypes/bs-jest.git", | ||
"bs-platform": "git+https://github.com/bloomberg/bucklescript.git", | ||
"changelog-maker": "^2.2.5", | ||
"execa": "^0.6.3", | ||
"jest": "^19.0.2", | ||
"np": "^2.13.1", | ||
"npm-run-all": "^4.0.2", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4", | ||
"read-pkg": "^2.0.0", | ||
"reason-react": "^0.1.0", | ||
"rimraf": "^2.6.1" | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"fixtures" | ||
] | ||
} | ||
} |
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,95 @@ | ||
# bs-react-test-renderer | ||
|
||
[![Build Status][travis-image]][travis-url] | ||
[![npm][npm-image]][npm-url] | ||
[![dependencies][deps-image]][deps-url] | ||
[![devDependencies][depsdev-image]][depsdev-url] | ||
|
||
> [BuckleScript](//github.com/bloomberg/bucklescript) bindings for [react-test-renderer](//github.com/facebook/react/tree/master/packages/react-test-renderer). | ||
## Installation | ||
|
||
```sh | ||
$ yarn add --dev bs-react-test-renderer | ||
|
||
# or.. | ||
|
||
$ npm install --save-dev bs-react-test-renderer | ||
``` | ||
|
||
## Usage | ||
|
||
#### Add to `bsconfig.json` | ||
|
||
```json | ||
{ | ||
"bs-dev-dependencies": [ | ||
"bs-react-test-renderer" | ||
] | ||
} | ||
``` | ||
|
||
#### With [`bs-jest`](//github.com/BuckleTypes/bs-jest) | ||
|
||
```reason | ||
// Component_test.re | ||
open Jest; | ||
open ExpectJs; | ||
let _ = | ||
describe "Component" (fun _ => { | ||
test "renders" (fun _ => { | ||
let component = ReactShallowRenderer.renderWithRenderer <Component />; | ||
expect (Js.Undefined.return component) |> toBeDefined; | ||
}); | ||
}); | ||
``` | ||
|
||
## Examples | ||
|
||
See [`src/__tests__`](//github.com/BuckleTypes/bs-react-test-renderer/tree/master/src/__tests__) for some examples. | ||
|
||
For examples with Snapshot testing with [`bs-jest`](//github.com/BuckleTypes/bs-jest), see [`reason-calculator`](//github.com/wyze/reason-calculator). | ||
|
||
## Development | ||
|
||
```sh | ||
$ git clone https://github.com/BuckleTypes/bs-react-test-renderer.git | ||
$ cd bs-react-test-renderer | ||
$ yarn # or `npm install` | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
$ yarn build | ||
``` | ||
|
||
## Test | ||
|
||
```sh | ||
$ yarn test | ||
``` | ||
|
||
## Change Log | ||
|
||
> [Full Change Log](changelog.md) | ||
## License | ||
|
||
MIT © [Neil Kistner](https://neilkistner.com) | ||
|
||
[travis-image]: https://img.shields.io/travis/BuckleTypes/bs-react-test-renderer.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/BuckleTypes/bs-react-test-renderer | ||
|
||
[npm-image]: https://img.shields.io/npm/v/bs-react-test-renderer.svg?style=flat-square | ||
[npm-url]: https://npm.im/bs-react-test-renderer | ||
|
||
[deps-image]: https://img.shields.io/david/BuckleTypes/bs-react-test-renderer.svg?style=flat-square | ||
[deps-url]: https://david-dm.org/BuckleTypes/bs-react-test-renderer | ||
|
||
[depsdev-image]: https://img.shields.io/david/dev/BuckleTypes/bs-react-test-renderer.svg?style=flat-square | ||
[depsdev-url]: https://david-dm.org/BuckleTypes/bs-react-test-renderer?type=dev |
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,67 @@ | ||
const execa = require('execa') | ||
const readFile = require('fs').readFileSync | ||
const readPkg = require('read-pkg') | ||
const writeFile = require('fs').writeFileSync | ||
|
||
// get version from pkg.json | ||
const getVersionAndUrl = | ||
({ repository: { url }, version }) => ({ url, version }) | ||
|
||
// npm run changelog (and grab output) | ||
const getChanges = ({ url, version }) => { | ||
const { stdout } = execa.sync('npm', [ 'run', 'changelog', '--silent' ]) | ||
const changes = stdout.trim().split(' \n') | ||
|
||
return { changes, url, version } | ||
} | ||
|
||
// modify changelog.md | ||
const updateChangelog = ({ changes, url, version }) => { | ||
const file = 'changelog.md' | ||
const changelog = readFile(file).toString().split('\n') | ||
const date = new Date().toJSON().split('T').shift() | ||
const tag = `v${version}` | ||
const repo = url.replace(/\.?git(?!hub)\+?/g, '') | ||
const header = `### [${tag}](${repo}/releases/tag/${tag}) (${date})` | ||
const formatted = [ header, '', ...changes ] | ||
|
||
writeFile( | ||
file, | ||
[ | ||
...changelog.slice(0, 2), | ||
...formatted, | ||
...changelog.slice(1), | ||
].join('\n') | ||
) | ||
|
||
return formatted | ||
} | ||
|
||
// modify readme.md | ||
const updateReadme = formatted => { | ||
const file = 'readme.md' | ||
const readme = readFile(file).toString().split('\n') | ||
const start = '> [Full Change Log](changelog.md)' | ||
const end = '## License' | ||
|
||
writeFile( | ||
file, | ||
[ | ||
...readme.slice(0, readme.indexOf(start) + 2), | ||
...formatted, | ||
...readme.slice(readme.indexOf(end) - 1), | ||
].join('\n') | ||
) | ||
} | ||
|
||
// git add | ||
const runGitAdd = () => { | ||
execa.sync('git', [ 'add', '--all' ]) | ||
} | ||
|
||
readPkg() | ||
.then(getVersionAndUrl) | ||
.then(getChanges) | ||
.then(updateChangelog) | ||
.then(updateReadme) | ||
.then(runGitAdd) |
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,15 @@ | ||
type t; | ||
|
||
external createRenderer : | ||
unit => t = "" [@@bs.val] [@@bs.module "react-test-renderer/shallow"]; | ||
|
||
external render : | ||
t => ReactRe.reactElement => option ReactRe.reactElement = "" [@@bs.send]; | ||
|
||
external getRenderOutput : | ||
t => option ReactRe.reactElement = "" [@@bs.send]; | ||
|
||
external unmount : | ||
t => unit = "" [@@bs.send]; | ||
|
||
let renderWithRenderer = render (createRenderer ()); |
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,7 @@ | ||
type t; | ||
|
||
external create : | ||
ReactRe.reactElement => t = "" [@@bs.val] [@@bs.module "react-test-renderer"]; | ||
|
||
external toJSON : | ||
t => Js.Json.t = "" [@@bs.send]; |
Oops, something went wrong.