Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
slapos.core
Commits
4d098c6b
Commit
4d098c6b
authored
Apr 11, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix last commit
Forgot to add modified files
parent
94b89ec8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
292 additions
and
76 deletions
+292
-76
jQuery/server.py
jQuery/server.py
+2
-6
jQuery/slapos.html
jQuery/slapos.html
+22
-8
jQuery/static/js/jquery-1.7.2.js
jQuery/static/js/jquery-1.7.2.js
+1
-1
jQuery/static/js/slapOs.js
jQuery/static/js/slapOs.js
+39
-11
jQuery/static/js/test.js
jQuery/static/js/test.js
+228
-50
No files found.
jQuery/server.py
View file @
4d098c6b
...
...
@@ -4,15 +4,11 @@ app = Flask(__name__)
@
app
.
route
(
'/'
)
def
index
():
return
"index"
@
app
.
route
(
'/test-mobile'
)
def
test
():
return
render_template
(
'test-mobile.html'
)
return
render_template
(
"slapos.html"
)
@
app
.
route
(
'/request'
,
methods
=
[
"POST"
,
"GET"
])
def
request
():
response
=
make_response
(
"HELLO"
,
40
9
)
response
=
make_response
(
"HELLO"
,
40
8
)
response
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
response
.
headers
[
'Access-Control-Allow-Methods'
]
=
'*'
return
response
...
...
jQuery/slapos.html
View file @
4d098c6b
...
...
@@ -3,14 +3,25 @@
<head>
<link
rel=
"stylesheet"
href=
"static/css/qunit.css"
type=
"text/css"
media=
"screen"
/>
<script
type=
"text/javascript"
src=
"static/js/jquery-1.7.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/modernizr-2.5.3.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/qunit.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/sinon-1.3.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/sinon-qunit-1.0.0.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/sinon-server-1.3.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/slapOs.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/test.js"
></script>
<title>
Test Slapos
</title>
</head>
<body>
<section>
<article>
<center>
<form
id=
"connect"
>
<label
for=
"login"
>
Test on a real server :
</label>
<input
type=
"text"
id=
"login"
name=
"login"
placeholder=
"Server url"
spellcheck=
"false"
required
autofocus=
"autofocus"
/>
<input
type=
"submit"
id=
"submit"
value=
"Go!"
/>
</form>
</center>
<div
class=
"container"
>
<h1
id=
"qunit-header"
>
QUnit SlapOs tests
</h1>
<h2
id=
"qunit-banner"
></h2>
...
...
@@ -19,4 +30,7 @@
<ol
id=
"qunit-tests"
></ol>
<div
id=
"qunit-fixture"
>
test markup, will be hidden
</div>
</div>
</article>
</section>
</body>
\ No newline at end of file
jQuery/static/js/jquery-1.7.2.js
View file @
4d098c6b
...
...
@@ -7420,6 +7420,7 @@ jQuery.extend({
if
(
state
===
2
)
{
if
(
!
responseHeaders
)
{
responseHeaders
=
{};
console
.
log
(
responseHeadersString
);
while
(
(
match
=
rheaders
.
exec
(
responseHeadersString
)
)
)
{
responseHeaders
[
match
[
1
].
toLowerCase
()
]
=
match
[
2
];
}
...
...
@@ -7483,7 +7484,6 @@ jQuery.extend({
response
=
responses
?
ajaxHandleResponses
(
s
,
jqXHR
,
responses
)
:
undefined
,
lastModified
,
etag
;
// If successful, handle type chaining
if
(
status
>=
200
&&
status
<
300
||
status
===
304
)
{
...
...
jQuery/static/js/slapOs.js
View file @
4d098c6b
(
function
(
window
,
$
)
{
;(
function
(
$
,
window
,
document
,
undefined
)
{
var
SlapOs
=
function
(
elem
,
options
){
this
.
elem
=
elem
;
this
.
$elem
=
$
(
elem
);
...
...
@@ -7,25 +7,52 @@
};
SlapOs
.
prototype
=
{
host
:
''
,
defaults
:
{
host
:
''
},
init
:
function
(){
this
.
config
=
$
.
extends
({},
this
.
defaults
,
this
.
options
,
this
.
metadata
);
this
.
config
=
$
.
extend
({},
this
.
defaults
,
this
.
options
,
this
.
metadata
);
this
.
store
=
Modernizr
.
localstorage
?
this
.
lStore
:
this
.
cStore
;
this
.
store
(
'
host
'
,
this
.
config
.
host
);
return
this
;
},
/* Local storage method */
lStore
:
function
(
name
,
value
){
if
(
Modernizr
.
localstorage
)
return
value
==
undefined
?
window
.
localStorage
[
name
]
:
window
.
localStorage
[
name
]
=
value
;
return
false
;
},
/* Cookie storage method */
cStore
:
function
(
name
,
value
){
if
(
value
!=
undefined
){
document
.
cookie
=
name
+
"
=
"
+
value
+
"
;domain=
"
+
window
.
location
.
hostname
+
"
;path=
"
+
window
.
location
.
pathname
;
}
else
{
var
i
,
x
,
y
,
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
i
=
0
;
i
<
cookies
.
length
;
i
++
){
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
if
(
x
==
name
)
return
unescape
(
y
);
}
}
},
request
:
function
(
type
,
url
,
callback
,
data
){
data
=
data
||
''
;
return
$
.
ajax
({
url
:
this
.
host
+
url
,
$
.
ajax
({
url
:
this
.
config
.
host
+
url
,
dataType
:
'
json
'
,
data
:
data
,
context
:
this
.
$elem
,
type
:
type
,
statusCode
:
{
409
:
function
(){
console
.
log
(
'
Status Code : 409
'
)},
}).
done
(
callback
).
fail
(
this
.
failCallback
);
},
success
:
function
(
data
){
callback
(
data
);
}
});
failCallback
:
function
(
jqXHR
,
textStatus
){
//console.log(jqXHR);
},
newInstance
:
function
(
data
,
callback
){
...
...
@@ -84,4 +111,5 @@
};
window
.
SlapOs
=
SlapOs
;
})(
window
,
jQuery
);
\ No newline at end of file
})(
jQuery
,
window
,
document
);
\ No newline at end of file
jQuery/static/js/test.js
View file @
4d098c6b
$
(
function
(){
module
(
"
Instance & Computer Methods Tests
"
,
{
var
h
=
getParameterByName
(
"
login
"
);
var
slap
=
new
SlapOs
(
document
,
{
host
:
h
}).
init
();
module
(
"
Ajax Tests
"
,
{
setup
:
function
(){
this
.
server
=
sinon
.
sandbox
.
useFakeServer
();
this
.
header
=
{
"
Content-Type
"
:
"
application/json; charset=utf-8
"
};
this
.
error
=
[
409
,
this
.
header
,
''
]
this
.
slap
=
new
SlapOs
();
this
.
error
=
[
409
,
this
.
header
,
'
ERROR
'
];
},
tear
D
own
:
function
(){
tear
d
own
:
function
(){
this
.
server
.
restore
();
}
});
test
(
"
Requesting a new instance
- Success Response
"
,
function
(){
test
(
"
Requesting a new instance
"
,
function
(){
expect
(
2
);
callback
=
this
.
spy
();
...
...
@@ -20,25 +22,23 @@ $(function(){
response
=
[
201
,
this
.
header
,
JSON
.
stringify
(
responseBody
)];
this
.
server
.
respondWith
(
"
POST
"
,
"
/request
"
,
response
);
data
=
'
{"title": "My unique instance","software_release": "http://example.com/example.cfg","software_type": "type_provided_by_the_software","slave": False,"status": "started","sla": {"computer_id": "COMP-0"}
'
;
this
.
slap
.
newInstance
(
data
,
callback
);
slap
.
newInstance
(
''
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback
call
"
);
ok
(
callback
.
calledWith
(
responseBody
),
'
callback check right parameters
'
);
ok
(
callback
.
calledOnce
,
"
callback
should be called
"
);
ok
(
callback
.
calledWith
(
responseBody
),
'
should return mainly id and status of an instance
'
);
});
test
(
"
Requesting a new instance - Fail
Response
"
,
function
(){
test
(
"
Requesting a new instance - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
POST
"
,
"
/request
"
,
this
.
error
);
data
=
'
{"title": "My unique instance","software_release": "http://example.com/example.cfg","software_type": "type_provided_by_the_software","slave": False,"status": "started","sla": {"computer_id": "COMP-0"}
'
;
this
.
slap
.
newInstance
(
data
,
callback
);
slap
.
newInstance
(
''
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback
not call
"
);
ok
(
!
callback
.
calledOnce
,
"
callback
should not be called
"
);
});
test
(
"
Deleting an instance
"
,
function
(){
...
...
@@ -48,36 +48,86 @@ $(function(){
response
=
[
202
,
this
.
header
,
''
];
this
.
server
.
respondWith
(
"
DELETE
"
,
/
\/
instance
\/(\w
+
)
/
,
response
);
this
.
slap
.
deleteInstance
(
'
id
'
,
callback
);
slap
.
deleteInstance
(
'
id
'
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Get instance information
"
,
function
(){
test
(
"
Deleting an instance - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
response
=
[
200
,
this
.
header
,
''
];
this
.
server
.
respondWith
(
"
DELETE
"
,
/
\/
instance
\/(\w
+
)
/
,
this
.
error
);
slap
.
deleteInstance
(
'
id
'
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Get instance information
"
,
function
(){
expect
(
2
);
callback
=
this
.
spy
();
responseBody
=
[{
instance_id
:
"
anId
"
,
status
:
"
start
"
,
software_release
:
"
http://example.com/example.cfg
"
,
software_type
:
"
type_provided_by_the_software
"
,
slave
:
"
False
"
,
connection
:
{
custom_connection_parameter_1
:
"
foo
"
,
custom_connection_parameter_2
:
"
bar
"
},
parameter
:
{
Custom1
:
"
one string
"
,
Custom2
:
"
one float
"
,
Custom3
:
[
"
abc
"
,
"
def
"
],},
sla
:
{
computer_id
:
"
COMP-0
"
,},
children_id_list
:
[
"
subinstance1
"
,
"
subinstance2
"
],
partition
:
{
public_ip
:
[
"
::1
"
,
"
91.121.63.94
"
],
private_ip
:
[
"
127.0.0.1
"
],
tap_interface
:
"
tap2
"
,},}];
response
=
[
200
,
this
.
header
,
JSON
.
stringify
(
responseBody
)];
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
instance
\/(\w
+
)
/
,
response
);
this
.
slap
.
getInstance
(
'
id
'
,
callback
);
slap
.
getInstance
(
'
id
'
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback should be call
"
);
ok
(
callback
.
calledWith
(
responseBody
),
"
should return informations of an instance
"
);
});
test
(
"
Get instance
authentication certificates
"
,
function
(){
test
(
"
Get instance
information - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
response
=
[
200
,
this
.
header
,
''
];
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
instance
\/(\w
+
)
/
,
this
.
error
);
slap
.
getInstance
(
'
id
'
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Get instance authentication certificates
"
,
function
(){
expect
(
2
);
callback
=
this
.
spy
();
responseBody
=
[{
ssl_key
:
"
-----BEGIN PRIVATE KEY-----
\n
MIIEvgIBADAN...h2VSZRlSN
\n
-----END PRIVATE KEY-----
"
,
ssl_certificate
:
"
-----BEGIN CERTIFICATE-----
\n
MIIEAzCCAuugAwIBAgICHQI...ulYdXJabLOeCOA=
\n
-----END CERTIFICATE-----
"
,}];
response
=
[
200
,
this
.
header
,
JSON
.
stringify
(
responseBody
)];
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
instance
\/(\w
+
)\/
certificate/
,
response
);
this
.
slap
.
getInstanceCert
(
'
id
'
,
callback
);
slap
.
getInstanceCert
(
'
id
'
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback call
"
);
ok
(
callback
.
calledWith
(
responseBody
));
});
test
(
"
Get instance authentication certificates - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
instance
\/(\w
+
)\/
certificate/
,
this
.
error
);
slap
.
getInstanceCert
(
'
id
'
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Bang instance
"
,
function
(){
...
...
@@ -85,13 +135,25 @@ $(function(){
callback
=
this
.
spy
();
response
=
[
200
,
this
.
header
,
''
];
this
.
server
.
respondWith
(
"
GE
T
"
,
/
\/
instance
\/(\w
+
)\/
bang/
,
response
);
this
.
server
.
respondWith
(
"
POS
T
"
,
/
\/
instance
\/(\w
+
)\/
bang/
,
response
);
data
=
''
;
this
.
slap
.
bangInstance
(
'
id
'
,
data
,
callback
);
slap
.
bangInstance
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Bang instance - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
instance
\/(\w
+
)\/
bang/
,
this
.
error
);
slap
.
bangInstance
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Modifying instance
"
,
function
(){
...
...
@@ -102,38 +164,84 @@ $(function(){
this
.
server
.
respondWith
(
"
PUT
"
,
/
\/
instance
\/(\w
+
)
/
,
response
);
data
=
''
;
this
.
slap
.
editInstance
(
'
id
'
,
data
,
callback
);
slap
.
editInstance
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Modifying instance - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
PUT
"
,
/
\/
instance
\/(\w
+
)
/
,
this
.
error
);
slap
.
editInstance
(
'
id
'
,
''
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Register a new computer
"
,
function
(){
expect
(
2
);
callback
=
this
.
spy
();
responseBody
=
[{
computer_id
:
"
COMP-0
"
,
ssl_key
:
"
-----BEGIN PRIVATE KEY-----
\n
MIIEvgIBADAN...h2VSZRlSN
\n
-----END PRIVATE KEY-----
"
,
ssl_certificate
:
"
-----BEGIN CERTIFICATE-----
\n
MIIEAzCCAuugAwIBAgICHQI...ulYdXJabLOeCOA=
\n
-----END CERTIFICATE-----
"
,}];
response
=
[
201
,
this
.
header
,
JSON
.
stringify
(
responseBody
)];
this
.
server
.
respondWith
(
"
POST
"
,
"
/computer
"
,
response
);
slap
.
newComputer
(
''
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
ok
(
callback
.
calledWith
(
responseBody
),
"
should return a computerID, ssl key and ssl certificates
"
);
});
test
(
"
Register a new computer - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
response
=
[
201
,
this
.
header
,
''
];
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer/
,
response
);
this
.
server
.
respondWith
(
"
POST
"
,
"
/computer
"
,
this
.
error
);
data
=
''
;
this
.
slap
.
newComputer
(
data
,
callback
);
slap
.
newComputer
(
''
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Getting computer information
"
,
function
(){
expect
(
1
);
expect
(
2
);
callback
=
this
.
spy
();
response
=
[
200
,
this
.
header
,
''
];
responseBody
=
[{
computer_id
:
"
COMP-0
"
,
software
:
[{
software_release
:
"
http://example.com/example.cfg
"
,
status
:
"
install
"
},],
partition
:
[{
title
:
"
slapart1
"
,
instance_id
:
"
foo
"
,
status
:
"
start
"
,
software_release
:
"
http://example.com/example.cfg
"
},
{
title
:
"
slapart2
"
,
instance_id
:
"
bar
"
,
status
:
"
stop
"
,
software_release
:
"
http://example.com/example.cfg
"
},],}];
response
=
[
200
,
this
.
header
,
JSON
.
stringify
(
responseBody
)];
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
computer
\/(\w
+
)
/
,
response
);
data
=
''
;
this
.
slap
.
getComputer
(
'
id
'
,
callback
);
slap
.
getComputer
(
'
id
'
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
ok
(
callback
.
calledWith
(
responseBody
),
"
should return informations of a computer
"
);
});
test
(
"
Getting computer information - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
GET
"
,
/
\/
computer
\/(\w
+
)
/
,
this
.
error
);
slap
.
getComputer
(
'
id
'
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Modifying computer
"
,
function
(){
...
...
@@ -144,10 +252,22 @@ $(function(){
this
.
server
.
respondWith
(
"
PUT
"
,
/
\/
computer
\/(\w
+
)
/
,
response
);
data
=
''
;
this
.
slap
.
editComputer
(
'
id
'
,
data
,
callback
);
slap
.
editComputer
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Modifying computer - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
PUT
"
,
/
\/
computer
\/(\w
+
)
/
,
this
.
error
);
slap
.
editComputer
(
'
id
'
,
''
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Supplying new software
"
,
function
(){
...
...
@@ -158,10 +278,22 @@ $(function(){
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
supply/
,
response
);
data
=
''
;
this
.
slap
.
newSoftware
(
'
computerId
'
,
data
,
callback
);
slap
.
newSoftware
(
'
computerId
'
,
data
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Supplying new software - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
supply/
,
this
.
error
);
slap
.
newSoftware
(
'
computerId
'
,
''
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Bang computer
"
,
function
(){
...
...
@@ -172,10 +304,22 @@ $(function(){
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
bang/
,
response
);
data
=
''
;
this
.
slap
.
bangComputer
(
'
id
'
,
data
,
callback
);
slap
.
bangComputer
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
ok
(
callback
.
calledOnce
,
"
callback should be called
"
);
});
test
(
"
Bang computer - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
bang/
,
this
.
error
);
slap
.
bangComputer
(
'
id
'
,
''
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
test
(
"
Report computer usage
"
,
function
(){
...
...
@@ -186,9 +330,43 @@ $(function(){
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
report/
,
response
);
data
=
''
;
this
.
slap
.
newComputer
(
'
id
'
,
data
,
callback
);
slap
.
computerReport
(
'
id
'
,
data
,
callback
);
this
.
server
.
respond
();
equal
(
1
,
this
.
server
.
requests
.
length
,
'
A request has been sent
'
);
ok
(
callback
.
calledOnce
,
"
callback call
"
);
});
test
(
"
Report computer usage - Fail
"
,
function
(){
expect
(
1
);
callback
=
this
.
spy
();
this
.
server
.
respondWith
(
"
POST
"
,
/
\/
computer
\/(\w
+
)\/
report/
,
this
.
error
);
slap
.
computerReport
(
'
id
'
,
''
,
callback
);
this
.
server
.
respond
();
ok
(
!
callback
.
calledOnce
,
"
callback should not be called
"
);
});
module
(
"
Common Tests
"
);
test
(
"
Check if host has been saved
"
,
function
(){
newS
=
new
SlapOs
(
document
,
{
host
:
"
http://foo.com
"
}).
init
();
equal
(
newS
.
store
(
'
host
'
),
"
http://foo.com
"
,
"
should contains host whatever is the method
"
)
});
test
(
"
Modifying host after initialisation at start
"
,
function
(){
newS
=
new
SlapOs
(
document
,
{
host
:
"
http://foo.com
"
}).
init
();
newS
.
store
(
'
host
'
,
'
http://examples.com
'
);
equal
(
newS
.
store
(
'
host
'
),
"
http://examples.com
"
,
"
should contains modified host
"
)
});
});
function
getParameterByName
(
name
){
name
=
name
.
replace
(
/
[\[]
/
,
"
\\\
[
"
).
replace
(
/
[\]]
/
,
"
\\\
]
"
);
var
regexS
=
"
[
\\
?&]
"
+
name
+
"
=([^&#]*)
"
;
var
regex
=
new
RegExp
(
regexS
);
var
results
=
regex
.
exec
(
window
.
location
.
search
);
if
(
results
==
null
)
return
""
;
else
return
decodeURIComponent
(
results
[
1
].
replace
(
/
\+
/g
,
"
"
));
}
\ No newline at end of file
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