Skip to content

Commit

Permalink
Merge pull request #67 from shipt/development
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
chaceburnette authored Jul 7, 2021
2 parents fc3f82c + 042c9b0 commit ff817c9
Show file tree
Hide file tree
Showing 19 changed files with 1,401 additions and 1,232 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/sast.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
# This workflow is to automate Checkmarx SAST scans. It runs on a push to the main branch.
#
# The following GitHub Secrets must be first defined:
# - CHECKMARX_URL
# - CHECKMARX_USER
# - CHECKMARX_PASSWORD
# - CHECKMARX_CLIENT_SECRET
#
# The following variables must be inserted below:
# - <ProjectName>
#
# Update the 'team' field to reflect the team name used in Checkmarx.
#
# For full documentation, including a list of all inputs, please refer to the README https://github.com/checkmarx-ts/checkmarx-cxflow-github-action

name: Checkmarx SAST Scan
on:
pull_request:
branches:
- main
- master
- development
push:
branches:
- master
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v1.1.1

* Minor dependency updates

## v1.1.0

* Removed deprecated class based container logic
Expand Down
24 changes: 21 additions & 3 deletions examples/counter-react/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import Osmosis from '@shipt/osmosis';
import { wrapCounter } from './store';
import { StoreProvider, configureUsePersistedState } from '@shipt/osmosis';
import { CounterWrapper, CounterWithReducerWrapper } from './store';

import Counter from './counter';
import PersistedCounter from './persistedCounter.js';
import DispactCounter from './dispatchCounter.js';

configureUsePersistedState({
getItem: key => JSON.parse(window.localStorage.getItem(key)),
setItem: (key, value) => window.localStorage.setItem(key, JSON.stringify(value))
});

const App = () => {
return (
<>
<Counter />
<PersistedCounter />
<DispactCounter />
</>
);
};

export default Osmosis.StoreProvider([wrapCounter], Counter);
export default StoreProvider([CounterWrapper, CounterWithReducerWrapper], App);
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ exports[`Counter renders default 1`] = `
data-testid="counter-wrap"
>
<p>
Count:
0
</p>
<button
data-testid="increment"
data-testid="decrement"
>
+
-
</button>
<button
data-testid="decrement"
data-testid="increment"
>
-
+
</button>
</div>
`;
8 changes: 4 additions & 4 deletions examples/counter-react/src/__tests__/counter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe('Counter', () => {
state: {
count: 0
},
increment: jest.fn(),
decrement: jest.fn()
incrementCount: jest.fn(),
decrementCount: jest.fn()
};
let ContextComponent = () => (
<CounterContext.Provider value={[CounterStore]}>
Expand All @@ -23,11 +23,11 @@ describe('Counter', () => {
it('tests increment button', async () => {
let wrapper = await render(<ContextComponent />);
fireEvent.click(wrapper.getByTestId('increment'));
expect(CounterStore.increment).toHaveBeenCalled();
expect(CounterStore.incrementCount).toHaveBeenCalled();
});
it('tests decrement button', async () => {
let wrapper = await render(<ContextComponent />);
fireEvent.click(wrapper.getByTestId('decrement'));
expect(CounterStore.decrement).toHaveBeenCalled();
expect(CounterStore.decrementCount).toHaveBeenCalled();
});
});
10 changes: 5 additions & 5 deletions examples/counter-react/src/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const Counter = () => {

return (
<div data-testid="counter-wrap">
<p>{count}</p>
<button data-testid="increment" onClick={counterContext.increment}>
+
</button>
<button data-testid="decrement" onClick={counterContext.decrement}>
<p>Count: {count}</p>
<button data-testid="decrement" onClick={counterContext.decrementCount}>
-
</button>
<button data-testid="increment" onClick={counterContext.incrementCount}>
+
</button>
</div>
);
};
Expand Down
21 changes: 21 additions & 0 deletions examples/counter-react/src/dispatchCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useContext } from 'react';
import { CounterWithReducerContext } from './store';

const PersistedCounter = () => {
const [counterContext] = useContext(CounterWithReducerContext);
let { dispatch, counterState: { count }} = counterContext;

return (
<div data-testid="counter-wrap">
<p>Dispatch Count: {count}</p>
<button data-testid="decrement" onClick={() => dispatch({type: 'decrement'})}>
-
</button>
<button data-testid="increment" onClick={() => dispatch({type: 'increment'})}>
+
</button>
</div>
);
};

export default PersistedCounter;
5 changes: 0 additions & 5 deletions examples/counter-react/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
<React.StrictMode>
Expand All @@ -10,7 +9,3 @@ ReactDOM.render(
document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
21 changes: 21 additions & 0 deletions examples/counter-react/src/persistedCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useContext } from 'react';
import { CounterContext } from './store';

const PersistedCounter = () => {
const [counterContext] = useContext(CounterContext);
let { persistedCount } = counterContext.state;

return (
<div data-testid="counter-wrap">
<p>Persisted Count: {persistedCount}</p>
<button data-testid="decrement" onClick={counterContext.decrementPersistedCount}>
-
</button>
<button data-testid="increment" onClick={counterContext.incrementPersistedCount}>
+
</button>
</div>
);
};

export default PersistedCounter;
141 changes: 0 additions & 141 deletions examples/counter-react/src/serviceWorker.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/counter-react/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
import 'regenerator-runtime/runtime';

import { configureUsePersistedState } from '@shipt/osmosis';
configureUsePersistedState({
getItem: ()=> {},
setItem: () => {}
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useContext } from 'react';
import { CounterContext, wrapCounter } from '../counter.store';
import { CounterContext, CounterWrapper} from '../counter.store';
import { render } from '@testing-library/react';
import { act } from 'react-dom/test-utils';

describe('CounterStore', () => {
let store;
const renderStore = () => {
let Prep = wrapCounter(() => {
let Prep = CounterWrapper(() => {
store = useContext(CounterContext)[0];
return null;
});
Expand All @@ -19,7 +19,7 @@ describe('CounterStore', () => {
});
expect(store.state.count).toEqual(0);
act(() => {
store.increment();
store.incrementCount();
});
expect(store.state.count).toEqual(1);
});
Expand All @@ -30,7 +30,7 @@ describe('CounterStore', () => {
});
expect(store.state.count).toEqual(0);
act(() => {
store.decrement();
store.decrementCount();
});
expect(store.state.count).toEqual(-1);
});
Expand Down
Loading

0 comments on commit ff817c9

Please sign in to comment.