aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/testing/fs/blob_test.html
blob: f802d7546dc28276f6e474ddc0cd1e5a5a0b70e9 (plain)
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
<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
-->
<head>
<title>Closure Unit Tests - goog.testing.fs.Blob</title>
<script src="../../base.js"></script>
<script>
goog.require('goog.testing.fs.Blob');
goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>

function testAttributes() {
  var blob = new goog.testing.fs.Blob();
  assertEquals(0, blob.size);
  assertEquals('', blob.type);

  blob = new goog.testing.fs.Blob('foo bar baz');
  assertEquals(11, blob.size);
  assertEquals('', blob.type);

  blob = new goog.testing.fs.Blob('foo bar baz', 'text/plain');
  assertEquals(11, blob.size);
  assertEquals('text/plain', blob.type);
}

function testToString() {
  assertEquals('', new goog.testing.fs.Blob().toString());
  assertEquals('foo bar', new goog.testing.fs.Blob('foo bar').toString());
}

function testSlice() {
  var blob = new goog.testing.fs.Blob('abcdef');
  assertEquals('bc', blob.slice(1, 2).toString());
  assertEquals('def', blob.slice(3, 10).toString());
  assertEquals('', blob.slice(10, 1).toString());
  assertEquals('a', blob.slice(-1, 1).toString());

  assertEquals('text/plain', blob.slice(1, 2, 'text/plain').type);
}

function testSetDataInternal() {
  var blob = new goog.testing.fs.Blob();

  blob.setDataInternal('asdf');
  assertEquals('asdf', blob.toString());
  assertEquals(4, blob.size);

  blob.setDataInternal('');
  assertEquals('', blob.toString());
  assertEquals(0, blob.size);
}

</script>
</body>
</html>