Mercurial > hg > webaudioevaluationtool
comparison php/test.html @ 2930:8424c62a8c97
Inital implementation of #228
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 11 Sep 2017 17:10:13 +0100 |
parents | |
children | 465084b9c6dc |
comparison
equal
deleted
inserted
replaced
2929:270f20b2d68f | 2930:8424c62a8c97 |
---|---|
1 <html lang="en"> | |
2 | |
3 <head> | |
4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
5 | |
6 | |
7 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame | |
8 Remove this if you use the .htaccess --> | |
9 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
10 | |
11 <title>Web Audio Evaluation Tool</title> | |
12 <meta name="description" content="" /> | |
13 <meta name="author" content="" /> | |
14 | |
15 <!-- Load up the default core JS and CSS files--> | |
16 <link rel='stylesheet' type='text/css' href='../css/core.css'> | |
17 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.css" integrity="sha256-Flo6sV8k+IPfHh6Hx97ReUJDLOwIwvhdGlKOz3UgHRE=" crossorigin="anonymous" /> | |
18 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
19 <!-- Use jQuery hosted from Google CDN --> | |
20 <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>--> | |
21 <script type="text/javascript" src="../js/showdown.min.js"></script> | |
22 <script type="text/javascript" src="../js/jquery-2.1.4.js"></script> | |
23 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | |
24 <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js" integrity="sha256-iP6sMGdjKeRM2DuED2Lsi/n7MNTKhGpkhuSdCHXIgYc=" crossorigin="anonymous"></script> | |
25 <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.js" integrity="sha256-rw/35Nx9y5f+fLTdO7Tipm6ju+tRGwnplU1CJyPM3nE=" crossorigin="anonymous"></script> | |
26 <script> | |
27 mocha.setup('bdd'); | |
28 var expect = chai.expect; | |
29 var should = chai.should(); | |
30 var key1; | |
31 describe("requestKey.php", function() { | |
32 it("should give a key", function(done) { | |
33 var xhr = new XMLHttpRequest(); | |
34 xhr.open("GET", "requestKey.php"); | |
35 xhr.onload = function() { | |
36 var doc = xhr.response; | |
37 var state = doc.querySelector("state").textContent; | |
38 key1 = doc.querySelector("key").textContent; | |
39 expect(state).to.equal("OK"); | |
40 done(); | |
41 } | |
42 xhr.responseType = "document"; | |
43 xhr.send(); | |
44 }); | |
45 it("should give a different key on second request", function(done) { | |
46 var xhr = new XMLHttpRequest(); | |
47 xhr.open("GET", "requestKey.php"); | |
48 xhr.onload = function() { | |
49 var doc = xhr.response; | |
50 var state = doc.querySelector("state").textContent; | |
51 var key = doc.querySelector("key").textContent; | |
52 expect(key).not.to.equal(key1); | |
53 done(); | |
54 } | |
55 xhr.responseType = "document"; | |
56 xhr.send(); | |
57 }); | |
58 }); | |
59 describe("save.php", function() { | |
60 it("should return an empty file on empty payload", function(done) { | |
61 var xhr = new XMLHttpRequest(); | |
62 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests"); | |
63 xhr.onload = function() { | |
64 var doc = xhr.response; | |
65 var state = doc.querySelector("message").textContent; | |
66 var file = doc.querySelector("file"); | |
67 console.log("saves/save-" + key1 + ".xml"); | |
68 console.log(file); | |
69 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\""); | |
70 expect(file.getAttribute("bytes")).to.equal("0"); | |
71 expect(state).to.equal("OK"); | |
72 done(); | |
73 } | |
74 xhr.responseType = "document"; | |
75 xhr.send(); | |
76 }); | |
77 it("should return an URL on payload", function(done) { | |
78 var xhr = new XMLHttpRequest(); | |
79 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests"); | |
80 xhr.onload = function() { | |
81 var doc = xhr.response; | |
82 var state = doc.querySelector("message").textContent; | |
83 var file = doc.querySelector("file"); | |
84 console.log("saves/save-" + key1 + ".xml"); | |
85 console.log(file); | |
86 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\""); | |
87 expect(file.getAttribute("bytes")).not.to.equal("0"); | |
88 expect(state).to.equal("OK"); | |
89 done(); | |
90 } | |
91 xhr.responseType = "document"; | |
92 xhr.send("<xml></xml>"); | |
93 }); | |
94 }); | |
95 window.onload = function() { | |
96 mocha.run(); | |
97 } | |
98 | |
99 </script> | |
100 </head> | |
101 | |
102 <body class="container"> | |
103 <div> | |
104 <h1>WAET PHP Server Tests</h1> | |
105 <p class="lead">This page will test your PHP server for any implementation issues.</p> | |
106 | |
107 </div> | |
108 <div id="mocha"></div> | |
109 </body> | |
110 | |
111 </html> |