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
87a7f9fb
Commit
87a7f9fb
authored
Feb 02, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor runTests
parent
0971b101
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
testRunner.js
src/testRunner.js
+18
-4
testRunner.js
tests/testRunner.js
+4
-4
No files found.
src/testRunner.js
View file @
87a7f9fb
var
async
=
require
(
'async'
)
var
async
=
require
(
'async'
)
var
changeCase
=
require
(
'change-case'
)
var
changeCase
=
require
(
'change-case'
)
function
runTest
(
testName
,
testObject
,
testCallback
,
resultsCallback
)
{
function
getAvailableFunctions
(
jsonInterface
)
{
let
runList
=
[]
return
jsonInterface
.
reverse
().
filter
((
x
)
=>
x
.
type
===
'function'
).
map
((
x
)
=>
x
.
name
)
}
function
getTestFunctions
(
jsonInterface
)
{
let
specialFunctions
=
[
'beforeAll'
,
'beforeEach'
]
let
specialFunctions
=
[
'beforeAll'
,
'beforeEach'
]
let
availableFunctions
=
testObject
.
_jsonInterface
.
reverse
().
filter
((
x
)
=>
x
.
type
===
'function'
).
map
((
x
)
=>
x
.
name
)
return
jsonInterface
.
filter
((
x
)
=>
specialFunctions
.
indexOf
(
x
.
name
)
<
0
&&
x
.
type
===
'function'
)
let
testFunctions
=
testObject
.
_jsonInterface
.
filter
((
x
)
=>
specialFunctions
.
indexOf
(
x
.
name
)
<
0
&&
x
.
type
===
'function'
)
}
function
createRunList
(
jsonInterface
)
{
let
availableFunctions
=
getAvailableFunctions
(
jsonInterface
)
let
testFunctions
=
getTestFunctions
(
jsonInterface
)
let
runList
=
[]
if
(
availableFunctions
.
indexOf
(
'beforeAll'
)
>=
0
)
{
if
(
availableFunctions
.
indexOf
(
'beforeAll'
)
>=
0
)
{
runList
.
push
({
name
:
'beforeAll'
,
type
:
'internal'
,
constant
:
false
})
runList
.
push
({
name
:
'beforeAll'
,
type
:
'internal'
,
constant
:
false
})
...
@@ -18,6 +26,12 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
...
@@ -18,6 +26,12 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
runList
.
push
({
name
:
func
.
name
,
type
:
'test'
,
constant
:
func
.
constant
})
runList
.
push
({
name
:
func
.
name
,
type
:
'test'
,
constant
:
func
.
constant
})
}
}
return
runList
}
function
runTest
(
testName
,
testObject
,
testCallback
,
resultsCallback
)
{
let
runList
=
createRunList
(
testObject
.
_jsonInterface
)
let
passingNum
=
0
let
passingNum
=
0
let
failureNum
=
0
let
failureNum
=
0
let
timePassed
=
0
let
timePassed
=
0
...
...
tests/testRunner.js
View file @
87a7f9fb
...
@@ -51,8 +51,8 @@ describe('testRunner', function () {
...
@@ -51,8 +51,8 @@ describe('testRunner', function () {
it
(
'should returns 3 messages'
,
function
()
{
it
(
'should returns 3 messages'
,
function
()
{
assert
.
deepEqual
(
tests
,
[
assert
.
deepEqual
(
tests
,
[
{
type
:
'contract'
,
value
:
'MyTest'
},
{
type
:
'contract'
,
value
:
'MyTest'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
,
time
:
1
},
{
type
:
'testFailure'
,
value
:
'Initial value should be200'
}
{
type
:
'testFailure'
,
value
:
'Initial value should be200'
,
time
:
1
}
])
])
})
})
})
})
...
@@ -85,8 +85,8 @@ describe('testRunner', function () {
...
@@ -85,8 +85,8 @@ describe('testRunner', function () {
it
(
'should returns 3 messages'
,
function
()
{
it
(
'should returns 3 messages'
,
function
()
{
assert
.
deepEqual
(
tests
,
[
assert
.
deepEqual
(
tests
,
[
{
type
:
'contract'
,
value
:
'MyTest'
},
{
type
:
'contract'
,
value
:
'MyTest'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
,
time
:
1
},
{
type
:
'testPass'
,
value
:
'Initial value should be200'
}
{
type
:
'testPass'
,
value
:
'Initial value should be200'
,
time
:
1
}
])
])
})
})
})
})
...
...
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