Skip to content

Commit

Permalink
Updated unit tests to work with new logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Callum committed May 3, 2019
1 parent 958b212 commit 290c495
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Name|Type|Default|Description
`onSelect`|`(select)=>{}`|`false`|When a function is passed in, clicking a value triggers the `onSelect` method to be called.
`sortKeys`|`boolean`|`false`|set to true to sort object keys
`validationMessage`|`string`|"Validation Error"|Custom message for validation failures to `onEdit`, `onAdd`, or `onDelete` callbacks
`disableDetectDatatypes`|`object`|`{ object: true, array: true, string: true, integer: true, float: true, boolean: true, date: true, function: true, null: true, nan: true, undefined: true}`| Sets which datatypes shouldn't be detected, any that are set as `true` will make it so editing won't detect the datatype
`disableDetectDatatypes`|`object`|`{}`| Sets which datatypes shouldn't be detected, any that are set as `true` will make it so editing won't detect the datatype

### Features
* `onEdit`, `onAdd` and `onDelete` props allow users to edit the `src` variable
Expand Down
14 changes: 1 addition & 13 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,7 @@ class ReactJsonView extends React.PureComponent {
style: {},
validationMessage: 'Validation Error',
defaultValue: null,
disableDetectDatatypes: {
object: true,
array: true,
string: true,
integer: true,
float: true,
boolean: true,
date: true,
function: true,
null: true,
nan: true,
undefined: true
}
disableDetectDatatypes: {}
}

// will trigger whenever setState() is called, or parent passes in new props.
Expand Down
40 changes: 14 additions & 26 deletions test/tests/js/components/VariableEditor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,7 @@ import VariableEditor from "./../../../../src/js/components/VariableEditor"

describe("<VariableEditor />", function () {
const rjvId = 1
const detectDatatypesTrue = {
object: true,
array: true,
string: true,
integer: true,
float: true,
boolean: true,
date: true,
function: true,
null: true,
nan: true,
undefined: true
}
const disableDetectDatatypes = {}

it("VariableEditor click-to-edit should be visible", function () {
const wrapper = shallow(
Expand Down Expand Up @@ -63,7 +51,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: 5,
Expand All @@ -82,7 +70,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: 5,
Expand Down Expand Up @@ -110,7 +98,7 @@ describe("<VariableEditor />", function () {
}}
namespace={["test"]}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: existing_value,
Expand Down Expand Up @@ -149,7 +137,7 @@ describe("<VariableEditor />", function () {
}}
namespace={["test"]}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: existing_value,
Expand Down Expand Up @@ -191,7 +179,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "null",
Expand All @@ -212,7 +200,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "undefined",
Expand All @@ -235,7 +223,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "NaN",
Expand All @@ -256,7 +244,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "test",
Expand All @@ -277,7 +265,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "function test() {}",
Expand All @@ -300,7 +288,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "{}",
Expand All @@ -321,7 +309,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "[1,2,3]",
Expand All @@ -344,7 +332,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "-5.2",
Expand All @@ -365,7 +353,7 @@ describe("<VariableEditor />", function () {
theme="rjv-default"
onEdit={edit => { }}
rjvId={rjvId}
detectDatatypes={detectDatatypesTrue}
disableDetectDatatypes={disableDetectDatatypes}
variable={{
name: "test",
value: "5",
Expand Down

0 comments on commit 290c495

Please sign in to comment.