Skip to content

Commit

Permalink
methods + tests for Grid.Column (part of #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Henri Kerola committed Jan 3, 2015
1 parent aaf114c commit 943c69b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
7 changes: 5 additions & 2 deletions addon/src/main/scala/vaadin/scala/Grid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ object Grid {

val p: com.vaadin.ui.Grid.Column

def propertyId: Any = p.getColumnProperty

def headerCaption: String = p.getHeaderCaption
def headerCaption_=(headerCaption: String): Unit = p.setHeaderCaption(headerCaption)

def width = p.getWidth
def width_=(pixelWidth: Int): Unit = p.setWidth(pixelWidth)
def width: Double = p.getWidth
def width_=(pixelWidth: Double): Unit = p.setWidth(pixelWidth)

def widthUndefined() = p.setWidthUndefined()

Expand Down
37 changes: 37 additions & 0 deletions addon/src/test/scala/vaadin/scala/tests/GridTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,44 @@ class GridTests extends ScaladinTestSuite {
Mockito.verify(spy).removeColumn("propertyId")
}

test("Column.propertyId") {
val column = grid.addColumn[String]("myColumn")

assert("myColumn" == column.propertyId)
}

test("Column.headerCaption") {
val column = grid.addColumn[String]("myColumn")
assert("My Column" == column.headerCaption)

column.headerCaption = "Header for Column"
assert("Header for Column" == column.headerCaption)
}

test("Column.width") {
val column = grid.addColumn[String]("myColumn")
assert(-1 == column.width)

column.width = 25.6
assert(25.6 == column.width)
}

test("Column.widthUndefined") {
val column = grid.addColumn[String]("myColumn")
column.width = 25.6

column.widthUndefined()
assert(-1 == column.width)
}

test("sortable") {
val column = grid.addColumn[String]("myColumn")

assert(column.sortable)

column.sortable = false
assert(!column.sortable)
}

// TODO tests for Grid.Column class

Expand Down

0 comments on commit 943c69b

Please sign in to comment.