|
1 Tests.prototype.MediaTests = function() { |
|
2 module('Media (Audio)'); |
|
3 test("should exist", function() { |
|
4 expect(1); |
|
5 ok(typeof Audio == "function", "'Audio' should be defined as a function in global scope."); |
|
6 }); |
|
7 test("should define constants for Media errors", function() { |
|
8 expect(5); |
|
9 ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists in global scope."); |
|
10 equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to 1."); |
|
11 equals(MediaError.MEDIA_ERR_NETWORK, 2, "MediaError.MEDIA_ERR_NETWORK is equal to 2."); |
|
12 equals(MediaError.MEDIA_ERR_DECODE, 3, "MediaError.MEDIA_ERR_DECODE is equal to 3."); |
|
13 equals(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 4, "MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED is equal to 4."); |
|
14 }); |
|
15 test("should contain 'src', 'loop' and 'error' properties", function() { |
|
16 expect(7); |
|
17 var audioSrc = '/test.mp3'; |
|
18 var audio = new Audio(audioSrc); |
|
19 ok(typeof audio == "object", "Instantiated 'Audio' object instance should be of type 'object.'"); |
|
20 ok(audio.src != null && typeof audio.src != 'undefined', "Instantiated 'Audio' object's 'src' property should not be null or undefined."); |
|
21 ok(audio.src == audioSrc, "Instantiated 'Audio' object's 'src' property should match constructor parameter."); |
|
22 ok(audio.loop != null && typeof audio.loop != 'undefined', "Instantiated 'Audio' object's 'loop' property should not be null or undefined."); |
|
23 ok(audio.loop == false, "Instantiated 'Audio' object's 'loop' property should initially be false."); |
|
24 ok(typeof audio.error != 'undefined', "Instantiated 'Audio' object's 'error' property should not undefined."); |
|
25 ok(audio.error == null, "Instantiated 'Audio' object's 'error' should initially be null."); |
|
26 }; |