86 lines
2.2 KiB
Smalltalk
86 lines
2.2 KiB
Smalltalk
"
|
|
I test the main functionality of the GrafoscopioNode class.
|
|
"
|
|
Class {
|
|
#name : #GrafoscopioNodeTest,
|
|
#superclass : #TestCase,
|
|
#category : #'Grafoscopio-Model'
|
|
}
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testAddingChildren [
|
|
| tree nnode orig |
|
|
tree := GrafoscopioNode new becomeDefaultTestTree.
|
|
nnode := GrafoscopioNode new.
|
|
orig := tree children size.
|
|
tree addNode: nnode.
|
|
self assert: tree children size equals: orig + 1.
|
|
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testDemoteNode [
|
|
| tree child1 child2 |
|
|
tree := GrafoscopioNode new.
|
|
child1 := GrafoscopioNode new.
|
|
child2 := GrafoscopioNode new.
|
|
tree
|
|
addNode: child1;
|
|
addNode: child2.
|
|
child2 demote.
|
|
self assert: child2 level equals: child1 level + 1
|
|
|
|
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testFindAndReplace [
|
|
| tree |
|
|
tree := GrafoscopioNode new.
|
|
tree body: 'I''m only a test node.'.
|
|
tree find: 'only' andReplaceWith: 'JUST'.
|
|
self assert: (tree body findString: 'JUST') > 0.
|
|
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testHasMarkdownSubtreesToExport [
|
|
"Because becomeDefaultTestTree contains at least one non empty 'links' object that
|
|
points to a relative path in the file system, ending in '.md' or '.markdown' the
|
|
result of this test is true.
|
|
Please see look #becomeDefaultTestTree message to see the details that makes this test true."
|
|
| tree |
|
|
tree := GrafoscopioNode new becomeDefaultTestTree.
|
|
self assert: tree selectMarkdownSubtreesToExport isNotEmpty equals: true.
|
|
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testInitializeIsOk [
|
|
self shouldnt: [ GrafoscopioNode new ] raise: Error
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testPromoteNode [
|
|
| tree child1 child2 |
|
|
tree := GrafoscopioNode new.
|
|
child1 := GrafoscopioNode new.
|
|
child2 := GrafoscopioNode new.
|
|
tree addNode: child1.
|
|
child1 addNode: child2.
|
|
child2 promote.
|
|
self assert: child2 level equals: child1 level
|
|
|
|
|
|
]
|
|
|
|
{ #category : #tests }
|
|
GrafoscopioNodeTest >> testRemovingChildren [
|
|
| tree orig |
|
|
tree := GrafoscopioNode new becomeDefaultTestTree.
|
|
orig := tree children size.
|
|
orig > 0 ifTrue: [ tree removeNode: (tree children at: 1) ].
|
|
self assert: tree children size equals: orig - 1.
|
|
|
|
]
|