Skip to content

Commit

Permalink
chore: remove global listener
Browse files Browse the repository at this point in the history
  • Loading branch information
orzyyyy committed Apr 12, 2019
1 parent 6181603 commit 2b7ae5a
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 36 deletions.
9 changes: 0 additions & 9 deletions src/canvas/__tests__/Canvas.test.tsx
Expand Up @@ -9,7 +9,6 @@ switch (process.env.LIB_DIR) {
Canvas = require('..').default;
break;
}
import Listener from '../../utils/GlobalListener';
import { mapping } from '../../mock/mapping';
import 'nino-cli/scripts/setup';

Expand All @@ -18,14 +17,6 @@ const createWrapper = (...props: Array<any>) => {
};

describe('Canvas', () => {
beforeEach(() => {
(window as any).DataCollector = new Listener();
});

afterEach(() => {
(window as any).DataCollector = null;
});

it('Canvas renders correctly', () => {
const wrapper = createWrapper();
wrapper.setProps({ data: mapping });
Expand Down
1 change: 0 additions & 1 deletion src/canvas/core.tsx
Expand Up @@ -158,7 +158,6 @@ export default class Canvas extends Component<CanvasProps, CanvasState> {
} = this.props;
const { blockProps, linesProps, tagProps, position } = this.state;

(window as any).DataCollector.set('CanvasPosition', position);
return (
<Draggable
onDrag={this.handleDrag}
Expand Down
3 changes: 0 additions & 3 deletions src/canvas/index.tsx
@@ -1,7 +1,4 @@
// rename Canvas to core because circleci is case-sensitive
import Canvas from './core';
import Listener from '../utils/GlobalListener';

(window as any).DataCollector = new Listener();

export default Canvas;
1 change: 0 additions & 1 deletion src/tools/BlockGroup.tsx
Expand Up @@ -222,7 +222,6 @@ export default class BlockGroup extends Component<
const { className: parentClassName, onChange, ...rest } = this.props;
const { data } = this.state;

(window as any).DataCollector.set('BlockGroup', data);
return Object.keys(data).map(blockKey => {
const { x, y, className: blockClassName } = data[blockKey];
return (
Expand Down
3 changes: 0 additions & 3 deletions src/tools/LineGroup.tsx
Expand Up @@ -48,9 +48,6 @@ export default class LineGroup extends Component<
const { offset, ...rest } = this.props;
return Object.keys(data).map(lineKey => {
const { from, to } = data[lineKey];
(window as any).DataCollector.set('LineGroup', {
[lineKey]: data[lineKey],
});
return (
<SteppedLineTo
from={from}
Expand Down
1 change: 0 additions & 1 deletion src/tools/TagGroup.tsx
Expand Up @@ -68,7 +68,6 @@ export default class TagGroup extends Component<TagGroupProps, TagGroupState> {
const { className: parentClassName, onChange, ...rest } = this.props;
const { data } = this.state;

(window as any).DataCollector.set('TagGroup', data);
return Object.keys(data).map(key => {
const { x, y, editable, className: tagClassName } = data[key];
const targetClassName = classNames(
Expand Down
9 changes: 0 additions & 9 deletions src/tools/__tests__/BlockGroup.test.tsx
Expand Up @@ -9,18 +9,9 @@ switch (process.env.LIB_DIR) {
BlockGroup = require('../BlockGroup').default;
break;
}
import Listener from '../../utils/GlobalListener';
import 'nino-cli/scripts/setup';

describe('BlockGroup', () => {
beforeEach(() => {
(window as any).DataCollector = new Listener();
});

afterEach(() => {
(window as any).DataCollector = null;
});

it("when lineData is null, onChange shouldn't be called", () => {
const onChange = jest.fn();
mount(
Expand Down
9 changes: 0 additions & 9 deletions src/tools/__tests__/TagGroup.test.tsx
Expand Up @@ -9,18 +9,9 @@ switch (process.env.LIB_DIR) {
TagGroup = require('..').TagGroup;
break;
}
import Listener from '../../utils/GlobalListener';
import 'nino-cli/scripts/setup';

describe('TagGroup', () => {
beforeEach(() => {
(window as any).DataCollector = new Listener();
});

afterEach(() => {
(window as any).DataCollector = null;
});

it('when data is null, render correctly', () => {
const wrapper = mount(<TagGroup />);
expect(wrapper).toMatchSnapshot();
Expand Down

0 comments on commit 2b7ae5a

Please sign in to comment.