Skip to content

Commit

Permalink
chore(tests): Adds node test to framework suite, and also improves th…
Browse files Browse the repository at this point in the history
…e file structure to include placeholder files, so as to better conform with brighterscript compiler
  • Loading branch information
georgejecook committed May 21, 2020
1 parent c4277d6 commit f23b81d
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 5 deletions.
15 changes: 15 additions & 0 deletions frameworkTests/components/NodeExample.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function Init() as void
m.nameText = m.top.findNode("nameText")
end function

function HelloFromNode(name, age) as string
return "HELLO " + name + " age:" + stri(age)
end function

function UpdateState(newState) as void
m.top.state = newState
end function

function SetLabelText(newText) as void
m.nameText.text = newText
end function
31 changes: 31 additions & 0 deletions frameworkTests/components/NodeExample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<component
name="NodeExample"
extends="Group"
>
<interface>
<!-- public fields/functions -->
<field
type="string"
id="state" />
</interface>

<script
type="text/brightscript"
uri="NodeExample.brs" />


<children>
<Label
id="nameText"
text="name" />

<Button
id="button1"
text="button1" />
<Button
id="button2"
text="button2" />
</children>

</component>
16 changes: 12 additions & 4 deletions frameworkTests/components/TestsScene.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<?xml version='1.0' encoding='UTF-8' ?>
<?xml version="1.0" encoding="UTF-8" ?>
<component
name='TestsScene'
extends='Scene'>
name="TestsScene"
extends="Scene">
<script
type="text/brightscript"
uri="pkg:/source/rooibosFunctionMap.brs" />
<script
type="text/brightscript"
uri="pkg:/source/tests/rooibosDist.brs" />

<interface>
<function name="Rooibos_CreateTestNode"/>
</interface>
<children>
<LayoutGroup>
<Label text='Rooibos tests are running' />
<Label text="Rooibos tests are running" />
</LayoutGroup>
</children>
</component>
24 changes: 24 additions & 0 deletions frameworkTests/components/tests/NodeExampleTests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<component
name="NodeExampleTests"
extends="NodeExample"
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
>
<interface>
<!-- public fields/functions -->
<!-- <function name="Rooibos_RunNodeTests" /> -->
</interface>

<script
type="text/brightscript"
uri="pkg:/source/tests/NodeExampleTests.brs" />

<script
type="text/brightscript"
uri="pkg:/source/rooibosFunctionMap.brs" />

<script
type="text/brightscript"
uri="pkg:/source/tests/rooibosDist.brs" />

</component>
36 changes: 36 additions & 0 deletions frameworkTests/source/tests/NodeExampleTests.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'@SGNode NodeExampleTests
'@TestSuite [NET] Node Example Tests

'@Setup
function NET_setup() as void
m.setupThing = "something created during setup"
end function

'@Only
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests methods present on the node
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@BeforeEach
function NET_BeforeEach() as void
m.beforeEachThing = "something created beforeEach"
end function

'@Test HelloFromNode
function NET__HelloFromNode_simple() as void
text = HelloFromNode("georgejecook", 12)
m.AssertEqual(text, "HELLO georgejecook" + " age:" + stri(12))
end function

'@Test HelloFromNode with params
'@Params["jon", 40]
'@Params["ringo", 23]
'@Params["ringo", 50]
'@Params["ringo", 24]
'@Params["george", 40]
'@Params["paul", 50]
function NET__HelloFromNode_params(name, age) as void
text = HelloFromNode(name, age)
m.AssertEqual(text, "HELLO " + name + " age:" + stri(age))
end function

1 change: 1 addition & 0 deletions frameworkTests/source/tests/rooibosFunctoinMap.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'replaced at build time
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>
<interface>
<!-- public fields/functions -->
<function name="Rooibos_RunNodeTests" />
<!-- <function name="Rooibos_RunNodeTests" /> -->
</interface>

<script
Expand Down
1 change: 1 addition & 0 deletions samples/example/source/tests/specs/NodeExampleTests.brs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function NET_setup() as void
m.setupThing = "something created during setup"
end function

'@Only
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests methods present on the node
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down

0 comments on commit f23b81d

Please sign in to comment.