-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_website.html
132 lines (99 loc) · 3.49 KB
/
test_website.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit SnapChatBordeaux</title>
<link rel="stylesheet" href="css/qunit-1.14.0.css">
</head>
<body>
<!-- DIV FOR TESTING NAVBAR -->
<div id="homespan" hidden></div>
<div id="friendsspan" hidden></div>
<div id="settingsspan" hidden></div>
<div id="logoutspan" hidden></div>
<div id="aboutspan" hidden></div>
<!-- DIV FOR TESTING INDEX -->
<div id="signin" hidden></div>
<div id="signup" hidden></div>
<div id="description" hidden></div>
<!-- DIV FOR TESTING FOOTER -->
<div id="createb" hidden></div>
<div id="projetf" hidden></div>
<!-- DIV FOR TESTING REGISTER -->
<div id="txtHint" hidden></div>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="js/mock.js"></script>
<script src="js/xmlhttprequest.js"></script>
<script src="js/cookies.js"></script>
<script src="js/messages.js"></script>
<script src="js/qunit-1.14.0.js"></script>
<script src="js/website.js"></script>
</body>
<script>
module("testing of traductor");
var traductor = new Traductor('fr');
test( "testing of the navigation bar", function() {
traductor.tradNavBar();
equal('Accueil', document.getElementById('homespan').innerHTML);
equal('Amis', document.getElementById('friendsspan').innerHTML);
equal('Paramètres', document.getElementById('settingsspan').innerHTML);
equal('Déconnection', document.getElementById('logoutspan').innerHTML);
equal("À propos", document.getElementById('aboutspan').innerHTML);
notEqual('kelkechose', document.getElementById('homespan').innerHTML);
notEqual('Autre', document.getElementById('friendsspan').innerHTML);
});
test("testing of the index bar", function(){
traductor.tradIndex();
equal('Se connecter', document.getElementById('signin').innerHTML);
equal("S'enregistrer", document.getElementById('signup').innerHTML);
equal("Snap Chat Bordeaux est une application disponible en tant que site web mais également pour smartphones.", document.getElementById('description').innerHTML);
});
test("testing of the footer bar", function(){
traductor.tradFooter();
equal('Créé par', document.getElementById('createb').innerHTML);
equal("Projet pour l'Université de Bordeaux", document.getElementById('projetf').innerHTML);
notEqual("Snap Chat smartphones.", document.getElementById('createb').innerHTML);
});
</script>
<script>
// FUNCTION MOCKER POUR LES TESTS
var redirected = false;
function redirectToHomePage () {
redirected = true;
}
var listStatus ="not showed";
function getCookie (key) {
var map = {email : '[email protected]', password: 'pass'};
return map[key];
}
function showMessageList() {
listStatus = 'listShowed';
}
// FIN DES MOCK
module("testing of message.js");
//testing checksession()
test("test user is not connected", function () {
var server = new MockHttpServer();
server.handle = function (request) {
request.setResponseHeader("Content-Type", "application/robot");
request.receive(200, " You have written a wrong email or a wrong password. ");
};
server.start(); // start mocking xmlHttpRequest
checkSession (); //code to test
server.stop(); // stop mocking xmlHttpRequest
equal(redirected, true);
});
test("test user is connected and has messages", function () {
var server = new MockHttpServer();
server.handle = function (request) {
request.setResponseHeader("Content-Type", "application/robot");
request.receive(200, "");
};
server.start();
checkSession ();
server.stop();
equal('listShowed', listStatus);
});
</script>
</html>