This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
forked from embedly/embedly-jquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.html
143 lines (142 loc) · 10.2 KB
/
tests.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="qunit.css" type="text/css"/>
<script src="http://code.jquery.com/jquery-latest.js"> </script>
<script src="jquery.embedly.js"> </script>
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript">
// --- Unittest Code goes here ---
$(document).ready(function(){
QUnit.log = function(result, message)
{
if (window.console && window.console.log)
{
window.console.log(result +' :: '+ message);
}
}
module("Embedly");
test("Chainability", function()
{
expect(4);
var urls = $.map($('a.photo'), function(v, i){ return $(v).attr('href'); });
same($('a.photo'), $('a.photo').embedly({success:function(){}}), '$(a).embedly() returns the same set of links as $(a)' );
same($('a.photo').embedly({method:'after', success:function(oembed,dict){}}),
$.embedly(urls,{elems:$('a.photo'), success:function(oembed,dict){}}),
'$(a).embedly() is the same as $.embedly(urls,{elems:$(a)})' );
same($.embedly(urls,{elems:$('a.photo'), success:function(oembed,dict){}}), $('a.photo'), 'passing urls and a set of elements returns those elements for chaining functions');
ok($.embedly(urls,{success:function(oembed,dict){ return oembed}}), 'Calling the embed function directly should return results');
});
module("oEmbed");
asyncTest('photo URL returns oEmbed Type Photo', function(){
$('a.photo:first').embedly({success:function(oembed,dict){
ok(oembed.type == 'photo', $('a.photo:first').attr('href')+' returns oembed.type: '+oembed.type );
start();
}});
});
asyncTest('video URL returns oEmbed Type Video', function(){
$('a.video:first').embedly({success:function(oembed,dict){
ok(oembed.type == 'video', $('a.video:first').attr('href')+' returns oembed.type: '+oembed.type );
start();
}});
});
asyncTest('rich URL returns oEmbed Type Rich', function(){
$('a.rich:first').embedly({success:function(oembed,dict){
ok(oembed.type == 'rich', $('a.rich:first').attr('href')+' returns oembed.type: '+oembed.type );
start();
}});
});
/*test('random URL is ignored by API', function(){
ok($('a.other:first').embedly().data('oembed') == false, $('a.other:first').attr('href')+' is not a recognized service' );
})*/
/*asyncTest('PRO: random URL is handled', function(){
$('a.other:first').embedly({key:'', success:function(oembed,dict){
ok(oembed.type == 'link', $('a.other:first').attr('href')+' returns oembed.type: '+oembed.type );
start();
}});
});*/
module('Custom Event Handler');
asyncTest('Bind and Unbind oembed event', function(){
expect(5);
var handler = function(event, oembed) {
ok( event.data, "bind() with data, check passed data exists" );
ok( oembed, 'oEmbed data an extra parameter in the event handler');
ok( $(this).data('oembed'), 'oembed is a data field on the DOM element $(this).data("oembed")');
equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
$(this).unbind('embedly-oembed');
ok(!$.data($("a.photo:first"), "events"), "Event handler unbound when using data.");
};
$("a.photo:first").bind("embedly-oembed", {foo: "bar"}, handler).embedly({success:function(){start();}});
});
});
</script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<h4>Test Urls</h4>
<ul class="links">
<li><a class="photo" href="http://twitpic.com/1c4t5h">Photo</a></li>
<li><a class="photo" href="http://twitpic.com/1c4t4s">Photo</a></li>
<li><a class="photo" href="http://twitpic.com/1c4s7c">Photo</a></li>
<li><a class="photo" href="http://www.flickr.com/photos/ciskatobing/108016857/">Photo</a></li>
<li><a class="photo" href="http://www.flickr.com/photos/laurentlouis/4460330770/in/set-72157623560121629/">Photo</a></li>
<li><a class="photo" href="http://www.flickr.com/photos/dryponder/4475104368/in/set-72157623726710218/">Photo</a></li>
<li><a class="photo" href="http://tweetphoto.com/16513486">Photo</a></li>
<li><a class="photo" href="http://i.imgur.com/PUai9.png">Photo</a></li>
<li><a class="photo" href="http://phodroid.com/10/03/2c2xzy">Photo</a></li>
<li><a class="video" href="http://www.hulu.com/watch/33457/family-guy-6000-chicken-fajitas">Video</a></li>
<li><a class="video" href="http://www.youtube.com/watch?v=LfamTmY5REw">Video</a></li>
<li><a class="video" href="http://revision3.com/thegameshow/ff13">Video</a></li>
<li><a class="video" href="http://www.viddler.com/explore/engadget/videos/1174/11.772">Video</a></li>
<li><a class="video" href="http://www.dailymotion.com/video/xa7bxy_usa-09_travel">Video</a></li>
<li><a class="video" href="http://qik.com/video/5774345">Video</a></li>
<li><a class="video" href="http://video.google.com/videoplay?docid=-6583704503096933955&ei=7AyzS-7THqjQrAOt8o2jBg&q=embed#">Video</a></li>
<li><a class="video" href="http://screenr.com/sWM">Video</a></li>
<li><a class="rich" href="http://www.scribd.com/doc/24791195/Mercantile-Law">Scrib</a></li>
<li><a class="rich" href="http://www.slideshare.net/Tatu.05/earth-hour-2010-3575769">Slideshare</a></li>
<li><a class="rich" href="http://twitter.com/LayerTennis/statuses/24131533380">twitter feed</a></li>
<li><a class="rich" href="http://twitter.com/wilw/statuses/24130676922">twitter feed</a></li>
<li><a class="rich" href="http://twitter.com/mashable/statuses/24134879185">twitter feed</a></li>
<li><a class="rich" href="http://twitter.com/ConanOBrien/statuses/24132174682">twitter feed</a></li>
<li><a class="rich" href="http://twitter.com/RyanSeacrest/statuses/24137863620">twitter feed</a></li>
<li><a class="video" href="http://www.youtube.com/watch?v=wTcz-etqwKg">Video</a></li>
<li><a class="video" href="http://www.youtube.com/watch?v=zVNTdWbVBgc">Video</a></li>
<li><a class="video" href="http://www.youtube.com/watch?v=Q5im0Ssyyus">Video</a></li>
<li><a class="video" href="http://www.youtube.com/watch?v=wCF3ywukQYA">Video</a></li>
<li><a class="photo" href="http://www.bestbuypricelowest.com/Fallen-Angel-Elite-Adult-Collection-Adult-Halloween-Costume-Small">other</a></li>
<li><a class="rich" href="http://www.amazon.com/gp/product/B002KJ3AJC/ref=s9_simh_gw_p193_d2_i4?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-3&pf_rd_r=1ET2B493GPXE4RB0FCTM&pf_rd_t=101&pf_rd_p=470938811&pf_rd_i=507846">other</a></li>
<li><a class="photo" href="http://twitpic.com/2xbqjo">photo</a></li>
<li><a class="video" href="http://tumblr.com/x3hlwzmah">video</a></li>
<li><a class="other" href="http://www.examiner.com/pop-culture-in-cleveland/michelle-obama-catwoman-photos-obama-s-halloween-costume-at-the-white-house-presidential">other</a></li>
<li><a class="other" href="http://www.amazon.com/Adults-Deluxe-Gorilla-Costume-Size/dp/B000JKO7NC">other</a></li>
<li><a class="other" href="http://mydisguises.com/2008/07/28/how-to-make-a-dr-horrible-costume/ ">other</a></li>
<li><a class="other" href="http://blog.makezine.com/archive/2007/10/realistic_werewolf_costum.html">other</a></li>
<li><a class="video" href="http://www.metacafe.com/watch/84226/octopus_costume/">Video</a></li>
<li><a class="video" href="http://www.colbertnation.com/the-colbert-report-videos/362254/october-15-2010/recap---week-of-10-11-10">Video</a></li>
<li><a class="other" href="http://www.costumesupercenter.com/group+costumes-lady+gaga/R889959-lady-gaga-blue-swimsuit-adult-costume.html">other</a></li>
<li><a class="other" href="http://www.huffingtonpost.com/2010/10/05/inappropriate-halloween-costumes_n_750503.html">other</a></li>
<li><a class="other" href="http://www.halloweencostumes.net/50s-class-nerd-costume.html">other</a></li>
<li><a class="other" href="http://www.costumecraze.com/SA593.html">other</a></li>
<li><a class="other" href="http://www.coolest-homemade-costumes.com/coolest-boat-from-the-deadliest-catch-costume.html">other</a></li>
<li><a class="video" href="http://www.twitvid.com/G8CGV">Video</a></li>
<li><a class="other" href="http://becauseimaddicted.net/2010/10/halloween-inspiration-from-vogue-paris.html">other</a></li>
<li><a class="other" href="http://girlsofdos.tumblr.com/post/1311697680/lctrguns">other</a></li>
<li><a class="other" href="http://www.etsy.com/listing/41794582/cute-pirate-wench-maid-costume-dress-and?ref=cat2_gallery_13">other</a></li>
<li><a class="other" href="http://www.sexycostumes.com/miss-mafia-costume.html">other</a></li>
<li><a class="other" href="http://blog.makezine.com/archive/2008/10/spy_vs_spy_halloween_cost.html">other</a></li>
<li><a class="video" href="http://vimeo.com/399507">Video</a></li>
<li><a class="other" href="http://www.costumesupercenter.com/group+costumes-toy+story/DI5233-buzz-lightyear-deluxe-child-costume.html">other</a></li>
<li><a class="other" href="http://mrcostumes.wordpress.com/2009/09/22/couples-costumes-best-and-worst/">other</a></li>
<li><a class="video" href="http://www.whitehouse.gov/photos-and-video/video/2010/10/16/weekly-address-gop-rewarding-corporations-create-jobs-overseas">other</a></li>
<li><a class="video" href="http://www.funnyordie.com/videos/d84660f7dd/bobby-bottleservice-jersey-shore-audition-tape">Video</a></li>
<li><a class="video" href="http://www.theonion.com/video/how-to-find-a-masculine-halloween-costume-for-your,14378/">Video</a></li>
<li><a class="other" href="http://www.candyapplecostumes.com/fp559205.html">other</a></li>
<li><a class="other" href="http://www.SugarChicCouture.com/Giraffe_Dog_Costume_p/gdc-19.htm">other</a></li>
</ul>
</body>
</html>