Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug with the link #756

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Class {
#name : 'MicDocumentTransformerTest',
#name : 'MicAbstractBlogCreatorTest',
#superclass : 'TestCase',
#category : 'Microdown-Blog-Tests',
#package : 'Microdown-Blog-Tests'
}

{ #category : 'tests' }
MicDocumentTransformerTest class >> testMakeALinkTo [
MicAbstractBlogCreatorTest class >> testMakeALinkTo [

| link |
link := MicInlineParser parse: '[Pharo is cool](Test)'.
Expand All @@ -17,7 +17,7 @@ MicDocumentTransformerTest class >> testMakeALinkTo [
]

{ #category : 'tests' }
MicDocumentTransformerTest >> testMakeALinkTo [
MicAbstractBlogCreatorTest >> testMakeALinkTo [

| link |
link := MicAbstractBlogCreator new makeALink: 'Pharo is cool' to: 'Test'.
Expand All @@ -28,7 +28,7 @@ MicDocumentTransformerTest >> testMakeALinkTo [
]

{ #category : 'tests' }
MicDocumentTransformerTest >> testMakeALinkToWithEmptyArguments [
MicAbstractBlogCreatorTest >> testMakeALinkToWithEmptyArguments [

| link |
link := MicAbstractBlogCreator new makeALink: '' to: ''.
Expand Down
87 changes: 64 additions & 23 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,23 @@ When you participate to the mooc you get access to the quizz and the credit vali
{ #category : 'as yet unclassified' }
MicBlogCreatorTest >> generateArchitecture [

| ref1 ref2 ref3 |
| ref1 ref2 ref3 ref4 |
fileSystem := FileSystem memory.
fileSystem createDirectory: '/html'.
fileSystem createDirectory: '/source'.
fileSystem createDirectory: '/source/test'.

ref1 := fileSystem workingDirectory / 'source/anExample1.md'.
ref1 writeStreamDo: [ :stream | stream nextPutAll: self fileContent1 ].

ref2 := fileSystem workingDirectory / 'source/anExample2.md'.
ref2 writeStreamDo: [ :stream | stream nextPutAll: self fileContent2 ].

ref3 := fileSystem workingDirectory / 'source/anExample3.md'.
ref3 writeStreamDo: [ :stream | stream nextPutAll: self fileContent3 ]
ref3 := fileSystem workingDirectory / 'source/test/anExample3.md'.
ref3 writeStreamDo: [ :stream | stream nextPutAll: self fileContent3 ].

ref4 := fileSystem workingDirectory / 'source/anExample4.java'.
ref4 writeStreamDo: [ :stream | stream nextPutAll: 'Du java' ]
]

{ #category : 'as yet unclassified' }
Expand Down Expand Up @@ -111,7 +115,12 @@ MicBlogCreatorTest >> testCopySourceDirectoryInTarget [

blog copySourceDirectoryInTarget.

self assert: (fileSystem / 'html') children size equals: 3
self
assert: (fileSystem / 'html') children size equals: 4;
assert: (fileSystem / 'html/anExample1.md') exists;
assert: (fileSystem / 'html/anExample2.md') exists;
assert: (fileSystem / 'html/test/anExample3.md') exists;
assert: (fileSystem / 'html/anExample4.java') exists
]

{ #category : 'tests' }
Expand All @@ -122,42 +131,75 @@ MicBlogCreatorTest >> testCreateAllHtmlFile [

allFile := (fileSystem / 'html') allFiles.

self assert: allFile size equals: 6
self assert: allFile size equals: 7;
assert: (fileSystem / 'html/index.html') exists;
assert: (fileSystem / 'html/anExample1.html') exists;
assert: (fileSystem / 'html/anExample2.html') exists;
assert: (fileSystem / 'html/test/anExample3.html') exists;
assert: (fileSystem / 'html/anExample4.java') exists
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCreateFromTo [

| allFile |
MicBlogCreator createFrom: fileSystem / 'source' to: fileSystem / 'html'.

allFile := (fileSystem / 'html') allFiles.

self assert: allFile size equals: 7
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCreateHtmlEmptyGroupFileAt [

| file |

blog
createHtmlEmptyGroupFileAt: (Month year: 2019 month: 'January').

file := fileSystem / 'html/_monthBlog/January 2019.html'.

self assert:
file exists;
assert: (file contents findString: 'No files found') = 0 equals: false.
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCreateHtmlFileToReplace [

| root file |

file := self listOfFile at: 1 .

file := self listOfFile at: 1.

root := Microdown parse: file contents.
MicBlogCreator new createHtmlFile: root toReplace: file.
self assert: file basename equals: 'anExample1.html'

blog createHtmlFile: root toReplace: file.

self assert: file basename equals: 'anExample1.html'
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCreateHtmlGroupFileAt [

| root summarizer allFileParse |
| root summarizer singleSummarizer allFileParse |
summarizer := MicSummarizer new.
summarizer targetDirectory: 'html'.

allFileParse := self listOfFile collect: [ :each |
Microdown parse: each asFileReference contents ].

singleSummarizer := MicSingleSummarizer new.

allFileParse := self listOfFile collect: [ :each | singleSummarizer summarizeFile: each ].

root := summarizer
group: allFileParse
byDate: (Month year: 2019 month: 'January').
root := summarizer summarize: root.

blog
createHtmlGroupFile: root at: (Month year: 2019 month: 'January').
blog
createHtmlGroupFile: root
at: (Month year: 2019 month: 'January').

self assert: (fileSystem / 'html/_monthBlog/January 2019.html') exists
self assert:
(fileSystem / 'html/_monthBlog/January 2019.html') exists
]

{ #category : 'tests' }
Expand Down Expand Up @@ -187,12 +229,11 @@ MicBlogCreatorTest >> testRenameMarkdownIntoHtmlFile [
MicBlogCreatorTest >> testRootAssembly [

| root file |

file := self listOfFile at: 1.
root := Microdown parse: file contents.
MicBlogCreator new rootAssembly: root.

blog rootAssembly: root.

self assert: root children size equals: 5
]

Expand Down
7 changes: 5 additions & 2 deletions src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateTo [

self assert: (dateList isKindOf: MicUnorderedListBlock).
self
assert: dateList children size
equals: self numberOfMonthSince2014.
assert: dateList children size equals: self numberOfMonthSince2014;
assert: dateList children first children first plainText
equals: '[January 2014](/html/_monthBlog/January 2014)';
assert: dateList children last children first plainText
equals: '[', Date today month asString ,'](/html/_monthBlog/', Date today month asString ,')'
]
26 changes: 14 additions & 12 deletions src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Class {
{ #category : 'enumerating' }
MicSingleSummarizerTest >> createMicRootBlock [

^ Microdown parse: self generateFilesystemExample asFileReference contents
| micRootBlock |

micRootBlock := Microdown parse: self generateFilesystemExample contents.
^ micRootBlock fromFile: self generateFilesystemExample.
]

{ #category : 'enumerating' }
Expand Down Expand Up @@ -39,18 +42,17 @@ this is a code blu blu
```
' ].

^ file
^ file asFileReference
]

{ #category : 'enumerating' }
MicSingleSummarizerTest >> generateFilesystemExampleEmpty [

| file |
file := FileSystem memory workingDirectory / 'anExample1.md'.
file writeStreamDo: [ :stream |
stream nextPutAll: '' ].
file writeStreamDo: [ :stream | stream nextPutAll: '' ].

^ file
^ file asFileReference
]

{ #category : 'enumerating' }
Expand Down Expand Up @@ -78,7 +80,7 @@ this is a code blu blu
```
' ].

^ file
^ file asFileReference
]

{ #category : 'enumerating' }
Expand All @@ -103,7 +105,7 @@ this is a code blu blu
```
' ].

^ file
^ file asFileReference
]

{ #category : 'running' }
Expand Down Expand Up @@ -257,9 +259,9 @@ MicSingleSummarizerTest >> testWithMetaDataAndWithDate [
MicSingleSummarizerTest >> testWithMetaDataAndWithoutDate [

| root |
root := micSingleSummarizer summarize:
(Microdown parse:
self generateFilesystemExampleWithoutDateInMetadata).

root := micSingleSummarizer summarizeFile:
self generateFilesystemExampleWithoutDateInMetadata.
self
assert: (root isKindOf: MicRootBlock);
assert: root children size equals: 3;
Expand All @@ -271,8 +273,8 @@ MicSingleSummarizerTest >> testWithMetaDataAndWithoutDate [
MicSingleSummarizerTest >> testWithoutMetaData [

| root |
root := micSingleSummarizer summarize: (Microdown parse:
self generateFilesystemExampleWithoutMetadata ).
root := micSingleSummarizer summarizeFile:
self generateFilesystemExampleWithoutMetadata.
self
assert: (root isKindOf: MicRootBlock);
assert: root children size equals: 3;
Expand Down
17 changes: 10 additions & 7 deletions src/Microdown-Blog-Tests/MicSummarizerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ MicSummarizerTest >> createListOfMicRootBlock [
singleSummarizer := MicSingleSummarizer new.
singleSummarizer targetDirectory: '/html/'.
q
at: 1 put: (singleSummarizer summarize: (Microdown parse:
self generateFilesystemExample1 asFileReference contents));
at: 2 put: (singleSummarizer summarize: (Microdown parse:
self generateFilesystemExample2 asFileReference contents));
at: 3 put: (singleSummarizer summarize: (Microdown parse:
self generateFilesystemExample3 asFileReference contents)).
at: 1 put: (singleSummarizer summarize:
((Microdown parse: self generateFilesystemExample1 contents)
fromFile: self generateFilesystemExample1));
at: 2 put: (singleSummarizer summarize:
((Microdown parse: self generateFilesystemExample2 contents)
fromFile: self generateFilesystemExample2));
at: 3 put: (singleSummarizer summarize:
((Microdown parse: self generateFilesystemExample3 contents)
fromFile: self generateFilesystemExample3)).
^ q
]

Expand All @@ -53,7 +56,7 @@ Pharo is cool but _this is_ a superlong _paragraph_ Simple powerful language: No
Amazing debugging experience: The Pharo environment includes a debugger unlike anything you''ve seen before. It allows you to step through code, restart the execution of methods, create methods on the fly, and much more!
' ].

^ file
^ file asFileReference
]

{ #category : 'tests' }
Expand Down
Loading
Loading