Skip to content

Commit

Permalink
refactor: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 25, 2024
1 parent d610ce9 commit c80b094
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
20 changes: 7 additions & 13 deletions dev-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,9 @@ ReactDom.render(

{/* String with special escape sequences */}
<JsonViewer
collapsed
theme='monokai'
name='String with special escape sequences'
src={getExampleWithStringEscapeSequences()}
onEdit={e => {
console.log('edit callback', e)
if (e.new_value == 'error') {
return false
}
}}
/>
</div>,
document.getElementById('app-container')
Expand All @@ -202,7 +196,7 @@ ReactDom.render(
/*-------------------------------------------------------------------------*/

//just a function to get an example JSON object
function getExampleJson1() {
function getExampleJson1 () {
return {
string: 'this is a test string',
integer: 42,
Expand Down Expand Up @@ -231,7 +225,7 @@ function getExampleJson1() {
}

//and another a function to get an example JSON object
function getExampleJson2() {
function getExampleJson2 () {
return {
normalized: {
'1-grams': {
Expand Down Expand Up @@ -269,7 +263,7 @@ function getExampleJson2() {
}
}

function getExampleJson3() {
function getExampleJson3 () {
return {
example_information:
'this example has the collapsed prop set to true and the indentWidth prop is set to 8',
Expand All @@ -285,7 +279,7 @@ function getExampleJson3() {
}
}

function getExampleJson4() {
function getExampleJson4 () {
const large_array = new Array(225).fill('this is a large array full of items')

large_array.push(getExampleArray())
Expand All @@ -295,7 +289,7 @@ function getExampleJson4() {
return large_array
}

function getExampleArray() {
function getExampleArray () {
return [
'you can also display arrays!',
new Date(),
Expand All @@ -308,6 +302,6 @@ function getExampleArray() {
]
}

function getExampleWithStringEscapeSequences() {
function getExampleWithStringEscapeSequences () {
return { '\\\n\t\r\f\\n': '\\\n\t\r\f\\n' }
}
10 changes: 0 additions & 10 deletions test/tests/js/components/DataTypes/String-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import JsonString from './../../../../../src/js/components/DataTypes/String'

describe('<JsonString />', function () {
it('string component should have a data type label', function () {
const rjvId = 1
const wrapper = mount(
<JsonString
value='test'
rjvId={rjvId}
displayDataTypes
theme='rjv-default'
/>
Expand All @@ -19,10 +17,8 @@ describe('<JsonString />', function () {
})

it('string with hidden data type', function () {
const rjvId = 1
const props = {
value: 'test',
rjvId: 1,
theme: 'rjv-default',
displayDataTypes: false
}
Expand All @@ -32,10 +28,8 @@ describe('<JsonString />', function () {

// test collapsed string and expand click
it('string displaying data type', function () {
const rjvId = 1
const props = {
value: 'test',
rjvId: 1,
displayDataTypes: false,
theme: 'rjv-default'
}
Expand All @@ -44,11 +38,9 @@ describe('<JsonString />', function () {
})

it('collapsed string content', function () {
const rjvId = 1
const props = {
value: '123456789',
collapseStringsAfterLength: 3,
rjvId: 1,
displayDataTypes: false,
theme: 'rjv-default'
}
Expand All @@ -63,10 +55,8 @@ describe('<JsonString />', function () {
})

it('string with special escape sequences', function () {
const rjvId = 1
const props = {
value: '\\\n\t\r\f\\n',
rjvId: 1,
displayDataTypes: false,
theme: 'rjv-default'
}
Expand Down

0 comments on commit c80b094

Please sign in to comment.