Skip to content

Commit fa09c66

Browse files
committed
fix more lint issues
1 parent a1b6fc2 commit fa09c66

1 file changed

Lines changed: 90 additions & 90 deletions

File tree

test/provider.js

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -92,101 +92,101 @@ describe('preact-redux', () => {
9292
});
9393
});
9494

95-
describe('connectAdvanced()', () => {
96-
it('should connectAdvanced component to store', () => {
97-
let initialState = {
98-
a: 'a',
99-
b: 'b'
100-
};
101-
102-
let reducer = (state=initialState, action) => {
103-
switch (action.type) {
104-
case 'A': return { ...state, a: action.data };
105-
case 'B': return { ...state, b: action.data };
106-
default: return state;
107-
}
108-
};
109-
110-
let store = createStore(reducer);
111-
let Child = sinon.stub().returns(<div />);
112-
113-
let spies = {};
114-
115-
function shallowDiffers (a, b) {
116-
for (let i in a) if (!(i in b)) return true;
117-
for (let i in b) if (a[i] !== b[i]) return true;
118-
return false;
119-
}
120-
121-
let ConnectedChild = connectAdvanced((dispatch) => {
122-
/**
123-
* from https://github.com/reactjs/react-redux/blob/master/docs/api.md
124-
* If a consecutive call to selector returns the same object (===) as its previous call,
125-
* the component will not be re-rendered.
126-
* It's the responsibility of selector to return that previous object when appropriate.
127-
*/
128-
let result = {};
129-
const onA = spies.onA = sinon.spy(data => dispatch({type: 'A', data}));
130-
const onB = spies.onB = sinon.spy(data => dispatch({type: 'B', data}));
131-
132-
return ({a, b}, {c}) => {
133-
const nextResult = {
134-
a,
135-
b,
136-
c,
137-
onA,
138-
onB
139-
};
140-
141-
if (shallowDiffers(result, nextResult)) {
142-
result = nextResult;
143-
}
144-
return result;
145-
};
146-
})(Child);
147-
148-
render((
95+
describe('connectAdvanced()', () => {
96+
it('should connectAdvanced component to store', () => {
97+
let initialState = {
98+
a: 'a',
99+
b: 'b'
100+
};
101+
102+
let reducer = (state=initialState, action) => {
103+
switch (action.type) {
104+
case 'A': return { ...state, a: action.data };
105+
case 'B': return { ...state, b: action.data };
106+
default: return state;
107+
}
108+
};
109+
110+
let store = createStore(reducer);
111+
let Child = sinon.stub().returns(<div />);
112+
113+
let spies = {};
114+
115+
function shallowDiffers (a, b) {
116+
for (let i in a) if (!(i in b)) return true;
117+
for (let i in b) if (a[i] !== b[i]) return true;
118+
return false;
119+
}
120+
121+
let ConnectedChild = connectAdvanced((dispatch) => {
122+
/**
123+
* from https://github.com/reactjs/react-redux/blob/master/docs/api.md
124+
* If a consecutive call to selector returns the same object (===) as its previous call,
125+
* the component will not be re-rendered.
126+
* It's the responsibility of selector to return that previous object when appropriate.
127+
*/
128+
let result = {};
129+
const onA = spies.onA = sinon.spy(data => dispatch({type: 'A', data}));
130+
const onB = spies.onB = sinon.spy(data => dispatch({type: 'B', data}));
131+
132+
return ({a, b}, {c}) => {
133+
const nextResult = {
134+
a,
135+
b,
136+
c,
137+
onA,
138+
onB
139+
};
140+
141+
if (shallowDiffers(result, nextResult)) {
142+
result = nextResult;
143+
}
144+
return result;
145+
};
146+
})(Child);
147+
148+
render((
149149
<Provider store={store}>
150150
<ConnectedChild c="c" />
151151
</Provider>
152-
), document.createElement('div'));
153-
154-
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
155-
a: 'a',
156-
b: 'b',
157-
c: 'c',
158-
onA: spies.onA,
159-
onB: spies.onB
160-
});
161-
162-
Child.reset();
163-
spies.onA('aaa');
164-
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
165-
a: 'aaa',
166-
b: 'b',
167-
c: 'c',
168-
onA: spies.onA,
169-
onB: spies.onB
170-
});
171-
172-
Child.reset();
173-
spies.onB('bbb');
174-
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
175-
a: 'aaa',
176-
b: 'bbb',
177-
c: 'c',
178-
onA: spies.onA,
179-
onB: spies.onB
180-
});
181-
});
182-
});
152+
), document.createElement('div'));
153+
154+
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
155+
a: 'a',
156+
b: 'b',
157+
c: 'c',
158+
onA: spies.onA,
159+
onB: spies.onB
160+
});
161+
162+
Child.reset();
163+
spies.onA('aaa');
164+
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
165+
a: 'aaa',
166+
b: 'b',
167+
c: 'c',
168+
onA: spies.onA,
169+
onB: spies.onB
170+
});
171+
172+
Child.reset();
173+
spies.onB('bbb');
174+
expect(Child).to.have.been.calledOnce.and.calledWithMatch({
175+
a: 'aaa',
176+
b: 'bbb',
177+
c: 'c',
178+
onA: spies.onA,
179+
onB: spies.onB
180+
});
181+
});
182+
});
183183

184184
describe('jsnext:main', () => {
185-
it('should export the correct interface', () => {
186-
expect(Redux.Provider).to.be.a('function');
187-
expect(Redux.connect).to.be.a('function');
188-
expect(Redux.connectAdvanced).to.be.a('function');
189-
});
185+
it('should export the correct interface', () => {
186+
expect(Redux.Provider).to.be.a('function');
187+
expect(Redux.connect).to.be.a('function');
188+
expect(Redux.connectAdvanced).to.be.a('function');
189+
});
190190
});
191191
});
192192

0 commit comments

Comments
 (0)