Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Commit c46f119

Browse files
committed
updated tests
1 parent cbccf87 commit c46f119

File tree

7 files changed

+241
-275
lines changed

7 files changed

+241
-275
lines changed

src/js/components/DataTypes/Function.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export default class extends React.Component {
4343
return (
4444
<div {...Theme(props.theme, 'function')} >
4545
<DataTypeLabel type_name={type_name} {...props} />
46-
<span onClick={()=>{this.toggleCollapsed()}} >
46+
<span class="rjv-function-container"
47+
onClick={()=>{this.toggleCollapsed()}} >
4748
{this.getFunctionDisplay(collapsed)}
4849
</span>
4950
</div>

src/js/components/ObjectKeyModal/ObjectKeyModal.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export default class extends React.Component {
4040
</div>
4141
<div style={{position: 'relative'}}>
4242
<input {...Theme(theme, 'key-modal-input')}
43-
id={'rjv-modal-input-' + rjvId}
4443
class="key-modal-input"
4544
ref={el => el && el.focus()}
4645
spellCheck={false}
@@ -79,23 +78,6 @@ export default class extends React.Component {
7978
);
8079
}
8180

82-
componentDidMount() {
83-
const {rjvId} = this.props;
84-
moveCursorToEnd(
85-
document.getElementById('rjv-modal-input-' + rjvId)
86-
);
87-
function moveCursorToEnd(el) {
88-
if (typeof el.selectionStart == "number") {
89-
el.selectionStart = el.selectionEnd = el.value.length;
90-
} else if (typeof el.createTextRange != "undefined") {
91-
el.focus();
92-
var range = el.createTextRange();
93-
range.collapse(false);
94-
range.select();
95-
}
96-
}
97-
}
98-
9981
submit = () => {
10082
this.props.submit(this.state.input);
10183
}

test/tests/js/components/AddKeyRequest-test.js

Lines changed: 0 additions & 254 deletions
This file was deleted.

test/tests/js/components/DataTypes/Function-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('<JsonFunction />', function () {
7979

8080
expect(wrapper.find('.function-collapsed')).to.have.length(1);
8181

82-
wrapper.simulate('click');
82+
wrapper.find('.rjv-function-container').simulate('click');
8383

8484
expect(wrapper.find('.function-collapsed')).to.have.length(0);
8585

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { shallow, render, mount } from 'enzyme';
3+
import {expect} from 'chai';
4+
5+
import AddKeyRequest from '/react/src/js/components/ObjectKeyModal/AddKeyRequest';
6+
import ObjectAttributes from '/react/src/js/stores/ObjectAttributes';
7+
8+
9+
describe('<AddKeyRequest />', function () {
10+
const rjvId = 1;
11+
12+
it('AddKeyRequest should not render input when inactive', function () {
13+
ObjectAttributes.set(
14+
rjvId, 'action', 'new-key-request', {
15+
existing_value: {test:true},
16+
namespace: [],
17+
new_value: {test: null}
18+
}
19+
);
20+
ObjectAttributes.set(
21+
rjvId, 'global', 'src', {test:true}
22+
);
23+
const wrapper = mount(
24+
<AddKeyRequest
25+
active={false}
26+
theme='rjv-default'
27+
rjvId={rjvId}
28+
/>
29+
);
30+
31+
expect(
32+
wrapper.find('.key-modal-input').length
33+
).to.equal(0);
34+
});
35+
36+
it('AddKeyRequest should render input when active', function () {
37+
ObjectAttributes.set(
38+
rjvId, 'action', 'new-key-request', {
39+
existing_value: {test:true},
40+
namespace: [],
41+
new_value: {test: null}
42+
}
43+
);
44+
ObjectAttributes.set(
45+
rjvId, 'global', 'src', {test:true}
46+
);
47+
const wrapper = mount(
48+
<AddKeyRequest
49+
active={true}
50+
theme='rjv-default'
51+
rjvId={rjvId}
52+
/>
53+
);
54+
55+
expect(
56+
wrapper.find('.key-modal-input').length
57+
).to.equal(1);
58+
});
59+
60+
});

0 commit comments

Comments
 (0)