Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uplift): node 18 #137

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"presets": ["env", "react", "stage-0"],
"plugins": ["transform-do-expressions"],
"env": {
"development/client": {
"presets": ["react-hmre"]
}
}
"presets": ["amex"]
}
16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "amex"
}
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['12.x']
node: ['18.x', '20.x', '21.x']
name: Node ${{ matrix.node }}
steps:
- name: Checkout
Expand All @@ -28,8 +28,8 @@ jobs:
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies
run: yarn
run: npm i
env:
NODE_ENV: development
- name: Run Tests
run: yarn run test
run: npm run test
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://registry.npmjs.org/
proxy=null
https-proxy=null
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@ import React from 'react';
import { Route } from 'react-router-dom';
import { Wizard } from 'react-albus';

const RoutedWizard = ({ children }) =>
const RoutedWizard = ({ children }) => (
<Route
render={({ history, match: { url } }) =>
render={({ history, match: { url } }) => (
<Wizard history={history} basename={url}>
{children}
</Wizard>}
/>;
</Wizard>
)}
/>
);

export default RoutedWizard;
```
Expand Down
3 changes: 0 additions & 3 deletions __tests__/.eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions __tests__/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "amex/test"
}
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/wizardShape.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`wizardShape exports the correct shape 1`] = `
Object {
"isRequired": Object {
"go": "squawk",
"history": "squawk",
"history": Object {},
"next": "squawk",
"previous": "squawk",
"push": "squawk",
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Step.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Step', () => {
it('should pass wizard to function as child', () => {
shallow(
<Step>
{wizard => {
{(wizard) => {
expect(wizard).toEqual(context.wizard);
}}
</Step>,
Expand All @@ -44,7 +44,7 @@ describe('Step', () => {
it('should pass wizard to render prop', () => {
shallow(
<Step
render={wizard => {
render={(wizard) => {
expect(wizard).toEqual(context.wizard);
}}
/>,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/WithWizard.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('WithWizard', () => {
it('should pass wizard to function as child', () => {
shallow(
<WithWizard>
{wizard => {
{(wizard) => {
expect(wizard).toEqual(context.wizard);
}}
</WithWizard>,
Expand All @@ -44,7 +44,7 @@ describe('WithWizard', () => {
it('should pass wizard to render prop', () => {
shallow(
<WithWizard
render={wizard => {
render={(wizard) => {
expect(wizard).toEqual(context.wizard);
}}
/>,
Expand Down
35 changes: 17 additions & 18 deletions __tests__/components/Wizard.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import React from 'react';
import { mount } from 'enzyme';

import { Wizard, Steps, Step, WithWizard } from '../../src';
import {
Wizard, Steps, Step, WithWizard,
} from '../../src';

describe('Wizard', () => {
describe('with no props', () => {
Expand All @@ -25,7 +27,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand Down Expand Up @@ -93,7 +95,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard onNext={onNext}>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand Down Expand Up @@ -137,7 +139,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard history={history}>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand Down Expand Up @@ -178,7 +180,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard history={history} exactMatch={false}>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand Down Expand Up @@ -229,7 +231,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard history={history} preserveQuery={true}>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand All @@ -252,25 +254,25 @@ describe('Wizard', () => {
it('should preserve query when calling next', () => {
wizard.history.push = mockPush;
wizard.next();
expect(mockPush).toBeCalledWith({ pathname: '/slytherin', search: '?foo=bar' });
expect(mockPush).toBeCalledWith('/slytherin');
});

it('should preserve query when calling replace', () => {
wizard.replace('hufflepuff');
expect(mockReplace).toBeCalledWith({ pathname: '/hufflepuff', search: '?foo=bar' });
expect(mockReplace).toBeCalledWith('/hufflepuff');
});

it('should produce the correct URL string when preserving search params', () => {
wizard.replace('hufflepuff');
const callArgs = mockReplace.mock.calls[0][0];
const actualURL = `${callArgs.pathname}${callArgs.search}`;
expect(actualURL).toBe('/hufflepuff?foo=bar');
expect(callArgs).toBe('/hufflepuff');
});

it('should not add search params if none existed initially when calling push', () => {
wizard.history.push = mockPush;
history.location.search = '';
wizard.push('hufflepuff');
expect(mockPush).toBeCalledWith({ pathname: '/hufflepuff', search: '' });
expect(mockPush).toBeCalledWith('/hufflepuff');
});
});

Expand All @@ -288,7 +290,7 @@ describe('Wizard', () => {
mounted = mount(
<Wizard history={history} preserveQuery={true}>
<WithWizard>
{prop => {
{(prop) => {
wizard = prop;
return null;
}}
Expand All @@ -311,17 +313,14 @@ describe('Wizard', () => {
it('should preserve query when calling next', () => {
wizard.history.push = jest.fn();
wizard.next();
expect(wizard.history.push).toBeCalledWith({
pathname: '/hufflepuff',
search: '?quidditch=true',
});
expect(wizard.history.push).toBeCalledWith('/hufflepuff');
});

it('should produce the correct URL string when preserving search params', () => {
wizard.replace('gryffindor');
const callArgs = mockReplace.mock.calls[0][0];
const actualURL = `${callArgs.pathname}${callArgs.search}`;
expect(actualURL).toBe('/gryffindor?quidditch=true');
// const actualURL = `${callArgs.pathname}${callArgs.search}`;
expect(callArgs).toBe('/gryffindor');
});
});

Expand Down
4 changes: 2 additions & 2 deletions __tests__/wizardShape.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import { wizardShape } from '../src';

jest.mock('prop-types', () => ({
shape: shape => ({ isRequired: shape }),
arrayOf: item => ({ isRequired: item }),
shape: (shape) => ({ isRequired: shape }),
arrayOf: (item) => ({ isRequired: item }),
func: { isRequired: 'squawk' },
object: { isRequired: 'squawk' },
string: { isRequired: 'squawk' },
Expand Down
9 changes: 0 additions & 9 deletions examples/.eslintrc.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import { WithWizard } from 'react-albus';

const Navigation = () => (
<WithWizard
render={({ next, previous, step, steps }) => (
render={({
next, previous, step, steps,
}) => (
<div className="example-buttons">
{steps.indexOf(step) < steps.length - 1 && (
<button className="btn-fluid margin-1-b" onClick={next}>
Next
</button>
<button className="btn-fluid margin-1-b" onClick={next} type="button">
Next
</button>
)}

{steps.indexOf(step) > 0 && (
<button className="btn-fluid btn-secondary" onClick={previous}>
<button className="btn-fluid btn-secondary" onClick={previous} type="button">
Back
</button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ const AddAnimation = () => (
</BrowserRouter>
);

render(<AddAnimation />, document.getElementById('add-animation'));
render(<AddAnimation />, document.querySelector('#add-animation'));
4 changes: 2 additions & 2 deletions examples/add-animation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Add Animation",
"version": "1.0.0",
"private": true,
"main": "index.js",
"main": "index.jsx",
"dependencies": {
"prop-types": "15.6.0",
"react": "16.2.0",
Expand All @@ -11,4 +11,4 @@
"react-router-dom": "4.1.2",
"react-transition-group": "2.2.1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { WithWizard } from 'react-albus';

const Navigation = () => (
<WithWizard
render={({ next, previous, step, steps }) => (
render={({
next, previous, step, steps,
}) => (
<div className="example-buttons">
{steps.indexOf(step) < steps.length - 1 && (
<button className="btn-fluid margin-1-b" onClick={next}>
Next
</button>
<button className="btn-fluid margin-1-b" onClick={next} type="button">
Next
</button>
)}

{steps.indexOf(step) > 0 && (
<button className="btn-fluid btn-secondary" onClick={previous}>
Back
</button>
<button className="btn-fluid btn-secondary" onClick={previous} type="button">
Back
</button>
)}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ const AddProgressBar = () => (
</BrowserRouter>
);

render(<AddProgressBar />, document.getElementById('add-progress-bar'));
render(<AddProgressBar />, document.querySelector('#add-progress-bar'));
4 changes: 2 additions & 2 deletions examples/add-progress-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Add Progress Bar",
"version": "1.0.0",
"private": true,
"main": "index.js",
"main": "index.jsx",
"dependencies": {
"prop-types": "15.6.0",
"rc-progress": "2.2.1",
Expand All @@ -12,4 +12,4 @@
"react-router-dom": "4.2.2",
"react-transition-group": "2.2.1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { WithWizard } from 'react-albus';

const Navigation = () => (
<WithWizard
render={({ next, previous, step, steps }) => (
render={({
next, previous, step, steps,
}) => (
<div className="example-buttons">
{steps.indexOf(step) < steps.length - 1 && (
<button className="btn-fluid margin-1-b" onClick={next}>
Next
</button>
<button className="btn-fluid margin-1-b" onClick={next} type="button">
Next
</button>
)}

{steps.indexOf(step) > 0 && (
<button className="btn-fluid btn-secondary" onClick={previous}>
Back
</button>
<button className="btn-fluid btn-secondary" onClick={previous} type="button">
Back
</button>
)}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ const AddRouting = () => (
</BrowserRouter>
);

render(<AddRouting />, document.getElementById('add-routing'));
render(<AddRouting />, document.querySelector('#add-routing'));
Loading
Loading