Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
e1ff449b
Unverified
Commit
e1ff449b
authored
Jun 11, 2018
by
yann300
Committed by
GitHub
Jun 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1350 from ethereum/test-tab
Test tab
parents
00a94809
afb18496
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
84 deletions
+89
-84
test-tab.js
src/app/tabs/test-tab.js
+89
-84
No files found.
src/app/tabs/test-tab.js
View file @
e1ff449b
...
@@ -3,104 +3,109 @@ var async = require('async')
...
@@ -3,104 +3,109 @@ var async = require('async')
var
css
=
require
(
'./styles/test-tab-styles'
)
var
css
=
require
(
'./styles/test-tab-styles'
)
var
remixTests
=
require
(
'remix-tests'
)
var
remixTests
=
require
(
'remix-tests'
)
function
append
(
container
,
txt
)
{
module
.
exports
=
class
TestTab
{
let
child
=
yo
`<div>
${
txt
}
</div>`
constructor
(
api
=
{},
events
=
{},
opts
=
{})
{
container
.
appendChild
(
child
)
const
self
=
this
}
self
.
_opts
=
opts
self
.
_api
=
api
self
.
_events
=
events
self
.
_view
=
{
el
:
null
}
self
.
_components
=
{}
self
.
data
=
{}
function
testTabView
(
api
)
{
self
.
_view
.
el
=
self
.
render
()
var
container
=
yo
`<div class="tests" id="tests"></div>`
let
testCallback
=
function
(
result
)
{
events
.
app
.
register
(
'tabChanged'
,
tabName
=>
{
if
(
result
.
type
===
'contract'
)
{
if
(
tabName
!==
'test'
)
return
append
(
container
,
'
\
n '
+
result
.
value
)
yo
.
update
(
self
.
_view
.
el
,
self
.
render
())
}
else
if
(
result
.
type
===
'testPass'
)
{
self
.
_view
.
el
.
style
.
display
=
'block'
append
(
container
,
'
\
t✓ '
+
result
.
value
)
})
}
else
if
(
result
.
type
===
'testFailure'
)
{
append
(
container
,
'
\
t✘ '
+
result
.
value
)
}
}
let
resultsCallback
=
function
(
_err
,
result
,
cb
)
{
return
{
render
()
{
return
self
.
_view
.
el
}
}
// total stats for the test
// result.passingNum
// result.failureNum
// result.timePassed
cb
()
}
}
render
()
{
const
self
=
this
const
api
=
self
.
_api
var
container
=
yo
`<div class="tests" id="tests"></div>`
let
updateFinalResult
=
function
(
_err
,
resul
t
)
{
function
append
(
container
,
tx
t
)
{
if
(
result
.
totalPassing
>
0
)
{
let
child
=
yo
`<div>
${
txt
}
</div>`
append
(
container
,
(
' '
+
result
.
totalPassing
+
' passing '
)
+
(
'('
+
result
.
totalTime
+
's)'
)
)
container
.
appendChild
(
child
)
}
}
if
(
result
.
totalFailing
>
0
)
{
append
(
container
,
(
' '
+
result
.
totalFailing
+
' failing'
))
let
testCallback
=
function
(
result
)
{
if
(
result
.
type
===
'contract'
)
{
append
(
container
,
'
\
n '
+
result
.
value
)
}
else
if
(
result
.
type
===
'testPass'
)
{
append
(
container
,
'
\
t✓ '
+
result
.
value
)
}
else
if
(
result
.
type
===
'testFailure'
)
{
append
(
container
,
'
\
t✘ '
+
result
.
value
)
}
}
}
result
.
errors
.
forEach
((
error
,
index
)
=>
{
let
resultsCallback
=
function
(
_err
,
result
,
cb
)
{
append
(
container
,
' '
+
(
index
+
1
)
+
') '
+
error
.
context
+
' '
+
error
.
value
)
// total stats for the test
append
(
container
,
''
)
// result.passingNum
append
(
container
,
(
'
\
t error: '
+
error
.
message
))
// result.failureNum
})
// result.timePassed
}
cb
()
}
function
runTest
(
testFilePath
,
callback
)
{
let
updateFinalResult
=
function
(
_err
,
result
)
{
var
provider
=
api
.
fileProviderOf
(
testFilePath
)
if
(
result
.
totalPassing
>
0
)
{
provider
.
get
(
testFilePath
,
(
error
,
content
)
=>
{
append
(
container
,
(
' '
+
result
.
totalPassing
+
' passing '
)
+
(
'('
+
result
.
totalTime
+
's)'
))
if
(
!
error
)
{
var
runningTest
=
{}
runningTest
[
testFilePath
]
=
{
content
}
remixTests
.
runTestSources
(
runningTest
,
testCallback
,
resultsCallback
,
(
error
,
result
)
=>
{
updateFinalResult
(
error
,
result
)
callback
(
error
)
},
api
.
importFileCb
)
}
}
})
if
(
result
.
totalFailing
>
0
)
{
}
append
(
container
,
(
' '
+
result
.
totalFailing
+
' failing'
))
let
runTests
=
function
()
{
container
.
innerHTML
=
''
var
path
=
api
.
currentPath
()
var
tests
=
[]
api
.
filesFromPath
(
path
,
(
error
,
files
)
=>
{
if
(
!
error
)
{
for
(
var
file
in
files
)
{
if
(
/.
(
_test.sol
)
$/
.
exec
(
file
))
tests
.
push
(
path
+
file
)
}
async
.
eachOfSeries
(
tests
,
(
value
,
key
,
callback
)
=>
{
runTest
(
value
,
callback
)
})
}
}
})
}
return
yo
`
result
.
errors
.
forEach
((
error
,
index
)
=>
{
<div class="
${
css
.
testTabView
}
"id="testView">
append
(
container
,
' '
+
(
index
+
1
)
+
') '
+
error
.
context
+
' '
+
error
.
value
)
<div>
append
(
container
,
''
)
<div class="
${
css
.
infoBox
}
">
append
(
container
,
(
'
\
t error: '
+
error
.
message
))
</div>
})
</div>
}
<div class="
${
css
.
testList
}
">
<p><button onclick=
${
runTests
}
>Run Tests</button></p>
${
container
}
</div>
</div>
`
}
function
testTab
(
api
=
{},
events
=
{},
opts
=
{})
{
let
el
=
testTabView
(
api
)
let
gitterIsLoaded
=
false
events
.
app
.
register
(
'tabChanged'
,
(
tabName
)
=>
{
function
runTest
(
testFilePath
,
callback
)
{
if
(
tabName
!==
'test'
||
gitterIsLoaded
)
{
var
provider
=
api
.
fileProviderOf
(
testFilePath
)
return
provider
.
get
(
testFilePath
,
(
error
,
content
)
=>
{
if
(
!
error
)
{
var
runningTest
=
{}
runningTest
[
testFilePath
]
=
{
content
}
remixTests
.
runTestSources
(
runningTest
,
testCallback
,
resultsCallback
,
(
error
,
result
)
=>
{
updateFinalResult
(
error
,
result
)
callback
(
error
)
},
api
.
importFileCb
)
}
})
}
}
yo
.
update
(
el
,
testTabView
(
api
))
let
runTests
=
function
()
{
el
.
style
.
display
=
'block'
container
.
innerHTML
=
''
gitterIsLoaded
=
true
var
path
=
api
.
currentPath
()
})
var
tests
=
[]
api
.
filesFromPath
(
path
,
(
error
,
files
)
=>
{
if
(
!
error
)
{
for
(
var
file
in
files
)
{
if
(
/.
(
_test.sol
)
$/
.
exec
(
file
))
tests
.
push
(
path
+
file
)
}
async
.
eachOfSeries
(
tests
,
(
value
,
key
,
callback
)
=>
{
runTest
(
value
,
callback
)
})
}
})
}
return
{
render
()
{
return
el
}
}
var
el
=
yo
`
<div class="
${
css
.
testTabView
}
"id="testView">
<div>
<div class="
${
css
.
infoBox
}
">
</div>
</div>
<div class="
${
css
.
testList
}
">
<p><button onclick=
${
runTests
}
>Run Tests</button></p>
${
container
}
</div>
</div>
`
return
el
}
}
}
module
.
exports
=
testTab
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment