Skip to content

Commit

Permalink
Fixes #1223 (#1236)
Browse files Browse the repository at this point in the history
* Fixes #1223

* Add tests.
  • Loading branch information
adamdriscoll authored Oct 8, 2019
1 parent 0747a20 commit 9377e02
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/UniversalDashboard.Materialize/Components/ud-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export default class UdModal extends React.Component {
}

onClose() {
this.setState({
content: null,
header: null,
footer: null
});
this._instance.close();
}

Expand Down
43 changes: 43 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/modal.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Describe "Modal" {
Context "Show-UDModal" {
Set-TestDashboard -Content {
New-UDButton -Text "Show" -Id 'button' -OnClick {
Show-UDModal -Content {
New-UDElement -Tag 'div' -Id 'modal-content'
}
}
}

It "should open modal with new content" {
$Element = Find-SeElement -Driver $Driver -Id 'button'
Invoke-SeClick -Element $Element

Find-SeElement -Driver $Driver -Id 'modal-content' | Should not be $null
}
}

Context "Hide-UDModal" {
Set-TestDashboard -Content {
New-UDButton -Text "Show" -Id 'button' -OnClick {
Show-UDModal -Content {
New-UDElement -Tag 'div' -Id 'modal-content'
New-UDButton -OnClick { Hide-UDModal } -Text "Hide" -Id 'hide'
}
}
}

It "should dispose of content when hidden" {
$Element = Find-SeElement -Driver $Driver -Id 'button'
Invoke-SeClick -Element $Element

Find-SeElement -Driver $Driver -Id 'modal-content' | Should not be $null

$Element = Find-SeElement -Driver $Driver -Id 'hide'
Invoke-SeClick -Element $Element

Start-Sleep 1

Find-SeElement -Driver $Driver -Id 'modal-content' | Should be $null
}
}
}

0 comments on commit 9377e02

Please sign in to comment.