Skip to content

Commit aa8a135

Browse files
(fix) fixing unit tests broken by beta 3
1 parent 655ae11 commit aa8a135

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

tests/Editor-test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import expect from 'expect';
2-
import React from 'react'
2+
import React from 'react';
33
import Enzyme, { mount, shallow } from 'enzyme';
44
import Adapter from 'enzyme-adapter-react-16';
55
import Editor from '../src/components/Editor';
@@ -8,41 +8,41 @@ Enzyme.configure({ adapter: new Adapter() });
88

99
describe('Editor component', () => {
1010
it ('should initialize with a schema', () => {
11-
const wraper = mount(<Editor position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />)
12-
expect(wraper.state().jsonSchema).toEqual({type: 'string'})
13-
})
11+
const wraper = mount(<Editor input={document.createElement('input')} position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />);
12+
expect(wraper.state().jsonSchema).toEqual({type: 'string'});
13+
});
1414

1515
it ('should set json state', () => {
16-
const wraper = mount(<Editor position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />)
16+
const wraper = mount(<Editor input={document.createElement('input')} position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />);
1717
wraper.setProps({json: {test: 'a'}});
1818
expect(wraper.state().jsonToFilter).toEqual({test: 'a'});
19-
})
19+
});
2020

2121
it ('should set json schema', () => {
22-
const wraper = mount(<Editor position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />)
22+
const wraper = mount(<Editor input={document.createElement('input')} position={{x: 0, y:0}} jsonSchema={{type: 'string'}} />);
2323
wraper.setProps({jsonSchema: {type: 'number'}});
2424
expect(wraper.state().jsonSchema).toEqual({type: 'number'});
25-
})
25+
});
2626

2727

2828
it ('should set json when updated in editor', () => {
29-
const wraper = mount(<Editor position={{x: 0, y:0}} json={{type: 'string'}} />)
29+
const wraper = mount(<Editor input={document.createElement('input')} position={{x: 0, y:0}} json={{type: 'string'}} />);
3030
wraper.instance().jsonEditor.set({test: 'a'});
3131
wraper.instance().onJsonChange();
3232
expect(wraper.state().jsonToFilter).toEqual({test: 'a'});
33-
})
33+
});
3434

3535
it ('should dispatch selected suggestion', () => {
3636
const spy = expect.createSpy();
37-
const wraper = mount(<Editor input={document.createElement('input')} onJsonPathChanged={spy} jsonpath='abc' position={{x: 0, y:0}} json={{type: 'string'}} />)
37+
const wraper = mount(<Editor input={document.createElement('input')} onJsonPathChanged={spy} jsonpath='abc' position={{x: 0, y:0}} json={{type: 'string'}} />);
3838
wraper.instance().onSelectSuggestion({value: 'test', description: 'test'});
3939
expect(spy).toHaveBeenCalledWith('test');
40-
})
40+
});
4141

4242
it ('should dispatch selected suggestion when suggestion has setCarretAt', () => {
4343
const spy = expect.createSpy();
44-
const wraper = mount(<Editor input={document.createElement('input')} onJsonPathChanged={spy} jsonpath='abc' position={{x: 0, y:0}} json={{type: 'string'}} />)
44+
const wraper = mount(<Editor input={document.createElement('input')} onJsonPathChanged={spy} jsonpath='abc' position={{x: 0, y:0}} json={{type: 'string'}} />);
4545
wraper.instance().onSelectSuggestion({value: 'test', description: 'test', setCarretAt: 1});
4646
expect(spy).toHaveBeenCalledWith('test');
47-
})
47+
});
4848
});

tests/SuggestionBuilder-test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import expect from 'expect';
2-
import { getSuggestion, evalAllProperties } from '../src/components/suggestionBuilder';
2+
import { getSuggestions, evalAllProperties } from '../src/components/suggestionBuilder';
33

44

