Skip to content

Commit

Permalink
Collect test coverage (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
danreeves authored Apr 21, 2018
1 parent a7dbb2c commit ec927d5
Show file tree
Hide file tree
Showing 8 changed files with 3,580 additions and 251 deletions.
57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# React Tether

[![Build Status](https://travis-ci.org/danreeves/react-tether.svg?branch=browser-tests)](https://travis-ci.org/danreeves/react-tether) [![Dependency Status](https://david-dm.org/danreeves/react-tether.svg)](https://david-dm.org/danreeves/react-tether)
[![Build Status](https://travis-ci.org/danreeves/react-tether.svg?branch=browser-tests)](https://travis-ci.org/danreeves/react-tether) [![Dependency Status](https://david-dm.org/danreeves/react-tether.svg)](https://david-dm.org/danreeves/react-tether) [![Coverage Status](https://coveralls.io/repos/github/danreeves/react-tether/badge.svg?branch=master)](https://coveralls.io/github/danreeves/react-tether?branch=master)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/react-tether.svg)](https://saucelabs.com/u/react-tether)

> Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com/).
---
Expand All @@ -20,41 +21,46 @@ React wrapper around [Tether](https://github.com/hubspot/tether) from Hub Spot.
## Example Usage

```javascript
import TetherComponent from 'react-tether'
import TetherComponent from 'react-tether';

class SimpleDemo extends React.Component {
constructor(props) {
super(props)
super(props);
this.state = {
isOpen: false
}
isOpen: false,
};
}

render() {
const { isOpen } = this.state
const { isOpen } = this.state;

return(
return (
<TetherComponent
attachment="top center"
constraints={[{
to: 'scrollParent',
attachment: 'together'
}]}
constraints={[
{
to: 'scrollParent',
attachment: 'together',
},
]}
>
{ /* First child: This is what the item will be tethered to */ }
<button onClick={() => {this.setState({isOpen: !isOpen})}}>
{/* First child: This is what the item will be tethered to */}
<button
onClick={() => {
this.setState({ isOpen: !isOpen });
}}
>
Toggle Tethered Content
</button>
{ /* Second child: If present, this item will be tethered to the the first child */ }
{
isOpen &&
{/* Second child: If present, this item will be tethered to the the first child */}
{isOpen && (
<div>
<h2>Tethered Content</h2>
<p>A paragraph to accompany the title.</p>
</div>
}
)}
</TetherComponent>
)
);
}
}
```
Expand Down Expand Up @@ -83,15 +89,16 @@ Any valid [Tether options](http://tether.io/#options).

The following methods are exposed on the component instance:

- `getTetherInstance(): Tether`
- `disable(): void`
- `enable(): void`
- `on(event: string, handler: function, ctx: any): void`
- `once(event: string, handler: function, ctx: any): void`
- `off(event: string, handler: function): void`
- `position(): void`
* `getTetherInstance(): Tether`
* `disable(): void`
* `enable(): void`
* `on(event: string, handler: function, ctx: any): void`
* `once(event: string, handler: function, ctx: any): void`
* `off(event: string, handler: function): void`
* `position(): void`

#### Example usage:

```javascript
<TetherComponent ref={tether => this.tether = tether}>
<Target/>
Expand Down
21 changes: 17 additions & 4 deletions bin/test
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#!/usr/bin/env bash

npm run danger

npm run react:15
npm run unit
npm run unit -- --coverage
mv coverage/coverage-final.json coverage/coverage-react15.json

npm run react:16
npm run unit
npm run unit -- --coverage
mv coverage/coverage-final.json coverage/coverage-react16.json

mkdir -p .nyc_output
npx istanbul-merge \
--out .nyc_output/coverage-final.json \
coverage/coverage-react15.json \
coverage/coverage-react16.json

rm -rf coverage

npx nyc report --reporter=text-lcov | npx coveralls
npx nyc report --reporter=json-summary

npm run danger

if [ -z "$SAUCE_USERNAME" ] && [ -z "$SAUCE_ACCESS_KEY"]; then
echo
Expand Down
5 changes: 4 additions & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { warn, message, danger } from 'danger';
import { warn, message, schedule, danger } from 'danger';
import { istanbulCoverage } from 'danger-plugin-istanbul-coverage';

const modified = danger.git.modified_files;
const modifiedSrc = modified.filter(p => p.includes('src/'));
Expand All @@ -25,3 +26,5 @@ if (danger.github.pr.body.length === 0) {
if (testChanges.length > 0) {
message(':tada: Thanks for working on tests!');
}

schedule(istanbulCoverage());
Loading

0 comments on commit ec927d5

Please sign in to comment.