Fixed unit tests

This commit is contained in:
jos 2017-11-22 10:12:59 +01:00
parent bac12dcc5a
commit 56528dc054
2 changed files with 30 additions and 15 deletions

View File

@ -364,7 +364,6 @@ export default class TreeMode extends Component {
// TODO: implement handleInsertStructure // TODO: implement handleInsertStructure
console.log('TODO: handleInsertStructure', path) console.log('TODO: handleInsertStructure', path)
alert('not yet implemented...') alert('not yet implemented...')
} }
handleAppend = (parentPath, type) => { handleAppend = (parentPath, type) => {

View File

@ -275,8 +275,8 @@ test('previousSearchResult', t => {
test('selection (object)', t => { test('selection (object)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '2', 'last']}, start: ['obj', 'arr', '2', 'last'],
end: {path: ['nill']} end: ['nill']
} }
const actual = applySelection(ESON1, selection) const actual = applySelection(ESON1, selection)
@ -291,8 +291,8 @@ test('selection (object)', t => {
test('selection (array)', t => { test('selection (array)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '1']}, start: ['obj', 'arr', '1'],
end: {path: ['obj', 'arr', '0']} // note the "wrong" order of start and end end: ['obj', 'arr', '0'] // note the "wrong" order of start and end
} }
const actual = applySelection(ESON1, selection) const actual = applySelection(ESON1, selection)
@ -307,8 +307,8 @@ test('selection (array)', t => {
test('selection (value)', t => { test('selection (value)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '2', 'first']}, start: ['obj', 'arr', '2', 'first'],
end: {path: ['obj', 'arr', '2', 'first']} end: ['obj', 'arr', '2', 'first']
} }
const actual = applySelection(ESON1, selection) const actual = applySelection(ESON1, selection)
@ -318,8 +318,8 @@ test('selection (value)', t => {
test('selection (node)', t => { test('selection (node)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr']}, start: ['obj', 'arr'],
end: {path: ['obj', 'arr']} end: ['obj', 'arr']
} }
const actual = applySelection(ESON1, selection) const actual = applySelection(ESON1, selection)
@ -329,8 +329,8 @@ test('selection (node)', t => {
test('pathsFromSelection (object)', t => { test('pathsFromSelection (object)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '2', 'last']}, start: ['obj', 'arr', '2', 'last'],
end: {path: ['nill']} end: ['nill']
} }
t.deepEqual(pathsFromSelection(ESON1, selection), [ t.deepEqual(pathsFromSelection(ESON1, selection), [
@ -342,8 +342,8 @@ test('pathsFromSelection (object)', t => {
test('pathsFromSelection (array)', t => { test('pathsFromSelection (array)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '1']}, start: ['obj', 'arr', '1'],
end: {path: ['obj', 'arr', '0']} // note the "wrong" order of start and end end: ['obj', 'arr', '0'] // note the "wrong" order of start and end
} }
t.deepEqual(pathsFromSelection(ESON1, selection), [ t.deepEqual(pathsFromSelection(ESON1, selection), [
@ -354,8 +354,8 @@ test('pathsFromSelection (array)', t => {
test('pathsFromSelection (value)', t => { test('pathsFromSelection (value)', t => {
const selection = { const selection = {
start: {path: ['obj', 'arr', '2', 'first']}, start: ['obj', 'arr', '2', 'first'],
end: {path: ['obj', 'arr', '2', 'first']} end: ['obj', 'arr', '2', 'first']
} }
t.deepEqual(pathsFromSelection(ESON1, selection), [ t.deepEqual(pathsFromSelection(ESON1, selection), [
@ -363,6 +363,22 @@ test('pathsFromSelection (value)', t => {
]) ])
}) })
test('pathsFromSelection (before)', t => {
const selection = {
before: ['obj', 'arr', '2', 'first']
}
t.deepEqual(pathsFromSelection(ESON1, selection), [])
})
test('pathsFromSelection (after)', t => {
const selection = {
after: ['obj', 'arr', '2', 'first']
}
t.deepEqual(pathsFromSelection(ESON1, selection), [])
})
// helper function to replace all id properties with a constant value // helper function to replace all id properties with a constant value
function replaceIds (data, value = '[ID]') { function replaceIds (data, value = '[ID]') {
if (data.type === 'Object') { if (data.type === 'Object') {