Skip to content

Commit a38a396

Browse files
committed
Add test to reproduce issue #19
1 parent 1f6c6cf commit a38a396

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/unit/test_reducer.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import assert from 'power-assert';
2+
import sinon from 'sinon';
3+
import reducer from '../../src/reducer';
4+
import * as actions from '../../src/actions';
5+
6+
describe('reducer', () => {
7+
let warn;
8+
beforeEach(() => {
9+
warn = sinon.spy(console, 'warn');
10+
});
11+
12+
afterEach(() => {
13+
console.warn.restore();
14+
});
15+
16+
it("warns with 'el' prop", () => {
17+
reducer(undefined, actions.show({ el: 'abc' }));
18+
assert(warn.calledOnce);
19+
assert(warn.firstCall.args[0] === "DEPRECATED: Use 'origin' instead of 'el' in props for Tooltip component or 'show' action.");
20+
});
21+
22+
it("doesn't warn with 'origin' prop", () => {
23+
reducer(undefined, actions.show({ origin: 'abc' }));
24+
assert(warn.callCount === 0);
25+
});
26+
27+
it("ignores non-related actions which contains 'el' prop in payload", () => {
28+
reducer(undefined, { type: 'NON_RELATED_ACTION', payload: { el: 'abc' } });
29+
assert(warn.callCount === 0);
30+
});
31+
});

0 commit comments

Comments
 (0)