Debian Codegraph @

closure-library/closure/goog/testing/fs/fs_test.js

raw
1 // Copyright 2011 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.provide('goog.testing.fsTest');
16 goog.setTestOnly('goog.testing.fsTest');
17
18 goog.require('goog.testing.fs');
19 goog.require('goog.testing.fs.Blob');
20 goog.require('goog.testing.jsunit');
21
22 function testObjectUrls() {
23 var blob = goog.testing.fs.getBlob('foo');
24 var url = goog.testing.fs.createObjectUrl(blob);
25 assertTrue(goog.testing.fs.isObjectUrlGranted(blob));
26 goog.testing.fs.revokeObjectUrl(url);
27 assertFalse(goog.testing.fs.isObjectUrlGranted(blob));
28 }
29
30 function testGetBlob() {
31 assertEquals(
32 new goog.testing.fs.Blob('foobarbaz').toString(),
33 goog.testing.fs.getBlob('foo', 'bar', 'baz').toString());
34 assertEquals(
35 new goog.testing.fs.Blob('foobarbaz').toString(),
36 goog.testing.fs.getBlob('foo', new goog.testing.fs.Blob('bar'), 'baz')
37 .toString());
38 }
39
40 function testBlobToString() {
41 return goog.testing.fs.blobToString(new goog.testing.fs.Blob('foobarbaz'))
42 .then(function(result) { assertEquals('foobarbaz', result); });
43 }
44
45 function testGetBlobWithProperties() {
46 assertEquals(
47 'data:spam/eggs;base64,Zm9vYmFy',
48 new goog.testing.fs
49 .getBlobWithProperties(
50 ['foo', new goog.testing.fs.Blob('bar')], 'spam/eggs')
51 .toDataUrl());
52 }
53
54 function testSliceBlob() {
55 myBlob = new goog.testing.fs.Blob('0123456789');
56 actual = new goog.testing.fs.sliceBlob(myBlob, 1, 3);
57 expected = new goog.testing.fs.Blob('12');
58 assertEquals(expected.toString(), actual.toString());
59
60 myBlob = new goog.testing.fs.Blob('0123456789');
61 actual = new goog.testing.fs.sliceBlob(myBlob, 0, -1);
62 expected = new goog.testing.fs.Blob('012345678');
63 assertEquals(expected.toString(), actual.toString());
64 }