Skip to content

Commit

Permalink
Merge pull request #841 from ironmansoftware/fix-tests3
Browse files Browse the repository at this point in the history
Fix some tests.
  • Loading branch information
adamdriscoll authored May 29, 2019
2 parents 9d93b08 + 42038d1 commit b1e453b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 23 deletions.
18 changes: 15 additions & 3 deletions src/UniversalDashboard.Materialize/Scripts/layout.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
function New-UDLayout {
param(
[Parameter(Mandatory = $true)]
[ValidateRange(1, 12)]
[int]$Columns,
[Parameter(Mandatory = $true)]
[ScriptBlock]$Content
)

$Components = $Content.Invoke()
$LargeColumnSize = 12 / $Columns
$MediumColumnSize = 12 / $Columns
$SmallColumnSize = 12

if ($Columns -eq 1)
{
$LargeColumnSize = 12
$MediumColumnSize = 12
$SmallColumnSize = 12
}
else
{
$LargeColumnSize = 12 / $Columns
$MediumColumnSize = 12 / ($Columns / 2)
$SmallColumnSize = 12
}

$Offset = 0
$ComponentCount = ($Components | Measure-Object).Count

Expand Down
24 changes: 21 additions & 3 deletions src/UniversalDashboard.Materialize/Tests/layout.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,26 @@ Describe "New-UDLayout" {
New-UDCard -Title "Test" -Content {}
}

$Layout[0].Content[0].Attributes["className"].Contains("s12") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("m8") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("l4") | should be $true
it "should contain all sizes" {
$Layout[0].Content[0].Attributes["className"].Contains("s12") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("m8") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("l4") | should be $true
}

}

Context "should not show error when column set to 1" {
$Layout = New-UDLayout -Columns 1 -Content {
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
New-UDCard -Title "Test" -Content {}
}

it "should contain all sizes" {
$Layout[0].Content[0].Attributes["className"].Contains("s12") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("m12") | should be $true
$Layout[0].Content[0].Attributes["className"].Contains("l12") | should be $true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Describe "Auto reload" {

It "auto reloads" {

Start-Sleep 1
Start-Sleep 3

Invoke-RestMethod http://localhost:10001/api/user | should be "2"

Expand All @@ -84,7 +84,7 @@ Describe "Auto reload" {
$Server = Start-UDRestApi -Port 10001 -Endpoint $Endpoint -AutoReload
}.ToString().Replace('$ModulePath', "'$ModulePath'") | Out-File $tempFile -Force

Start-Sleep 1
Start-Sleep 3
Invoke-RestMethod http://localhost:10001/api/user | should be "1"
}

Expand Down
24 changes: 12 additions & 12 deletions src/UniversalDashboard.UITest/Integration/Grid.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Describe "Grid" {
$data = @(
[PSCustomObject]@{"day" = 1; jpg = $Variable; mp4= (New-UDLink -Text "This is text" -Url "http://www.google.com")}
[PSCustomObject]@{"day" = 2; jpg = "20"; mp4= (Get-Date -Day 2 -Month 12 -Year 2007)}
[PSCustomObject]@{"day" = 3; jpg = $true; mp4= (New-UDButton -Text "Hey" -OnClick{ Set-UDElement -Id "Hey" -Content {"Hey"}})}
[PSCustomObject]@{"day" = 3; jpg = $true; mp4= (New-UDButton -Id button -Text "Hey" -OnClick{ Set-UDElement -Id "Hey" -Content {"Hey"}})}
[PSCustomObject]@{"day" = 3; jpg = $true; mp4= (New-UDIcon -Icon check -Color Green)}
)

Expand All @@ -78,7 +78,7 @@ Describe "Grid" {
Set-TestDashboard -Dashboard $dashboard

It "should click button" {
$Button = Find-SeElement -LinkText "HEY" -Driver $Driver
$Button = Find-SeElement -Id "button" -Driver $Driver
Invoke-SeClick -Element $Button

Start-Sleep -Seconds 5
Expand Down Expand Up @@ -233,39 +233,39 @@ Describe "Grid" {

$Element = Find-SeElement -ClassName "griddle-row" -Driver $Driver
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Element[0]
$Element.Length | Should be 3
$Element[0].Text | should be "3"
$Element[1].Text | should be "30"
$Element[2].Text | should be "10"
$Element.Length | Should be 2
$Element[0].Text | should be "1"
$Element[1].Text | should be "10"
$Element[2].Text | should be "30"
}

It "should sort data" {

$Row = Find-SeElement -ClassName "griddle-row" -Driver $Driver
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[0]
$Element[0].Text | should be "3"
$Element[0].Text | should be "1"
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[1]
$Element[0].Text | should be "3"
$Element[0].Text | should be "1"

$Element = Find-SeElement -ClassName "griddle-table-heading-cell" -Driver $Driver
$header = $element[0]
Invoke-SeClick $header

$Row = Find-SeElement -ClassName "griddle-row" -Driver $Driver
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[0]
$Element[0].Text | should be "1"
$Element[0].Text | should be "3"
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[1]
$Element[0].Text | should be "1"
$Element[0].Text | should be "3"

$Element = Find-SeElement -ClassName "griddle-table-heading-cell" -Driver $Driver
$header = $element[0]
Invoke-SeClick $header

$Row = Find-SeElement -ClassName "griddle-row" -Driver $Driver
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[0]
$Element[0].Text | should be "3"
$Element[0].Text | should be "1"
$Element = Find-SeElement -ClassName "griddle-cell" -Driver $Row[1]
$Element[0].Text | should be "3"
$Element[0].Text | should be "1"
}

It "should filter data" {
Expand Down
2 changes: 1 addition & 1 deletion src/UniversalDashboard.UITest/Manifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Get-UDDashboard | Stop-UDDashboard
Describe "Manifest" {

It "should have correct version" {
(Get-Module 'UniversalDashboard.Community').Version | Should be "2.4.0"
(Get-Module 'UniversalDashboard.Community').Version | Should be "2.4.1"
}

It "should have correct exported commands" {
Expand Down
4 changes: 2 additions & 2 deletions src/UniversalDashboard/New-UDModuleManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param(

Remove-Item (Join-Path $outputDirectory 'UniversalDashboard.Community.psd1') -ErrorAction SilentlyContinue -Force

$version = "2.4.0"
$version = "2.4.1"
#$prerelease = "-beta2"

$ReleaseNotes = "
Expand All @@ -17,7 +17,7 @@ $manifestParameters = @{
Path = "$outputDirectory\UniversalDashboard.Community.psd1"
Author = "Adam Driscoll"
CompanyName = "Ironman Software, LLC"
Copyright = "2018 Ironman Software, LLC"
Copyright = "2019 Ironman Software, LLC"
RootModule = "UniversalDashboard.psm1"
Description = "Cross-platform module for developing websites and REST APIs."
ModuleVersion = $version
Expand Down

0 comments on commit b1e453b

Please sign in to comment.