comparison php/test.html @ 2934:260efd43fe52

#228
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 11 Sep 2017 17:41:40 +0100
parents 95f507064bf2
children
comparison
equal deleted inserted replaced
2933:95f507064bf2 2934:260efd43fe52
68 } 68 }
69 xhr.responseType = "document"; 69 xhr.responseType = "document";
70 xhr.send(); 70 xhr.send();
71 }); 71 });
72 }); 72 });
73 describe("save.php", function() { 73 describe("Saves permissions", function() {
74 it("should return an empty file on empty payload", function(done) { 74 it("should write \"test-save.xml\" to saves and delete", function(done) {
75 var xhr = new XMLHttpRequest(); 75 var xhr = new XMLHttpRequest();
76 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests"); 76 xhr.open("GET", "test_write.php");
77 xhr.onload = function() { 77 xhr.onload = function() {
78 var doc = xhr.response; 78 var doc = xhr.response;
79 var state = doc.querySelector("message").textContent; 79 var response = doc.querySelector("response");
80 var file = doc.querySelector("file"); 80 var message = doc.querySelector("message");
81 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\""); 81 expect(response.getAttribute("state")).to.equal("OK");
82 expect(file.getAttribute("bytes")).to.equal("0");
83 expect(state).to.equal("OK");
84 done(); 82 done();
85 } 83 }
86 xhr.responseType = "document"; 84 xhr.responseType = "document";
87 xhr.send(); 85 xhr.send();
88 });
89 it("should return a file on payload save", function(done) {
90 var xhr = new XMLHttpRequest();
91 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests");
92 xhr.onload = function() {
93 var doc = xhr.response;
94 var state = doc.querySelector("message").textContent;
95 var file = doc.querySelector("file");
96 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\"");
97 expect(file.getAttribute("bytes")).not.to.equal("0");
98 expect(state).to.equal("OK");
99 done();
100 }
101 xhr.responseType = "document";
102 xhr.send("<xml></xml>");
103 }); 86 });
104 }); 87 });
105 window.onload = function() { 88 window.onload = function() {
106 mocha.run(); 89 mocha.run();
107 } 90 }