Skip to content

Commit

Permalink
chore: update all devDeps (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker authored Jan 3, 2024
1 parent 09eb571 commit f84df6e
Show file tree
Hide file tree
Showing 11 changed files with 16,129 additions and 14,321 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10.x', '12.x', '14.x' ]
node: [ '18.x', '20.x' ]
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20
- name: Install dependencies
run: npm ci
- name: Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10.x', '12.x', '14.x' ]
node: [ '18.x', '20.x' ]
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
4 changes: 2 additions & 2 deletions __tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`redux-lifesaver actionThrottled returns the expected action shape 1`] = `
Object {
"action": Object {
{
"action": {
"type": "SOME_ACTION",
},
"type": "@@lifesaver/ACTION_THROTTLED",
Expand Down
28 changes: 12 additions & 16 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import createLifesaverMiddleware, {
actionThrottled,
} from '../src';

jest.useFakeTimers();
jest.useFakeTimers({ legacyFakeTimers: true });

describe('redux-lifesaver', () => {
let dn;
let cw;
let lifesaver;
let middle;
let now = 0;
Expand All @@ -30,29 +29,26 @@ describe('redux-lifesaver', () => {

const action = { type: 'TEST_ACTION' };

const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});

beforeAll(() => {
dn = Date.now;
cw = console.warn;
Date.now = jest.fn(() => {
now += 1;
return now;
});
console.warn = jest.fn();
});

beforeEach(() => {
jest.clearAllTimers();
setTimeout.mockClear();
dispatch.mockClear();
next.mockClear();
jest.clearAllMocks();
now = 0;
lifesaver = createLifesaverMiddleware();
middle = lifesaver({ dispatch })(next);
});

afterAll(() => {
Date.now = dn;
console.warn = cw;
});

describe('actionThrottled', () => {
Expand Down Expand Up @@ -107,8 +103,8 @@ describe('redux-lifesaver', () => {
middle(action);
i += 1;
}
expect(console.warn).toHaveBeenCalled();
expect(console.warn.mock.calls[0][0]).toMatchSnapshot();
expect(consoleWarnSpy).toHaveBeenCalled();
expect(consoleWarnSpy.mock.calls[0][0]).toMatchSnapshot();
});

it('sets a timeout to dispatch the action if the dispatch limit is exceeded within the configured limit duration', () => {
Expand All @@ -120,7 +116,7 @@ describe('redux-lifesaver', () => {
expect(dispatch).toHaveBeenCalledTimes(1);
expect(dispatch).toHaveBeenCalledWith(actionThrottled(action));
expect(setTimeout).toHaveBeenCalledTimes(1);
jest.runTimersToTime(100);
jest.advanceTimersByTime(100);
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenLastCalledWith(action);
});
Expand All @@ -136,9 +132,9 @@ describe('redux-lifesaver', () => {
expect(dispatch).toHaveBeenCalledTimes(1);
expect(dispatch).toHaveBeenCalledWith(actionThrottled(action));
expect(setTimeout).toHaveBeenCalledTimes(1);
jest.runTimersToTime(100);
jest.advanceTimersByTime(100);
expect(dispatch).toHaveBeenCalledTimes(1);
jest.runTimersToTime(200);
jest.advanceTimersByTime(200);
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenLastCalledWith(action);
});
Expand All @@ -161,9 +157,9 @@ describe('redux-lifesaver', () => {
expect(dispatch).toHaveBeenCalledTimes(1);
expect(dispatch).toHaveBeenCalledWith(actionThrottled(specialAction));
expect(setTimeout).toHaveBeenCalledTimes(1);
jest.runTimersToTime(100);
jest.advanceTimersByTime(100);
expect(dispatch).toHaveBeenCalledTimes(1);
jest.runTimersToTime(200);
jest.advanceTimersByTime(200);
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenLastCalledWith(specialAction);
});
Expand Down Expand Up @@ -255,7 +251,7 @@ describe('redux-lifesaver', () => {

it('allows the user to configure an action creator for lifesaver to use', () => {
const date = Date.now();
const actionCreator = jest.fn(throttledAction => ({
const actionCreator = jest.fn((throttledAction) => ({
type: ACTION_THROTTLED,
other: 'data',
throttledAction,
Expand Down
Loading

0 comments on commit f84df6e

Please sign in to comment.