diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index 4be24f06..413d99dc 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -272,6 +272,32 @@ MicBlogCreatorTest >> testSortSingleSummarizedDocuments [ assert: (listOfSummarizedDocuments at: 3) equals: summarized2 ] +{ #category : 'tests' } +MicBlogCreatorTest >> testTargetDirectoryCleanDirectory [ + + self assert: (fileSystem / 'source') hasChildren. + blog targetDirectory: fileSystem / 'source'. + self assert: (fileSystem / 'source') hasChildren not. +] + +{ #category : 'tests' } +MicBlogCreatorTest >> testTargetDirectoryWithFileReference [ + + blog targetDirectory: fileSystem / 'html'. + + self assert: blog targetDirectory equals: fileSystem / 'html' +] + +{ #category : 'tests' } +MicBlogCreatorTest >> testTargetDirectoryWithString [ + +"we use basename cause we can't pass the memory with a String" + + blog targetDirectory: 'html'. + + self assert: blog targetDirectory basename equals: (fileSystem / 'html') basename +] + { #category : 'tests' } MicBlogCreatorTest >> testWriteTo [ diff --git a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st index 7d8dcc95..7fbdc8bf 100644 --- a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st @@ -27,6 +27,44 @@ MicMonthListCreatorTest >> setUp [ monthListCreator root: MicFileTestResources new genericEmptyRootPath ] +{ #category : 'tests' } +MicMonthListCreatorTest >> testCreateListOfMonthListFromSummarized [ + + | dateList january2019 january2018 listSummarizerTest| + listSummarizerTest := MicListSummarizerTest new. + listSummarizerTest setUp. + dateList := monthListCreator createListOfMonthListFromSummarized: listSummarizerTest createListOfMicRootBlock. + + january2019 := Month year: 2019 month: 1. + january2018 := Month year: 2018 month: 1. + + self assert: (dateList isKindOf: Set); + assert: dateList size equals: 2; + assert: (dateList includes: january2018); + assert: (dateList includes: january2019) +] + +{ #category : 'tests' } +MicMonthListCreatorTest >> testCreateListOfMonthListFromSummarizedAreSet [ + + | singleSummarizer summarizedDocument dateList january2019 | + + singleSummarizer := MicSingleSummarizer new. + singleSummarizer targetDirectory: '/html/' asFileReference; + root: MicFileTestResources new genericEmptyRootPath. + + summarizedDocument := (singleSummarizer summarize: + ((Microdown parse: ressources generateFilesystemExample1 contents) + fromFile: ressources generateFilesystemExample1)). + dateList := monthListCreator createListOfMonthListFromSummarized: { summarizedDocument copy. summarizedDocument copy. summarizedDocument copy }. + + january2019 := Month year: 2019 month: 1. + + self assert: (dateList isKindOf: Set); + assert: dateList size equals: 1; + assert: (dateList includes: january2019) +] + { #category : 'tests' } MicMonthListCreatorTest >> testGenerateDateListSince2014 [ diff --git a/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st b/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st index 85016523..6ad00718 100644 --- a/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st +++ b/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st @@ -200,6 +200,30 @@ MicSingleSummarizerTest >> testSummarizeFile [ self assert: (root isKindOf: MicRootBlock) ] +{ #category : 'tests' } +MicSingleSummarizerTest >> testWithFromFile [ + + | root fromFile | + root := self createMicRootBlock. + fromFile := root fromFile. + + micSingleSummarizer verifyFromFile: root. + + self assert: root fromFile equals: fromFile +] + +{ #category : 'tests' } +MicSingleSummarizerTest >> testWithFromFileNil [ + + | root | + root := self createMicRootBlock. + root fromFile: nil. + + micSingleSummarizer verifyFromFile: root. + + self assert: root fromFile equals: '' +] + { #category : 'tests' } MicSingleSummarizerTest >> testWithMetaDataAndWithDate [ @@ -237,6 +261,18 @@ MicSingleSummarizerTest >> testWithMetaDataButInvalidDate [ equals: micSingleSummarizer replacementDate ] +{ #category : 'tests' } +MicSingleSummarizerTest >> testWithoutFromFile [ + + | root | + root := Microdown parse: + resources generateFilesystemExample1 contents. + + micSingleSummarizer verifyFromFile: root. + + self assert: root fromFile equals: '' +] + { #category : 'tests' } MicSingleSummarizerTest >> testWithoutMetaData [ diff --git a/src/Microdown-Blog/MicSingleSummarizer.class.st b/src/Microdown-Blog/MicSingleSummarizer.class.st index 81032fe4..b466a717 100644 --- a/src/Microdown-Blog/MicSingleSummarizer.class.st +++ b/src/Microdown-Blog/MicSingleSummarizer.class.st @@ -54,6 +54,8 @@ MicSingleSummarizer >> headerLink: aMicRootBlock [ | headerLink header fileReference | headerLink := MicHeaderBlock new. header := self firstHeaderBlockOf: aMicRootBlock. + + self verifyFromFile: aMicRootBlock. fileReference := (aMicRootBlock fromFile withoutExtension fullName withoutPrefix: targetDirectory fullName) , '.html'. @@ -131,3 +133,18 @@ MicSingleSummarizer >> summarizeFile: aFileReference [ root fromFile: aFileReference. ^ self summarize: root ] + +{ #category : 'accessing' } +MicSingleSummarizer >> verifyFromFile: aMicRootBlock [ + + | newFromFile | + + newFromFile := ''. + + aMicRootBlock properties ifNotNil: [ + aMicRootBlock properties ifNotEmpty: [ + aMicRootBlock fromFile ifNotNil: [ + newFromFile := aMicRootBlock fromFile ] ] ]. + + aMicRootBlock fromFile: newFromFile +]