Skip to content

Commit

Permalink
Merge pull request #16 from sarahtathy/sarah-branch
Browse files Browse the repository at this point in the history
add the tests for to create a file
  • Loading branch information
hernanmd authored Jul 17, 2024
2 parents bd86716 + a8dac52 commit 29246ba
Show file tree
Hide file tree
Showing 15 changed files with 327 additions and 378 deletions.
9 changes: 4 additions & 5 deletions src/BaselineOfMicroEd/BaselineOfMicroEd.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ BaselineOfMicroEd >> baseline: spec [
"Suppose that this is only for P9
spec baseline: ''Microdown'' with: [
spec repository: ''github://pillar-markup/Microdown/src'' ]"

spec
package: 'MicroEd'.
spec
package: 'MicroEd-Tests'
with: [ spec requires: #('MicroEd') ]
package: 'MicroEd';
package: 'MicroEd-Spec' with: [ spec requires: #('MicroEd') ];
package: 'MicroEd-Tests' with: [ spec requires: #('MicroEd') ];
package: 'MicroEd-Spec-Tests' with: [ spec requires: #('MicroEd') ]
]
]
111 changes: 111 additions & 0 deletions src/MicroEd-Spec-Tests/MDEditorFilePresenterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Class {
#name : 'MDEditorFilePresenterTest',
#superclass : 'TestCase',
#instVars : [
'window',
'memoryFS',
'presenter',
'mdFile',
'fileReference'
],
#category : 'MicroEd-Spec-Tests',
#package : 'MicroEd-Spec-Tests'
}

{ #category : 'running' }
MDEditorFilePresenterTest >> mockTextObject: aString [

^ SpTextPresenter new text: aString
]

{ #category : 'running' }
MDEditorFilePresenterTest >> setUp [

| text |
super setUp.
memoryFS := FileSystem memory.
presenter := MDEditorPresenter new.
window := presenter open.
text := 'This is just a test'.
fileReference := memoryFS / 'aFileReference.txt'.
fileReference writeStreamDo: [
:stream | stream nextPutAll: text ].

mdFile := MDFile newFromFileReference: fileReference.
]

{ #category : 'running' }
MDEditorFilePresenterTest >> tearDown [

window ifNotNil: [ window close ].
fileReference ensureDelete.
super tearDown.
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testCleanAction [

presenter cleanInput.
self assert: presenter textInputText equals: ''.
self assert: presenter textOutputText equals: ''
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testGotCurrentFileWhenIsNotSpecify [

self assert: presenter mdFile class equals: MDFile
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testGotCurrentFileWhenIsSpecify [

presenter mdFile: mdFile.
self assert: presenter mdFile class equals: MDFile
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testGotMicrodownParser [

self assert: presenter microdownParser class equals: MicrodownParser
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testGotSyntaxStateWhenIsNotSpecify [

presenter syntaxState: MDMicroDownSyntax new.
self assert: presenter syntaxState class equals: MDMicroDownSyntax
]

{ #category : 'tests-interaction' }
MDEditorFilePresenterTest >> testOpenIsWorkingSmokeTest [

self assert: window isOpen

]

{ #category : 'running' }
MDEditorFilePresenterTest >> testSaveWithExtension [

| text textPresenter |
text := 'This is just a test'.
textPresenter := self mockTextObject: text.
presenter mdFile: mdFile.
presenter saveFile.

self assert: mdFile extension equals: 'mic'.
self assert: mdFile contents equals: text.

]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testTextInputTextIsNotSpecify [

self assert: presenter textInputText equals: '% Type your marked-up text here. Render it and see right the output generated as rich text', String cr, String cr, presenter syntaxState exampleText
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testTextInputTextIsSpecify [

presenter textInputText: 'test'.
self assert: presenter textInputText equals: 'test'
]
1 change: 1 addition & 0 deletions src/MicroEd-Spec-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'MicroEd-Spec-Tests' }
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Class {
#instVars : [
'textInput',
'textOutput',
'currentFile',
'composer',
'syntaxState'
'syntaxState',
'mdFile'
],
#category : 'MicroEd',
#package : 'MicroEd'
#category : 'MicroEd-Spec',
#package : 'MicroEd-Spec'
}

{ #category : 'world menu' }
Expand Down Expand Up @@ -52,18 +52,6 @@ MDEditorPresenter >> cleanOutput [
textOutput text: ''
]

{ #category : 'accessing' }
MDEditorPresenter >> currentFileState [

^ currentFile ifNil: [ ^ currentFile := MDEditorNewFile new ]
]

{ #category : 'accessing' }
MDEditorPresenter >> currentFileState: aMDEditorFile [

currentFile := aMDEditorFile
]

{ #category : 'specs' }
MDEditorPresenter >> defaultLayout [

Expand Down Expand Up @@ -163,6 +151,19 @@ MDEditorPresenter >> initializeWindow: aWindowPresenter [
windowIcon: (self application iconNamed: #glamorousBrowseIcon)
]

{ #category : 'accessing' }
MDEditorPresenter >> mdFile [

^ mdFile ifNil: [ mdFile := MDFile new ]
]

{ #category : 'accessing' }
MDEditorPresenter >> mdFile: aMDFile [

mdFile := aMDFile.
textInput text: mdFile contents
]

{ #category : 'utilities' }
MDEditorPresenter >> microdownParser [

Expand All @@ -179,11 +180,11 @@ MDEditorPresenter >> openFile [
openModal.
selectedFile
ifNotNil: [
self currentFileState: (MDEditorOpenedFile new file: selectedFile).
self mdFile: (MDFile new file: selectedFile).
textInput text: selectedFile contents.
self cleanOutput.
self updateTitle ]
ifNil: [ self currentFileState: MDEditorNoFile new ].
ifNil: [ self mdFile: MDFile new ].


]
Expand All @@ -204,8 +205,8 @@ MDEditorPresenter >> renderDocument [
MDEditorPresenter >> saveFile [
"SAVE button is pressed: save file, then print message if actually saved (if no cancel)"

self currentFileState: (self currentFileState
save: textInput
self mdFile: (self mdFile
save: textInput text asString
withExtension: syntaxState extension).
self updateTitle.

Expand All @@ -224,7 +225,7 @@ MDEditorPresenter >> startNewFile [
"NEW button is pressed: reset tool"

self cleanInput.
currentFile := MDEditorNewFile new.
mdFile := MDFile new.
self updateTitle
]

Expand Down Expand Up @@ -261,7 +262,7 @@ MDEditorPresenter >> textOutputText [
{ #category : 'api' }
MDEditorPresenter >> title [

^ 'MicroDown Editor - ' , self currentFileState basename
^ 'MicroDown Editor - ' , self mdFile basename
]

{ #category : 'api' }
Expand Down
1 change: 1 addition & 0 deletions src/MicroEd-Spec/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'MicroEd-Spec' }
23 changes: 0 additions & 23 deletions src/MicroEd-Tests/MDEditorFileTest.class.st

This file was deleted.

47 changes: 0 additions & 47 deletions src/MicroEd-Tests/MDEditorNewFileTest.class.st

This file was deleted.

48 changes: 0 additions & 48 deletions src/MicroEd-Tests/MDEditorOpenedFileTest.class.st

This file was deleted.

Loading

0 comments on commit 29246ba

Please sign in to comment.