-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #803 from pillar-markup/RefactBookTesterTests
Refact book tester tests
- Loading branch information
Showing
17 changed files
with
1,408 additions
and
1,193 deletions.
There are no files selected for viewing
173 changes: 173 additions & 0 deletions
173
src/Microdown-BookTester-Tests/MicFileCollectorTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
Class { | ||
#name : 'MicFileCollectorTest', | ||
#superclass : 'MicFileTest', | ||
#instVars : [ | ||
'mainMic', | ||
'visitor' | ||
], | ||
#category : 'Microdown-BookTester-Tests', | ||
#package : 'Microdown-BookTester-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MicFileCollectorTest >> startVisitingFromTheRoot: root [ | ||
|
||
"just parsing the file here and and passing it to the visitor with the fs used " | ||
"Note : its quite important to use parseFile: because assigning fromFile is implemented inside the parseFile: method" | ||
|
||
mainMic := Microdown parseFile: root. | ||
visitor := MicFileCollector new. | ||
visitor | ||
fileSystem: fs; | ||
visit: mainMic. | ||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testDoubleLoopsAndThatUnexistingInputIsCorrectlyResolved [ | ||
|
||
self createDoubleLoop3To1And5To3. | ||
self startVisitingFromTheRoot: section2. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
Set <- { | ||
'/myDirectory/section1.md' . | ||
'/myDirectory/sections/section2.md' . | ||
'/myDirectory/sections/subsections/section4.md' . | ||
'/myDirectory/sections/subsections/subsubsections/section5.md' . | ||
'/myDirectory/sections/section3.md' | ||
}. | ||
|
||
self | ||
assert: (visitor unexistingFiles collect: [:each | each path path ]) | ||
equals: Set <- { '/myDirectory/sections/subsections/section6.md' } | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testFileCollectorHandlesLoopFromSection3ToMain [ | ||
"and unknown references." | ||
|
||
self createProjectWithLoopFromSection3ToSection1. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
"we expect | ||
section 1 | ||
section2 | ||
section3 | ||
section1 | ||
section5 | ||
section4" | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
{ | ||
'/myDirectory/section1.md' . | ||
'/myDirectory/sections/section2.md' . | ||
'/myDirectory/sections/section4.md' . | ||
'/myDirectory/sections/subsections/section3.md' . | ||
'/myDirectory/sections/section5.md' | ||
} asSet. | ||
self | ||
assert: (visitor unexistingFiles collect: [:each | each path path ]) | ||
equals: Set <- { '/myDirectory/section6.md' } | ||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testLoopOfFilesReferencingEachOther [ | ||
|
||
self createProjectSmallLoop. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
Set <- { | ||
'/myDirectory/section1.md'. | ||
'/myDirectory/sections/section2.md' | ||
} | ||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testMultipleReferencesOfFileThatDoesNotExist [ | ||
|
||
self createProjectWithUnexistingSection3And5. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
Set <- { | ||
'/myDirectory/section1.md' . | ||
'/myDirectory/sections/section2.md' . | ||
'/myDirectory/sections/section4.md' | ||
}. | ||
self | ||
assert: (visitor unexistingFiles collect: [:each | each path path ]) | ||
equals: Set <- { | ||
'/myDirectory/sections/subsections/section5.md' . | ||
'/myDirectory/sections/section3.md' . | ||
'/myDirectory/sections/subsections/section3.md' } | ||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testMultipleReferencesToTheSameFile [ | ||
|
||
self createUndirectCyclesToTheSameFile. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
{ '/myDirectory/section1.md'. '/myDirectory/sections/section2.md' . '/myDirectory/sections/section4.md' } asSet | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testOnlyGoDownInFolders [ | ||
|
||
self createProjectOnlyGoDownInFolders. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
Set <- { | ||
'/myDirectory/section1.md' . | ||
'/myDirectory/sections/section2.md' . | ||
'/myDirectory/sections/subsections/section3.md' . '/myDirectory/sections/subsections/subsubsections/section4.md' | ||
}. | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testOnlyGoUpInFoldersStartingFromAnotherRoot [ | ||
|
||
self createProjectOnlyGoUpInFolders. | ||
self startVisitingFromTheRoot: section4. | ||
|
||
self | ||
assert: visitor visitedDocumentFiles | ||
equals: | ||
Set <- { | ||
'/myDirectory/section1.md'. | ||
'/myDirectory/sections/section2.md' . | ||
'/myDirectory/sections/subsections/section3.md' . '/myDirectory/sections/subsections/subsubsections/section4.md' | ||
} | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
MicFileCollectorTest >> testUnreferencedFileAreNotHandled [ | ||
"This test verifies that the collector only collects files that are referenced from a root and not all the files in a folder." | ||
|
||
self createProjectWithUnreferencedFiles3And5. | ||
self startVisitingFromTheRoot: section1. | ||
|
||
self assert: visitor visitedDocumentFiles equals: Set | ||
<- | ||
{ '/myDirectory/section1.md'. '/myDirectory/sections/section2.md'. | ||
'/myDirectory/sections/section4.md' } | ||
] |
Oops, something went wrong.