Skip to content

Commit daded86

Browse files
committed
Add first factory
1 parent aff0524 commit daded86

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Factory} from 'rosie';
2+
3+
export const position = new Factory().attrs({
4+
line: 0,
5+
ch: 0,
6+
});
7+
8+
export const change = new Factory().
9+
attr('from', () => position.build()).
10+
attr('to', () => position.build()).
11+
attrs({
12+
text: 'c',
13+
removed: '',
14+
origin: '+input',
15+
});

src/components/__tests__/CodeMirrorEditor.test.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import React from 'react';
55
import ShallowRenderer from 'react-test-renderer/shallow';
66
import TestRenderer, {act} from 'react-test-renderer';
77

8+
// eslint-disable-next-line import/no-extraneous-dependencies
9+
import {change as changeFactory} from '@factories/packages/codemirror';
10+
811
import CodeMirrorEditor from '../CodeMirrorEditor';
912

1013
const DEFAULT_PROPS = {
@@ -121,11 +124,11 @@ describe('codemirror editor', () => {
121124
const newSource =
122125
DEFAULT_PROPS.source.replace('<html>', '<html>d');
123126
editor.getValue.mockReturnValueOnce(newSource);
124-
handleChanges(null, [{origin: '+input'}]);
127+
handleChanges(null, [changeFactory.build({origin: '+input'})]);
125128
expect(DEFAULT_PROPS.onInput).toHaveBeenLastCalledWith(newSource);
126129

127130
DEFAULT_PROPS.onInput.mockClear();
128-
handleChanges(null, [{origin: 'setValue'}]);
131+
handleChanges(null, [changeFactory.build({origin: 'setValue'})]);
129132
expect(DEFAULT_PROPS.onInput).not.toHaveBeenCalled();
130133
});
131134
});

0 commit comments

Comments
 (0)