jasmine-ajax 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.pairs +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +168 -0
- data/Rakefile +3 -0
- data/examples/jquery/Rakefile +2 -0
- data/examples/jquery/public/css/master.css +59 -0
- data/examples/jquery/public/css/reset.css +47 -0
- data/examples/jquery/public/images/fail-whale.png +0 -0
- data/examples/jquery/public/index.html +60 -0
- data/examples/jquery/public/javascripts/Tweet.js +6 -0
- data/examples/jquery/public/javascripts/TwitSearch.js +32 -0
- data/examples/jquery/public/javascripts/TwitterApi.js +31 -0
- data/examples/jquery/spec/SpecRunner.html +32 -0
- data/examples/jquery/spec/javascripts/TweetSpec.js +24 -0
- data/examples/jquery/spec/javascripts/TwitterApiSpec.js +88 -0
- data/examples/jquery/spec/javascripts/helpers/test_responses/search.js +16 -0
- data/examples/jquery/spec/javascripts/helpers/tweets.js +3 -0
- data/examples/jquery/spec/javascripts/jasmine-0.11.1/jasmine-html.js +182 -0
- data/examples/jquery/spec/javascripts/jasmine-0.11.1/jasmine.css +166 -0
- data/examples/jquery/spec/javascripts/jasmine-0.11.1/jasmine.js +2343 -0
- data/examples/jquery/spec/javascripts/support/jasmine.yml +78 -0
- data/examples/jquery/spec/javascripts/support/jasmine_runner.rb +21 -0
- data/examples/prototype/Rakefile +2 -0
- data/examples/prototype/public/css/master.css +59 -0
- data/examples/prototype/public/css/reset.css +47 -0
- data/examples/prototype/public/images/fail-whale.png +0 -0
- data/examples/prototype/public/index.html +45 -0
- data/examples/prototype/public/javascripts/Tweet.js +6 -0
- data/examples/prototype/public/javascripts/TwitSearch.js +32 -0
- data/examples/prototype/public/javascripts/TwitterApi.js +24 -0
- data/examples/prototype/spec/SpecRunner.html +32 -0
- data/examples/prototype/spec/javascripts/TweetSpec.js +24 -0
- data/examples/prototype/spec/javascripts/TwitterApiSpec.js +89 -0
- data/examples/prototype/spec/javascripts/helpers/test_responses/search.js +16 -0
- data/examples/prototype/spec/javascripts/helpers/tweets.js +3 -0
- data/examples/prototype/spec/javascripts/jasmine-0.11.1/jasmine-html.js +182 -0
- data/examples/prototype/spec/javascripts/jasmine-0.11.1/jasmine.css +166 -0
- data/examples/prototype/spec/javascripts/jasmine-0.11.1/jasmine.js +2343 -0
- data/examples/prototype/spec/javascripts/support/jasmine.yml +78 -0
- data/examples/prototype/spec/javascripts/support/jasmine_runner.rb +21 -0
- data/frameworks/jquery.js +8176 -0
- data/frameworks/prototype.js +4874 -0
- data/lib/assets/javascripts/mock-ajax.js +207 -0
- data/lib/spec-helper.js +0 -0
- data/lib/version.rb +5 -0
- data/spec/javascripts/fake-xml-http-request-spec.js +45 -0
- data/spec/javascripts/helpers/spec-helper.js +5 -0
- data/spec/javascripts/mock-ajax-jquery-spec.js +374 -0
- data/spec/javascripts/mock-ajax-prototypejs-spec.js +287 -0
- data/spec/javascripts/mock-ajax-spec.js +193 -0
- data/spec/javascripts/support/jasmine.yml +81 -0
- data/spec/javascripts/support/jasmine_runner.rb +21 -0
- metadata +108 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
function TwitterApi () {
|
2
|
+
this.baseUrl = "http://search.twitter.com/search.json"
|
3
|
+
}
|
4
|
+
|
5
|
+
TwitterApi.prototype.search = function(query, callbacks) {
|
6
|
+
$.ajax({
|
7
|
+
url: this.baseUrl,
|
8
|
+
data: {
|
9
|
+
q: query
|
10
|
+
},
|
11
|
+
type: "GET",
|
12
|
+
success: function(data, status, request) {
|
13
|
+
var tweets = [];
|
14
|
+
$(data.results).each(function(index, result){
|
15
|
+
tweets.push(new Tweet(result));
|
16
|
+
});
|
17
|
+
|
18
|
+
callbacks.onSuccess(tweets);
|
19
|
+
},
|
20
|
+
complete: callbacks.onComplete,
|
21
|
+
error: function(request, status, error){
|
22
|
+
errorStatus = request.status;
|
23
|
+
|
24
|
+
if (errorStatus == "500") {
|
25
|
+
callbacks.onFailure();
|
26
|
+
} else if (errorStatus == "503") {
|
27
|
+
callbacks.onFailWhale();
|
28
|
+
}
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Test Runner</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="javascripts/jasmine-0.11.1/jasmine.css" />
|
7
|
+
<script type="text/javascript" src="javascripts/jasmine-0.11.1/jasmine.js"></script>
|
8
|
+
<script type="text/javascript" src="javascripts/jasmine-0.11.1/jasmine-html.js"></script>
|
9
|
+
|
10
|
+
<!-- include source files here... -->
|
11
|
+
<script type="text/javascript" src="../../../frameworks/jquery.js"></script>
|
12
|
+
<script type="text/javascript" src="../public/javascripts/Tweet.js"></script>
|
13
|
+
<script type="text/javascript" src="../public/javascripts/TwitSearch.js"></script>
|
14
|
+
<script type="text/javascript" src="../public/javascripts/TwitterApi.js"></script>
|
15
|
+
|
16
|
+
<!-- include spec files here... -->
|
17
|
+
<script type="text/javascript" src="../../../lib/mock-ajax.js"></script>
|
18
|
+
<script type="text/javascript" src="../../../lib/spec-helper.js"></script>
|
19
|
+
<script type="text/javascript" src="javascripts/helpers/test_responses/search.js"></script>
|
20
|
+
<script type="text/javascript" src="javascripts/helpers/tweets.js"></script>
|
21
|
+
<script type="text/javascript" src="javascripts/TweetSpec.js"></script>
|
22
|
+
<script type="text/javascript" src="javascripts/TwitterApiSpec.js"></script>
|
23
|
+
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<script type="text/javascript">
|
27
|
+
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
28
|
+
jasmine.getEnv().execute();
|
29
|
+
</script>
|
30
|
+
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe("Tweet", function(){
|
2
|
+
var tweet;
|
3
|
+
|
4
|
+
beforeEach(function(){
|
5
|
+
tweet = new Tweet(eval('(' + Tweets.noAtReply + ')'));
|
6
|
+
});
|
7
|
+
|
8
|
+
it("should create a pretty date", function(){
|
9
|
+
expect(tweet.postedAt).toEqual("Thu, 29 Jul 2010 02:18:53 +0000");
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should store the users messages", function(){
|
13
|
+
expect(tweet.text).toEqual("Pres Obama on stage with the Foo fighters, jonas brothers and a whole lot of ppl..nice..");
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should store the username", function(){
|
17
|
+
expect(tweet.user).toEqual("_wbrodrigues");
|
18
|
+
});
|
19
|
+
|
20
|
+
it("stores the users messages", function(){
|
21
|
+
expect(tweet.imageUrl).toEqual("http://a2.twimg.com/profile_images/1014111170/06212010155_normal.jpg");
|
22
|
+
});
|
23
|
+
|
24
|
+
});
|
@@ -0,0 +1,88 @@
|
|
1
|
+
describe("TwitterApi#search", function(){
|
2
|
+
var twitter, request;
|
3
|
+
var onSuccess, onFailure, onComplete, onFailWhale;
|
4
|
+
|
5
|
+
beforeEach(function(){
|
6
|
+
jasmine.Ajax.useMock();
|
7
|
+
|
8
|
+
onSuccess = jasmine.createSpy('onSuccess');
|
9
|
+
onFailure = jasmine.createSpy('onFailure');
|
10
|
+
onComplete = jasmine.createSpy('onComplete');
|
11
|
+
onFailWhale = jasmine.createSpy('onFailWhale');
|
12
|
+
|
13
|
+
twitter = new TwitterApi();
|
14
|
+
|
15
|
+
twitter.search('basketball', {
|
16
|
+
onSuccess: onSuccess,
|
17
|
+
onFailure: onFailure,
|
18
|
+
onComplete: onComplete,
|
19
|
+
onFailWhale: onFailWhale
|
20
|
+
});
|
21
|
+
|
22
|
+
request = mostRecentAjaxRequest();
|
23
|
+
});
|
24
|
+
|
25
|
+
it("calls Twitter with the correct url", function(){
|
26
|
+
expect(request.url).toEqual("http://search.twitter.com/search.json?q=basketball")
|
27
|
+
});
|
28
|
+
|
29
|
+
describe("on success", function(){
|
30
|
+
beforeEach(function(){
|
31
|
+
request.response(TestResponses.search.success);
|
32
|
+
});
|
33
|
+
|
34
|
+
it("calls onSuccess with an array of Tweets", function(){
|
35
|
+
var successArgs = onSuccess.mostRecentCall.args[0];
|
36
|
+
|
37
|
+
expect(onSuccess).toHaveBeenCalledWith(jasmine.any(Array));
|
38
|
+
expect(successArgs.length).toEqual(15);
|
39
|
+
expect(successArgs[0]).toEqual(jasmine.any(Tweet));
|
40
|
+
});
|
41
|
+
|
42
|
+
it("calls onComplete", function(){
|
43
|
+
expect(onComplete).toHaveBeenCalled();
|
44
|
+
});
|
45
|
+
|
46
|
+
it("does not call onFailure", function(){
|
47
|
+
expect(onFailure).not.toHaveBeenCalled();
|
48
|
+
})
|
49
|
+
|
50
|
+
});
|
51
|
+
|
52
|
+
describe('on failure', function(){
|
53
|
+
beforeEach(function(){
|
54
|
+
request.response(TestResponses.search.failure);
|
55
|
+
});
|
56
|
+
|
57
|
+
it("calls onFailure", function() {
|
58
|
+
expect(onFailure).toHaveBeenCalled();
|
59
|
+
});
|
60
|
+
|
61
|
+
it("call onComplete", function(){
|
62
|
+
expect(onComplete).toHaveBeenCalled();
|
63
|
+
});
|
64
|
+
|
65
|
+
it("does not call onSuccess", function(){
|
66
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
70
|
+
describe("on fail whale", function(){
|
71
|
+
beforeEach(function(){
|
72
|
+
request.response(TestResponses.search.failWhale);
|
73
|
+
});
|
74
|
+
|
75
|
+
it("calls onFailWhale", function(){
|
76
|
+
expect(onFailWhale).toHaveBeenCalled();
|
77
|
+
});
|
78
|
+
|
79
|
+
it("does not call onSuccess", function(){
|
80
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
81
|
+
});
|
82
|
+
|
83
|
+
it("calls onComplete", function(){
|
84
|
+
expect(onComplete).toHaveBeenCalled();
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var TestResponses = {
|
2
|
+
search: {
|
3
|
+
success: {
|
4
|
+
status: 200,
|
5
|
+
responseText: '{"results":[{"profile_image_url":"http://a1.twimg.com/profile_images/884091661/Braxten_2008_Fall_Ball_001_normal.jpg","created_at":"Tue, 27 Jul 2010 20:35:12 +0000","from_user":"FWSportsAcademy","metadata":{"result_type":"recent"},"to_user_id":null,"text":"BASKETBALL: Five-Star NYC Metro | Stroudsburg, Pa | August 25 - 28, 2010 | @5Starhoops | More Info: http://ow.ly/2gHQl","id":19684312578,"from_user_id":115767107,"geo":null,"iso_language_code":"en","source":"<a href="http://www.hootsuite.com" rel="nofollow">HootSuite</a>"},{"profile_image_url":"http://a0.twimg.com/profile_images/83191308/RH_Full_Colour_normal.jpg","created_at":"Tue, 27 Jul 2010 20:35:09 +0000","from_user":"ScoreHints","metadata":{"result_type":"recent"},"to_user_id":null,"text":"If #Angels trail by seven at half time do you want to watch? Need a hint? www.scorehints.com #NBA #Basketball","id":19684309828,"from_user_id":5581860,"geo":null,"iso_language_code":"en","source":"<a href="http://dev.twitter.com/" rel="nofollow">API</a>"},{"profile_image_url":"http://a0.twimg.com/profile_images/1087851604/Photo_1612_normal.jpg","created_at":"Tue, 27 Jul 2010 20:35:08 +0000","from_user":"Debyshu","metadata":{"result_type":"recent"},"to_user_id":null,"text":"RT @JWigg12: its crazy how #thankstohampton is trending but basketball games were always empty and having school spirit was considered lame","id":19684309349,"from_user_id":70467359,"geo":null,"iso_language_code":"en","source":"<a href="http://www.deliciousmorsel.com/app/twee" rel="nofollow">Twee2</a>"},{"profile_image_url":"http://a1.twimg.com/profile_images/966663977/ATT00003_normal.jpg","created_at":"Tue, 27 Jul 2010 20:35:00 +0000","from_user":"EilishQ_xo","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Basketball :D","id":19684301116,"from_user_id":122208550,"geo":null,"iso_language_code":"no","source":"<a href="/devices" rel="nofollow">txt</a>"},{"profile_image_url":"http://a2.twimg.com/profile_images/1066224070/image_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:46 +0000","from_user":"BaileyKathlyn","metadata":{"result_type":"recent"},"to_user_id":null,"text":"I haven\'t seen inception but I do love Leo so I\'m watching basketball diaries. #sadbutgreat","id":19684288051,"from_user_id":7652303,"geo":null,"iso_language_code":"en","source":"<a href="http://twitter.com/" rel="nofollow">Twitter for iPhone</a>"},{"profile_image_url":"http://a0.twimg.com/profile_images/1073721248/logo_meebo_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:44 +0000","from_user":"meebojono","metadata":{"result_type":"recent"},"to_user_id":null,"text":"basketball 1280262884","id":19684286055,"from_user_id":128057193,"geo":null,"iso_language_code":"no","source":"<a href="http://dev.twitter.com/" rel="nofollow">API</a>"},{"profile_image_url":"http://a2.twimg.com/profile_images/1088509454/image_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:16 +0000","from_user":"shortydent_22","metadata":{"result_type":"recent"},"to_user_id":null,"text":"okay so more basketball tournaments with balboa oh yes and more viewing tournaments that\'s a plus lol","id":19684259884,"from_user_id":139618461,"geo":null,"iso_language_code":"en","source":"<a href="http://blackberry.com/twitter" rel="nofollow">Twitter for BlackBerry\u00ae</a>"},{"profile_image_url":"http://a0.twimg.com/profile_images/438609748/YK_photo_012_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:16 +0000","from_user":"YanniKouts","metadata":{"result_type":"recent"},"to_user_id":28591659,"text":"@Immanuelcarr Did you see this? Turkish Airlines closes 5-yr deal to become Euroleague Basketball\'s name sponsor http://bit.ly/betKvz","id":19684259414,"from_user_id":137616871,"to_user":"Immanuelcarr","geo":null,"iso_language_code":"en","source":"<a href="http://83degrees.com/to/powertwitter" rel="nofollow">Power Twitter</a>"},{"profile_image_url":"http://a1.twimg.com/profile_images/937703398/Basketball_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:09 +0000","from_user":"MyBasketballHub","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Watch Live NBA Basketball Online: Sammy Dunking ! http://watchbasketballonlinetv.com/2010/07/sammy-dunking/","id":19684252798,"from_user_id":119761113,"geo":null,"iso_language_code":"en","source":"<a href="http://alexking.org/projects/wordpress" rel="nofollow">Twitter Tools</a>"},{"profile_image_url":"http://a1.twimg.com/profile_images/974986837/DSC02764pt2_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:03 +0000","from_user":"heightsonline","metadata":{"result_type":"recent"},"to_user_id":101981646,"text":"@iHeartChuckee lool real talk o yh u c basketball is it hard there?","id":19684247026,"from_user_id":70580756,"to_user":"iHeartChuckee","geo":null,"iso_language_code":"en","source":"<a href="http://twitter.com/">web</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/1062447055/IMG00127-20100325-1308_normal.jpg","created_at":"Tue, 27 Jul 2010 20:34:00 +0000","from_user":"718rocky","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Aug 21 Rosedale day! Basketball games for the youth! 12, 14, 16, 18 so if u know some kids the are nice send them 2 brookville park.@G2Buck","id":19684244113,"from_user_id":131711316,"geo":null,"iso_language_code":"en","source":"<a href="http://blackberry.com/twitter" rel="nofollow">Twitter for BlackBerry\u00ae</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/491471495/twitterProfilePhoto_normal.jpg","created_at":"Tue, 27 Jul 2010 20:33:52 +0000","from_user":"Tanapseudes","metadata":{"result_type":"recent"},"to_user_id":null,"text":"HR 5741, instead of the Yutes playing midnight basketball, they can be slaves to govt for 2 years. Sorry Charlie #tcot","id":19684237202,"from_user_id":32253974,"geo":null,"iso_language_code":"en","source":"<a href="http://www.tweetdeck.com/" rel="nofollow">TweetDeck</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/1072106439/135058220_normal.jpg","created_at":"Tue, 27 Jul 2010 20:33:43 +0000","from_user":"Datblue","metadata":{"result_type":"recent"},"to_user_id":108633989,"text":"@RetrOspeC_ofCCC I thought u was playin basketball nigga, tryna get ya scottie pippen up..wat did u think I was talkin bout?? Oooooooo I kno","id":19684229013,"from_user_id":88488335,"to_user":"RetrOspeC_ofCCC","geo":null,"iso_language_code":"en","source":"<a href="http://www.ubertwitter.com/bb/download.php" rel="nofollow">\u00dcberTwitter</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/1089092015/144994995_normal.jpg","created_at":"Tue, 27 Jul 2010 20:33:34 +0000","from_user":"KoolsWorld","metadata":{"result_type":"recent"},"to_user_id":7321391,"text":"@KattPackAllDay #WhyYoMama fucking one of your teammates on your basketball team and that\'s why yall got shut out the championship","id":19684220691,"from_user_id":100745158,"to_user":"KattPackAllDay","geo":null,"iso_language_code":"en","source":"<a href="http://ubertwitter.com" rel="nofollow">UberTwitter</a>"},{"profile_image_url":"http://a2.twimg.com/profile_images/788120510/twitterProfilePhoto_normal.jpg","created_at":"Tue, 27 Jul 2010 20:33:30 +0000","from_user":"Jdovitz","metadata":{"result_type":"recent"},"to_user_id":null,"text":"basketball jones","id":19684216698,"from_user_id":98323727,"geo":null,"iso_language_code":"no","source":"<a href="http://twitter.com/">web</a>"}],"max_id":19684312578,"since_id":0,"refresh_url":"?since_id=19684312578&q=basketball","next_page":"?page=2&max_id=19684312578&q=basketball","results_per_page":15,"page":1,"completed_in":0.021477,"query":"basketball"}'
|
6
|
+
},
|
7
|
+
failure: {
|
8
|
+
status: 500,
|
9
|
+
responseText: '{"error":"You broke Twitter."}'
|
10
|
+
},
|
11
|
+
failWhale: {
|
12
|
+
status: 503,
|
13
|
+
responseText: '{"error":"Too many tweets!"}'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
var Tweets = {
|
2
|
+
noAtReply: '{"profile_image_url":"http://a2.twimg.com/profile_images/1014111170/06212010155_normal.jpg","created_at":"Thu, 29 Jul 2010 02:18:53 +0000","from_user":"_wbrodrigues","metadata":{"result_type":"recent"},"to_user_id":null,"text":"Pres Obama on stage with the Foo fighters, jonas brothers and a whole lot of ppl..nice..","id":19789985947,"from_user_id":139732299,"geo":null,"iso_language_code":"en","source":"<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>"}'
|
3
|
+
}
|
@@ -0,0 +1,182 @@
|
|
1
|
+
jasmine.TrivialReporter = function(doc) {
|
2
|
+
this.document = doc || document;
|
3
|
+
this.suiteDivs = {};
|
4
|
+
this.logRunningSpecs = false;
|
5
|
+
};
|
6
|
+
|
7
|
+
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
8
|
+
var el = document.createElement(type);
|
9
|
+
|
10
|
+
for (var i = 2; i < arguments.length; i++) {
|
11
|
+
var child = arguments[i];
|
12
|
+
|
13
|
+
if (typeof child === 'string') {
|
14
|
+
el.appendChild(document.createTextNode(child));
|
15
|
+
} else {
|
16
|
+
if (child) { el.appendChild(child); }
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
for (var attr in attrs) {
|
21
|
+
if (attr == "className") {
|
22
|
+
el[attr] = attrs[attr];
|
23
|
+
} else {
|
24
|
+
el.setAttribute(attr, attrs[attr]);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return el;
|
29
|
+
};
|
30
|
+
|
31
|
+
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
32
|
+
var showPassed, showSkipped;
|
33
|
+
|
34
|
+
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
35
|
+
this.createDom('div', { className: 'banner' },
|
36
|
+
this.createDom('div', { className: 'logo' },
|
37
|
+
"Jasmine",
|
38
|
+
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
39
|
+
this.createDom('div', { className: 'options' },
|
40
|
+
"Show ",
|
41
|
+
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
42
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
43
|
+
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
44
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
45
|
+
)
|
46
|
+
),
|
47
|
+
|
48
|
+
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
49
|
+
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
50
|
+
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
51
|
+
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
52
|
+
);
|
53
|
+
|
54
|
+
this.document.body.appendChild(this.outerDiv);
|
55
|
+
|
56
|
+
var suites = runner.suites();
|
57
|
+
for (var i = 0; i < suites.length; i++) {
|
58
|
+
var suite = suites[i];
|
59
|
+
var suiteDiv = this.createDom('div', { className: 'suite' },
|
60
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
61
|
+
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
62
|
+
this.suiteDivs[suite.id] = suiteDiv;
|
63
|
+
var parentDiv = this.outerDiv;
|
64
|
+
if (suite.parentSuite) {
|
65
|
+
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
66
|
+
}
|
67
|
+
parentDiv.appendChild(suiteDiv);
|
68
|
+
}
|
69
|
+
|
70
|
+
this.startedAt = new Date();
|
71
|
+
|
72
|
+
var self = this;
|
73
|
+
showPassed.onchange = function(evt) {
|
74
|
+
if (evt.target.checked) {
|
75
|
+
self.outerDiv.className += ' show-passed';
|
76
|
+
} else {
|
77
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
78
|
+
}
|
79
|
+
};
|
80
|
+
|
81
|
+
showSkipped.onchange = function(evt) {
|
82
|
+
if (evt.target.checked) {
|
83
|
+
self.outerDiv.className += ' show-skipped';
|
84
|
+
} else {
|
85
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
86
|
+
}
|
87
|
+
};
|
88
|
+
};
|
89
|
+
|
90
|
+
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
91
|
+
var results = runner.results();
|
92
|
+
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
93
|
+
this.runnerDiv.setAttribute("class", className);
|
94
|
+
//do it twice for IE
|
95
|
+
this.runnerDiv.setAttribute("className", className);
|
96
|
+
var specs = runner.specs();
|
97
|
+
var specCount = 0;
|
98
|
+
for (var i = 0; i < specs.length; i++) {
|
99
|
+
if (this.specFilter(specs[i])) {
|
100
|
+
specCount++;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
104
|
+
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
105
|
+
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
106
|
+
|
107
|
+
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
111
|
+
var results = suite.results();
|
112
|
+
var status = results.passed() ? 'passed' : 'failed';
|
113
|
+
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
114
|
+
status = 'skipped';
|
115
|
+
}
|
116
|
+
this.suiteDivs[suite.id].className += " " + status;
|
117
|
+
};
|
118
|
+
|
119
|
+
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
120
|
+
if (this.logRunningSpecs) {
|
121
|
+
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
126
|
+
var results = spec.results();
|
127
|
+
var status = results.passed() ? 'passed' : 'failed';
|
128
|
+
if (results.skipped) {
|
129
|
+
status = 'skipped';
|
130
|
+
}
|
131
|
+
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
132
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
133
|
+
this.createDom('a', {
|
134
|
+
className: 'description',
|
135
|
+
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
136
|
+
title: spec.getFullName()
|
137
|
+
}, spec.description));
|
138
|
+
|
139
|
+
|
140
|
+
var resultItems = results.getItems();
|
141
|
+
var messagesDiv = this.createDom('div', { className: 'messages' });
|
142
|
+
for (var i = 0; i < resultItems.length; i++) {
|
143
|
+
var result = resultItems[i];
|
144
|
+
|
145
|
+
if (result.type == 'log') {
|
146
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
147
|
+
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
148
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
149
|
+
|
150
|
+
if (result.trace.stack) {
|
151
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
if (messagesDiv.childNodes.length > 0) {
|
157
|
+
specDiv.appendChild(messagesDiv);
|
158
|
+
}
|
159
|
+
|
160
|
+
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
161
|
+
};
|
162
|
+
|
163
|
+
jasmine.TrivialReporter.prototype.log = function() {
|
164
|
+
var console = jasmine.getGlobal().console;
|
165
|
+
if (console && console.log) console.log.apply(console, arguments);
|
166
|
+
};
|
167
|
+
|
168
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
169
|
+
return this.document.location;
|
170
|
+
};
|
171
|
+
|
172
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
173
|
+
var paramMap = {};
|
174
|
+
var params = this.getLocation().search.substring(1).split('&');
|
175
|
+
for (var i = 0; i < params.length; i++) {
|
176
|
+
var p = params[i].split('=');
|
177
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
178
|
+
}
|
179
|
+
|
180
|
+
if (!paramMap["spec"]) return true;
|
181
|
+
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
182
|
+
};
|
@@ -0,0 +1,166 @@
|
|
1
|
+
body {
|
2
|
+
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
.jasmine_reporter a:visited, .jasmine_reporter a {
|
7
|
+
color: #303;
|
8
|
+
}
|
9
|
+
|
10
|
+
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
11
|
+
color: blue;
|
12
|
+
}
|
13
|
+
|
14
|
+
.run_spec {
|
15
|
+
float:right;
|
16
|
+
padding-right: 5px;
|
17
|
+
font-size: .8em;
|
18
|
+
text-decoration: none;
|
19
|
+
}
|
20
|
+
|
21
|
+
.jasmine_reporter {
|
22
|
+
margin: 0 5px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.banner {
|
26
|
+
color: #303;
|
27
|
+
background-color: #fef;
|
28
|
+
padding: 5px;
|
29
|
+
}
|
30
|
+
|
31
|
+
.logo {
|
32
|
+
float: left;
|
33
|
+
font-size: 1.1em;
|
34
|
+
padding-left: 5px;
|
35
|
+
}
|
36
|
+
|
37
|
+
.logo .version {
|
38
|
+
font-size: .6em;
|
39
|
+
padding-left: 1em;
|
40
|
+
}
|
41
|
+
|
42
|
+
.runner.running {
|
43
|
+
background-color: yellow;
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
.options {
|
48
|
+
text-align: right;
|
49
|
+
font-size: .8em;
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
.suite {
|
56
|
+
border: 1px outset gray;
|
57
|
+
margin: 5px 0;
|
58
|
+
padding-left: 1em;
|
59
|
+
}
|
60
|
+
|
61
|
+
.suite .suite {
|
62
|
+
margin: 5px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.suite.passed {
|
66
|
+
background-color: #dfd;
|
67
|
+
}
|
68
|
+
|
69
|
+
.suite.failed {
|
70
|
+
background-color: #fdd;
|
71
|
+
}
|
72
|
+
|
73
|
+
.spec {
|
74
|
+
margin: 5px;
|
75
|
+
padding-left: 1em;
|
76
|
+
clear: both;
|
77
|
+
}
|
78
|
+
|
79
|
+
.spec.failed, .spec.passed, .spec.skipped {
|
80
|
+
padding-bottom: 5px;
|
81
|
+
border: 1px solid gray;
|
82
|
+
}
|
83
|
+
|
84
|
+
.spec.failed {
|
85
|
+
background-color: #fbb;
|
86
|
+
border-color: red;
|
87
|
+
}
|
88
|
+
|
89
|
+
.spec.passed {
|
90
|
+
background-color: #bfb;
|
91
|
+
border-color: green;
|
92
|
+
}
|
93
|
+
|
94
|
+
.spec.skipped {
|
95
|
+
background-color: #bbb;
|
96
|
+
}
|
97
|
+
|
98
|
+
.messages {
|
99
|
+
border-left: 1px dashed gray;
|
100
|
+
padding-left: 1em;
|
101
|
+
padding-right: 1em;
|
102
|
+
}
|
103
|
+
|
104
|
+
.passed {
|
105
|
+
background-color: #cfc;
|
106
|
+
display: none;
|
107
|
+
}
|
108
|
+
|
109
|
+
.failed {
|
110
|
+
background-color: #fbb;
|
111
|
+
}
|
112
|
+
|
113
|
+
.skipped {
|
114
|
+
color: #777;
|
115
|
+
background-color: #eee;
|
116
|
+
display: none;
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
/*.resultMessage {*/
|
121
|
+
/*white-space: pre;*/
|
122
|
+
/*}*/
|
123
|
+
|
124
|
+
.resultMessage span.result {
|
125
|
+
display: block;
|
126
|
+
line-height: 2em;
|
127
|
+
color: black;
|
128
|
+
}
|
129
|
+
|
130
|
+
.resultMessage .mismatch {
|
131
|
+
color: black;
|
132
|
+
}
|
133
|
+
|
134
|
+
.stackTrace {
|
135
|
+
white-space: pre;
|
136
|
+
font-size: .8em;
|
137
|
+
margin-left: 10px;
|
138
|
+
max-height: 5em;
|
139
|
+
overflow: auto;
|
140
|
+
border: 1px inset red;
|
141
|
+
padding: 1em;
|
142
|
+
background: #eef;
|
143
|
+
}
|
144
|
+
|
145
|
+
.finished-at {
|
146
|
+
padding-left: 1em;
|
147
|
+
font-size: .6em;
|
148
|
+
}
|
149
|
+
|
150
|
+
.show-passed .passed,
|
151
|
+
.show-skipped .skipped {
|
152
|
+
display: block;
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
#jasmine_content {
|
157
|
+
position:fixed;
|
158
|
+
right: 100%;
|
159
|
+
}
|
160
|
+
|
161
|
+
.runner {
|
162
|
+
border: 1px solid gray;
|
163
|
+
display: block;
|
164
|
+
margin: 5px 0;
|
165
|
+
padding: 2px 0 2px 10px;
|
166
|
+
}
|