-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
354 lines (334 loc) · 15 KB
/
index.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!DOCTYPE html>
<html>
<head>
<title>
Javascript Testing
</title>
<!-- All meta Tags-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Tweeter Tweets"/>
<meta property="og:site_name" content="Tweeter tweet extracter"/>
<meta property="og:url" content="http://" />
<meta property="og:description" content="Get all the tweets that is retweeted and has #custserv"/>
<meta property="og:type" content="website" />
<meta property="article:author" content="https://www.facebook.com/mjarpitanand" />
<meta property="og:image" content="http://" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<!--End of all the Meta tags-->
<link rel="shortcut icon" href="resources/img/favicon.ico" type="image/x-icon">
<!--All icons-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
<!--End of the all icons-->
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<!-- All css-->
<link rel="stylesheet" href="vendors/css/bootstrap.css"/>
<link rel="stylesheet" href="resources/css/init.css"/>
<link rel="stylesheet" href="resources/css/main.css"/>
<!--End of All css-->
<!-- All Js-->
<script src="vendors/js/jquery.min.js"></script>
<script src="vendors/js/bootstrap.js"></script>
<script src="resources/js/script.js"></script>
<script src="resources/js/init.js"></script>
<!--End of All Js-->
</head>
<body id="body">
<!--End of the preloader html-->
<!--Header of the website-->
<header>
<div class="row">
<div class="col">
<div class="bar" id="menu" onclick="toggle()">
<i class="fa fa-bars"></i>
</div>
<div class="right">
<p class="tag">Technical Blog Writing</p>
</div>
</div>
</div>
</header>
<!--End Of Header of the website-->
<br /><br/>
<!--Break tags-->
<!--Whole Wrapper-->
<div id="wrapper">
<!--Side Nav-->
<div id="sidebar-wrapper">
<br /><br /><br /><br />
<div class="close1" onclick="toggle_close1()"><i class="fa fa-close fa-lg"></i></div>
<br /><br />
<ul class="sidebar-nav">
<li>
<a href="index.html">Javascript Testing</a>
</li>
<br/>
</ul>
</div>
</div>
<!--End of sidenav HTML-->
<!--Post Appended here-->
<div id="page-content-wrapper">
<br /><br />
<div class="head">
<br />
<div class="breadcrumbs">
<ol class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Technical Blog</a></li>
<li class="active">Javascript Testing</li>
</ol>
</div>
<center>
<p class="head-tag">Javascript Testing</p>
</center>
</div>
<br /><br />
<div class="section">
<div class="subtopic">
Introduction
</div>
<br /><br />
<p class="subtopic-det">
Working in the production environment, there is no scope of the error ,Error and non-tested modules can
destroy the features of the application and affect the performance.
<br/>
Obviously, We don't want our product to break.
</p>
<br/>
<blockquote id="blockquote">
In simple way, we test our application by Refresh,click, PlayAround to test our application and test until the
product is working.
</blockquote>
</div>
<br/>
<p class="subtopic-det">
But this process is slow and inaccurate, and need a standard method so that a method is followed.
<br /><br />
<ul class="subtopic-list">
<li><p>We write unit tests, suits of function and check functionality.</p></li>
<li><p>We need to make Test-driven Development.</p></li>
<li><p>Write the test first,and then write features itself.</p></li>
</ul>
<br /><br />
<p class="subtopic">What is Test?</p>
<br />
<p class="subtopic-det">We can define <span class="bold">Test</span> as validating the software according to the expectation.</p>
<br />
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img class="media-object" src="resources/img/aero.jpg" alt="Aeroplane Image">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Fun Fact:</h4>
<br/><br />
<p class="subtopic-det">Boeing 747, has more than 170 miles of wires and has complex system, functionality.
Navigating, pressure, Air quality everything is tested. So, A number of test is performed.
<br />
Test on the wings done till it breaks the wings
<br />
<br/>
<p class="subtopic-det well">Faliure is the only option for the testing here.</p>
</div>
</div>
<br /><br />
<p class="subtopic-det" id="blockquote">
In our school days, we used to appear on various exams, Second apporach is that Teacher is testing how they have
teaching the students.
<br /><br />
In analog, we can say that faliure app, finding bug, till the software is running in correct way.
</p>
<br /><br />
<div class="subtopic">
Example:
</div>
<br />
<p class="cmd">
function add(x,y)
<br />
{
<br />
return x + y;
<br />
}
<br /><br />
add(2 , 3); // Let say we want Int Add and excepting 5.
</p>
<br />
<p class="well subtopic-det">
Test Case 1: Is the calling function is there or not.
<br/><br />
Test Case 2: Is the passing argument is '2' , '3' string then output is 23.
<br /><br />
Test Case 3: If floating number is passes as 0.1 , 0.2 is 0.300004.
</p>
<br /><br />
<p class="subtopic alert alert">
Refactor the add function,<span class="bold">Using Red Green Refactor Cycle.</span>
</p>
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img class="media-object" src="resources/img/rec.png" alt="Aeroplane Image">
</a>
</div>
<div class="media-body">
<br/><br />
<h4 class="media-heading">Expectations:</h4>
<br/>
<p class="subtopic-det">
<p style="color:green;"><i class="fa fa-check-square-o"></i> 2 + 3 = 5. </p>
<br />
<p style="color:red;"><i class="fa fa-window-close"></i> Error, if string passed. </p>
<br />
<p style="color:red;"><i class="fa fa-window-close"></i> 0.1 + 0.2 = 0.3 </p>
<br />
</div>
</div>
<br />
<p class="subtopic-det">Below the refactored codes:</p>
<br />
<div class="cmd">
function add(x , y ){
<br /><br />
if(typeof(x) && typeof(y) !== 'number'){
<br /><br />
throw new Error('Invalid Integer Number');
<br /><br />
}
<br /><br />
result = x + y;
<br /><br />
if(parseInt(result) !== result){
<br /><br />
result = parseFloat(result).toFixed(1);
<br /><br />
}
<br /><br />
return result;
<br/><br />
}
</div>
<br />
<p class="subtopic-det">Conclusion:</p>
<br />
<p id="blockquote">We can write expect(add(0.1 , 0.2).toBe(0.3))</p>
<br />
<br />
<p class="subtopic">Intoduction to Jasmine</p>
<br />
<p class="subtopic-det">Jasmine is a unit-testing framework, run on any javascript-enabled platform, testing javascript codes.
<br /><br />
<i class="fa fa-check-square-o"></i> It is run by checking specRunner.html file in the browser which include specs, both the specs and suits are linked.
<br /><br />
<i class="fa fa-check-square-o"></i> Suites:It starts with the global jasmine function with the parameter-a string and function.
<br /><br />
<i class="fa fa-check-square-o"></i> Specs:Specs defined by call of the global Jasmine function (it()), which,like describe takes string and function.
<br /><br />
<i class="fa fa-check-square-o"></i> Expectations:built with the function expect which takes the value called actual.responsible for reporting of the Jasmine.
<br /><br />
<i class="fa fa-check-square-o"></i> Matchers:Matchers implements the bool comparison between actual values and expecting values.
</p>
<br /><br /><br />
<p class="subtopic">Implementing Jasmine.</p>
<br />
<div class="cmd">
<ul>
<li><i class="fa fa-folder fa fa-lg"></i> Specs</li>
<br />
<li> <i class="fa fa-file"></i> AddressBookSpec.js</li>
<br />
<li><i class="fa fa-folder fa-lg"></i> Src</li>
<br />
<li> <i class="fa fa-file"></i> AddressBook.js</li>
<br />
<li><i class="fa fa-file fa-lg"></i> SpecRunner.html</li>
</ul>
</div>
<p id="blockquote">We should be running SpecRunner.html, and follow Red, Green, Refactor Cycle.</p>
<br /><br /><br />
<p class="well">AddressBookSpec.js</p>
<div class="cmd">
describe('AddressBook' , function(){
<br/><br />
it('should be able to add the contact' , function(){
<br /><br>
var addressBook = new AddressBook();
<br/><br />
this.contact = new Contact();
<br /><br />
addressBook.addContact(this.contact);
<br /><br />
expect(addressBook.getContact(0).toBe(this.contact));
<br/><br >
});
<br/>
});
</div>
<p class="well">AddressBook.js</p>
<div class="cmd">
function AddressBook(){
<br/><br />
this.contact = [];
<br /><br/>
}
<br /><br />
AddressBook.prototype.addContact = function(con){
<br /><br />
this.contact.push(contact);
<br /><br />
}
<br /><br />
AddressBook.prototype.getContact = function(index){
<br /><br />
return this.contact[index];
<br /><br />
}
<br /><br />
function Contact(){
<br/><br />
}
</div>
<br /><br />
<p class="alert alert-danger">
Getting Red In specsRunner.html, review the js once again.
</p>
<br >
<p class="alert alert-success">
Getting Green In specsRunner.html, App running successfully.
</p>
<hr/>
<p class="subtopic">
Conclusion
</p>
<br />
<p class="subtopic-det">
Testing of your app, plays a vital role in the prodution environment, We can't afford,
to have error on our application.Moreover, Writing a testing module using a Jasmine,Mocha,
Chai for writing test modules.
<br/>
Test the faliure, finding bug, then test software till it is running in correct way.
</p>
<hr/><br />
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img class="media-object" style="height:120px !important;width:120px !important;" src="http://placehold.it/200x200" alt="Arpit Anand">
</a>
</div>
<div class="media-body">
<br />
<h4 class="media-heading" id="bold">Author:</h4>
<p class="subtopic-det">Arpit Anand.
<p class="subtopic-det"><a href="http://arpitanand.tk"> Click to know about me</a></p>
</div>
</div>
<hr/>
<br /><br />
</div><!--Main Wrapper Div -->
<br/><br />
</body>
</html>