OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library blob_test; | |
6 import 'package:unittest/unittest.dart'; | |
7 import 'package:unittest/html_config.dart'; | |
8 import 'dart:html'; | 5 import 'dart:html'; |
9 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
10 | 7 |
| 8 import 'package:minitest/minitest.dart'; |
| 9 |
11 main() { | 10 main() { |
12 useHtmlConfiguration(); | |
13 | |
14 test('basic', () { | 11 test('basic', () { |
15 var b = new Blob([]); | 12 var b = new Blob([]); |
16 expect(b.size, isZero); | 13 expect(b.size, 0); |
17 }); | 14 }); |
18 | 15 |
19 test('type1', () { | 16 test('type1', () { |
20 // OPTIONALS var b = new Blob(['Harry'], type: 'text'); | 17 // OPTIONALS var b = new Blob(['Harry'], type: 'text'); |
21 var b = new Blob(['Harry'], 'text'); | 18 var b = new Blob(['Harry'], 'text'); |
22 expect(b.size, 5); | 19 expect(b.size, 5); |
23 expect(b.type, 'text'); | 20 expect(b.type, 'text'); |
24 }); | 21 }); |
25 | 22 |
26 test('endings1', () { | 23 test('endings1', () { |
27 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'transparent'); | 24 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'transparent'); |
28 var b = new Blob(['A\nB\n'], null, 'transparent'); | 25 var b = new Blob(['A\nB\n'], null, 'transparent'); |
29 expect(b.size, 4); | 26 expect(b.size, 4); |
30 }); | 27 }); |
31 | 28 |
32 test('endings2', () { | 29 test('endings2', () { |
33 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'native'); | 30 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'native'); |
34 var b = new Blob(['A\nB\n'], null, 'native'); | 31 var b = new Blob(['A\nB\n'], null, 'native'); |
35 expect(b.size, (x) => x == 4 || x == 6, | 32 expect(b.size, predicate((x) => x == 4 || x == 6), |
36 reason: "b.size should be 4 or 6"); | 33 reason: "b.size should be 4 or 6"); |
37 }); | 34 }); |
38 | 35 |
39 test('twoStrings', () { | 36 test('twoStrings', () { |
40 // OPTIONALS var b = new Blob(['123', 'xyz'], type: 'text/plain;charset=UT
F-8'); | 37 // OPTIONALS var b = new Blob(['123', 'xyz'], type: 'text/plain;charset=UT
F-8'); |
41 var b = new Blob(['123', 'xyz'], 'text/plain;charset=UTF-8'); | 38 var b = new Blob(['123', 'xyz'], 'text/plain;charset=UTF-8'); |
42 expect(b.size, 6); | 39 expect(b.size, 6); |
43 }); | 40 }); |
44 | 41 |
45 test('fromBlob1', () { | 42 test('fromBlob1', () { |
46 var b1 = new Blob([]); | 43 var b1 = new Blob([]); |
47 var b2 = new Blob([b1]); | 44 var b2 = new Blob([b1]); |
48 expect(b2.size, isZero); | 45 expect(b2.size, 0); |
49 }); | 46 }); |
50 | 47 |
51 test('fromBlob2', () { | 48 test('fromBlob2', () { |
52 var b1 = new Blob(['x']); | 49 var b1 = new Blob(['x']); |
53 var b2 = new Blob([b1, b1]); | 50 var b2 = new Blob([b1, b1]); |
54 expect(b1.size, 1); | 51 expect(b1.size, 1); |
55 expect(b2.size, 2); | 52 expect(b2.size, 2); |
56 }); | 53 }); |
57 | 54 |
58 test('fromArrayBuffer', () { | 55 test('fromArrayBuffer', () { |
59 var a = new Uint8List(100).buffer; // i.e. new ArrayBuffer(100); | 56 var a = new Uint8List(100).buffer; // i.e. new ArrayBuffer(100); |
60 var b = new Blob([a, a]); | 57 var b = new Blob([a, a]); |
61 expect(b.size, 200); | 58 expect(b.size, 200); |
62 }); | 59 }); |
63 } | 60 } |
OLD | NEW |