* Test filereader.
(assert)
| 571 | * Test filereader. |
| 572 | */ |
| 573 | function testFilereader(assert) { |
| 574 | |
| 575 | var pipe; |
| 576 | |
| 577 | // Test type coercion. |
| 578 | |
| 579 | pipe = new reader.filesReader([ '../termkit.txt' ], function () { |
| 580 | return { begin: function (headers) { |
| 581 | assert(headers.get('Content-Type') == 'text/plain', 'Type for txt'); |
| 582 | } }; |
| 583 | }); |
| 584 | |
| 585 | pipe = new reader.filesReader([ '../Mockups/Shot-0.2.png' ], function () { |
| 586 | return { begin: function (headers) { |
| 587 | assert(headers.get('Content-Type') == 'image/png', 'Type for img'); |
| 588 | } }; |
| 589 | }); |
| 590 | |
| 591 | pipe = new reader.filesReader([ 'router.js' ], function () { |
| 592 | return { begin: function (headers) { |
| 593 | assert(headers.get('Content-Type') == 'application/javascript', 'Type for js'); |
| 594 | } }; |
| 595 | }); |
| 596 | |
| 597 | pipe = new reader.filesReader([ 'test.js', 'router.js' ], function () { |
| 598 | return { begin: function (headers) { |
| 599 | assert(headers.get('Content-Type') == 'application/javascript', 'Type for (js+js)'); |
| 600 | } }; |
| 601 | }); |
| 602 | |
| 603 | pipe = new reader.filesReader([ 'misc.js', 'router.js', 'config.js' ], function () { |
| 604 | return { begin: function (headers) { |
| 605 | assert(headers.get('Content-Type') == 'application/javascript', 'Type for (js+js+js)'); |
| 606 | } }; |
| 607 | }); |
| 608 | |
| 609 | pipe = new reader.filesReader([ 'misc.js', '../termkit.txt' ], function () { |
| 610 | return { begin: function (headers) { |
| 611 | assert(headers.get('Content-Type') == 'text/plain', 'Type for (js+txt)'); |
| 612 | } }; |
| 613 | }); |
| 614 | |
| 615 | pipe = new reader.filesReader([ 'misc.js', '../termkit.txt', '../Mockups/Shot-0.2.png' ], function () { |
| 616 | return { begin: function (headers) { |
| 617 | assert(headers.get('Content-Type') == 'application/octet-stream', 'Type for (js+txt+img)'); |
| 618 | } }; |
| 619 | }); |
| 620 | |
| 621 | } |
| 622 | |
| 623 | |
| 624 | // Run tests. |