69 lines
1.9 KiB
Plaintext
69 lines
1.9 KiB
Plaintext
namespace Tests
|
|
|
|
@suite
|
|
class NavBarTests extends Rooibos.BaseTestSuite
|
|
|
|
@describe("NavBar")
|
|
|
|
@beforeEach
|
|
function _()
|
|
m.navBar = CreateObject("roSGNode", "NavBar")
|
|
m.navbar.appController = CreateObject("roSGNode", "AppController")
|
|
m.navBar@.BindNode()
|
|
end function
|
|
|
|
@it("Populates the buttons based on content node")
|
|
function _()
|
|
items = [
|
|
{
|
|
text: "Item1"
|
|
},
|
|
{
|
|
text: "Item2"
|
|
}
|
|
]
|
|
|
|
m.navBar.items = m.CreateContentNode(items)
|
|
|
|
buttonGroup = m.navBar.buttonGroup.getChildren(-1, 0)
|
|
|
|
m.assertArrayCount(buttonGroup, 2)
|
|
|
|
m.assertEqual(buttonGroup[0].text, "Item1")
|
|
m.assertEqual(buttonGroup[1].text, "Item2")
|
|
end function
|
|
|
|
@it("Clears the buttons when content node is invalid")
|
|
function _()
|
|
items = [
|
|
{
|
|
text: "Item1"
|
|
},
|
|
{
|
|
text: "Item2"
|
|
}
|
|
]
|
|
|
|
m.navBar.items = m.CreateContentNode(items)
|
|
buttonGroup = m.navBar.buttonGroup.getChildren(-1, 0)
|
|
m.assertArrayCount(buttonGroup, 2)
|
|
|
|
m.navBar.items = invalid
|
|
buttonGroup = m.navBar.buttonGroup.getChildren(-1, 0)
|
|
m.assertArrayCount(buttonGroup, 0)
|
|
end function
|
|
|
|
function CreateContentNode(items as object) as object
|
|
contentNode = CreateObject("roSGNode", "ContentNode")
|
|
for each item in items
|
|
navBarItem = CreateObject("roSGNode", "NavBarItem")
|
|
navBarItem.text = item.text
|
|
contentNode.appendChild(navBarItem)
|
|
end for
|
|
return contentNode
|
|
end function
|
|
|
|
end class
|
|
|
|
end namespace
|