diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..18cbe17 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,11 @@ +name: Validate +on: [push] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: yarn install + - run: yarn validate + - run: yarn test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e62e532..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -cache: yarn -node_js: - - '10.15.3' -script: - - yarn validate - - yarn test \ No newline at end of file diff --git a/README.md b/README.md index 0690922..ba67721 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [`useMemo`](https://reactjs.org/docs/hooks-reference.html#usememo) and [`useCallback`](https://reactjs.org/docs/hooks-reference.html#usecallback) with a stable cache (semantic guarantee) -[![Build Status](https://travis-ci.org/alexreardon/use-memo-one.svg?branch=master)](https://travis-ci.org/alexreardon/use-memo-one) +[![Build Status](https://github.com/alexreardon/use-memo-one/actions?query=workflow%3AValidate)](https://github.com/alexreardon/use-memo-one/workflows/Validate/badge.svg) [![npm](https://img.shields.io/npm/v/use-memo-one.svg)](https://www.npmjs.com/package/use-memo-one) [![dependencies](https://david-dm.org/alexreardon/use-memo-one.svg)](https://david-dm.org/alexreardon/use-memo-one) [![min](https://img.shields.io/bundlephobia/min/use-memo-one.svg)](https://bundlephobia.com/result?p=use-memo-one) diff --git a/src/index.js b/src/index.js index e0635f5..431349c 100644 --- a/src/index.js +++ b/src/index.js @@ -22,11 +22,13 @@ export function useMemoOne( const committed = useRef>(initial); // persist any uncommitted changes after they have been committed - const useCache: boolean = isFirstRun.current || Boolean( - inputs && - committed.current.inputs && - areInputsEqual(inputs, committed.current.inputs), - ); + const useCache: boolean = + isFirstRun.current || + Boolean( + inputs && + committed.current.inputs && + areInputsEqual(inputs, committed.current.inputs), + ); // create a new cache if required const cache: Cache = useCache diff --git a/test/no-input.spec.js b/test/no-input.spec.js index a943567..604c222 100644 --- a/test/no-input.spec.js +++ b/test/no-input.spec.js @@ -78,10 +78,12 @@ it('should start memoizing if inputs are provided', () => { it('should only call get result once on first pass', () => { const getResult = jest.fn().mockReturnValue({ hello: 'friend' }); - const wrapper = mount( - {() => null}, + mount( + + {() => null} + , ); // initial call expect(getResult).toHaveBeenCalledTimes(1); -}) +});