forked from azer/require-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
62 lines (47 loc) · 1.35 KB
/
test.js
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
var sdk = require('./');
it('loads soundcloud api', function(done){
var soundcloud = sdk('http://connect.soundcloud.com/sdk.js', 'SC');
var calledFirst;
soundcloud(function (error, api) {
expect(error).to.not.exist;
expect(api).to.equal(window.SC);
expect(calledFirst).to.not.exist;
calledFirst = true;
});
soundcloud(function (error, api) {
expect(error).to.not.defined;
expect(api).to.equal(window.SC);
expect(calledFirst).to.be.true;
var loadedAgain;
soundcloud(function (error, api) {
expect(error).to.not.exist;
expect(api).to.equal(window.SC);
expect(loadedAgain).to.not.exist;
done();
});
loadedAgain = true;
});
});
it('loads youtube api', function(done){
var youtube = sdk('https://www.youtube.com/iframe_api', 'YT');
var trigger = youtube.trigger();
window.onYouTubeIframeAPIReady = function() {
trigger();
delete window.onYouTubeIframeAPIReady;
};
var calledFirst;
youtube(function (error, api) {
expect(error).to.not.exist;
expect(api).to.equal(window.YT);
expect(calledFirst).to.not.exist;
expect(YT.Player).to.exist;
calledFirst = true;
});
youtube(function (error, api) {
expect(error).to.not.defined;
expect(api).to.equal(window.YT);
expect(YT.Player).to.exist;
expect(calledFirst).to.be.true;
done();
});
});