Skip to content

Commit

Permalink
Merge pull request #1636 from hernanmd/p13-add-notebook-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc authored Oct 28, 2024
2 parents 8e3e118 + cf3640c commit 1b290cb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ SpNotebookAdapterTest >> initializeTestedInstance [
addPage: (SpNotebookPage title: 'Mock2' icon: (self iconNamed: #changeUpdate) provider: [ SpLabelPresenter new ])
]

{ #category : 'tests' }
SpNotebookAdapterTest >> testAccessPage [

| newPage |

newPage := SpNotebookPage title: 'Mock3' provider: [ SpLabelPresenter new ].
presenter addPage: newPage.
self assert: (presenter pageNamed: 'Mock3') equals: newPage.
presenter removeAll.
self should: [ presenter pageNamed: 'Mock3' ] raise: NotFound.
]

{ #category : 'tests' }
SpNotebookAdapterTest >> testAddPage [
self assert: self adapter numberOfTabs equals: 2.
Expand All @@ -42,6 +54,14 @@ SpNotebookAdapterTest >> testClickOnPage [
self assert: self adapter selectedPageName equals: 'Mock2'
]

{ #category : 'tests' }
SpNotebookAdapterTest >> testHasPages [

self assert: presenter hasPages.
presenter removeAll.
self deny: presenter hasPages.
]

{ #category : 'tests' }
SpNotebookAdapterTest >> testRemoveAll [

Expand Down
19 changes: 19 additions & 0 deletions src/Spec2-Core/SpNotebookPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ SpNotebookPresenter >> addPageTitle: aString provider: aBlock [
^ self addPage: (SpNotebookPage title: aString provider: aBlock)
]

{ #category : 'testing' }
SpNotebookPresenter >> hasPageNamed: aTitle [

^ self pages anySatisfy: [ : page | page title = aTitle ]
]

{ #category : 'testing' }
SpNotebookPresenter >> hasPages [

^ self pages isNotEmpty
]

{ #category : 'initialization' }
SpNotebookPresenter >> initialize [

Expand All @@ -55,6 +67,13 @@ SpNotebookPresenter >> pageAt: index [
^ self pages at: index
]

{ #category : 'api' }
SpNotebookPresenter >> pageNamed: aTitle [
"Answer the receiver's <SpNotebookPage> with aTitle as name. Raise a <NotFound> exception if not present"

^ self pages detect: [ : page | page title = aTitle ]
]

{ #category : 'private' }
SpNotebookPresenter >> pageTitleChanged: aPage [

Expand Down

0 comments on commit 1b290cb

Please sign in to comment.