55
describe('get suggestion', () => {
66
it('should lists . suggestions', () => {
77
// Given
88
// When
9-
const suggestion = getSuggestion('$.', 2, { test: 0 });
9+
const suggestion = getSuggestions('$.', 2, { test: 0 });
1010
// Then
1111
expect(suggestion).toEqual([
1212
{ value: 'test', description: 'property', scopes: ['object'] },
@@ -15,25 +15,25 @@ describe('get suggestion', () => {
1515
value: '*',
1616
scopes: ['[]', '.']
1717
}
18-
])
19-
})
18+
]);
19+
});
2020

2121
it('should lists .. suggestions', () => {
2222
// Given
2323
// When
24-
const suggestion = getSuggestion('$..', 2, { test: 0, test2: [{test3: 1}] });
24+
const suggestion = getSuggestions('$..', 2, { test: 0, test2: [{test3: 1}] });
2525
// Then
2626
expect(suggestion).toEqual([
2727
{ value: 'test', description: 'property', scopes: ['object'] },
2828
{ value: 'test2', description: 'property', scopes: ['object'] },
2929
{ value: 'test3', description: 'property', scopes: ['object'] }
30-
])
31-
})
30+
]);
31+
});
3232

3333
it('should lists object suggestions', () => {
3434
// Given
3535
// When
36-
const suggestion = getSuggestion('$', 2, { test: 0 });
36+
const suggestion = getSuggestions('$', 2, { test: 0 });
3737
// Then
3838
expect(suggestion).toEqual([
3939
{
@@ -57,13 +57,13 @@ describe('get suggestion', () => {
5757
value: '.*',
5858
scopes: ['array', 'object']
5959
},
60-
])
61-
})
60+
]);
61+
});
6262

6363
it('should lists array suggestions', () => {
6464
// Given
6565
// When
66-
const suggestion = getSuggestion('$', 2, [0, 1]);
66+
const suggestion = getSuggestions('$', 2, [0, 1]);
6767
// Then
6868
expect(suggestion).toEqual([
6969
{
@@ -102,13 +102,13 @@ describe('get suggestion', () => {
102102
value: '.*',
103103
scopes: ['array', 'object']
104104
},
105-
])
106-
})
105+
]);
106+
});
107107

108108
it('should lists pick suggestions', () => {
109109
// Given
110110
// When
111-
const suggestion = getSuggestion('$.test[]', 6, { test: [0, 1] });
111+
const suggestion = getSuggestions('$.test[]', 7, { test: [0, 1] });
112112
// Then
113113
expect(suggestion).toEqual([
114114
{
@@ -139,31 +139,31 @@ describe('get suggestion', () => {
139139
value: '*',
140140
scopes: ['[]', '.']
141141
}
142-
])
143-
})
142+
]);
143+
});
144144

145145
it('should not lists pick suggestions', () => {
146146
// Given
147147
// When
148-
const suggestion = getSuggestion('$.test[]', 7, { test: [0, 1] });
148+
const suggestion = getSuggestions('$.test[]', 8, { test: [0, 1] });
149149
// Then
150-
expect(suggestion).toEqual([])
151-
})
150+
expect(suggestion).toEqual([]);
151+
});
152152

153153
it('should lists no suggestions when json path is invalid', () => {
154154
// Given
155155
// When
156-
const suggestion = getSuggestion('$.hello[@', 1, { test: [0, 1] });
156+
const suggestion = getSuggestions('$.hello[@', 1, { test: [0, 1] });
157157
// then
158158
expect(suggestion).toEqual([]);
159-
})
159+
});
160160

161161
it ('should lists no properties when json path is invalid', () => {
162162
// Given
163163
const suggestions = [{value: 'all_properties', description: 'test'},{value: 'all_properties_recursively', description: 'test'}];
164164
// When
165165
const evaluatedProperties = evalAllProperties(suggestions, '$....', {test: 'a'});
166166
// Then
167-
expect(evaluatedProperties).toEqual([[],[]])
168-
})
169-
})
167+
expect(evaluatedProperties).toEqual([[],[]]);
168+
});
169+
});

0 commit comments

Comments
 (0)