|
1 | | -QUnit.module( "core", { teardown: moduleTeardown } ); |
| 1 | +QUnit.module( "core", { |
| 2 | + setup: function() { |
| 3 | + this.sandbox = sinon.sandbox.create(); |
| 4 | + }, |
| 5 | + teardown: function() { |
| 6 | + this.sandbox.restore(); |
| 7 | + return moduleTeardown.apply( this, arguments ); |
| 8 | + } |
| 9 | +} ); |
2 | 10 |
|
3 | 11 | QUnit.test( "Basic requirements", function( assert ) { |
4 | 12 | assert.expect( 7 ); |
@@ -1709,3 +1717,41 @@ QUnit.test( "Iterability of jQuery objects (gh-1693)", function( assert ) { |
1709 | 1717 | assert.ok( true, "The browser doesn't support Symbols" ); |
1710 | 1718 | } |
1711 | 1719 | } ); |
| 1720 | + |
| 1721 | +QUnit[ jQuery.Deferred ? "test" : "skip" ]( "jQuery.readyException (original)", function( assert ) { |
| 1722 | + assert.expect( 1 ); |
| 1723 | + |
| 1724 | + var message; |
| 1725 | + |
| 1726 | + this.sandbox.stub( window, "setTimeout", function( fn ) { |
| 1727 | + try { |
| 1728 | + fn(); |
| 1729 | + } catch ( error ) { |
| 1730 | + message = error.message; |
| 1731 | + } |
| 1732 | + } ); |
| 1733 | + |
| 1734 | + jQuery( function() { |
| 1735 | + throw new Error( "Error in jQuery ready" ); |
| 1736 | + } ); |
| 1737 | + assert.strictEqual( message, "Error in jQuery ready", "The error wasn't thrown in a timeout" ); |
| 1738 | +} ); |
| 1739 | + |
| 1740 | +QUnit[ jQuery.Deferred ? "test" : "skip" ]( "jQuery.readyException (custom)", function( assert ) { |
| 1741 | + assert.expect( 1 ); |
| 1742 | + |
| 1743 | + var done = assert.async(); |
| 1744 | + |
| 1745 | + this.sandbox.stub( jQuery, "readyException", function( error ) { |
| 1746 | + assert.strictEqual( |
| 1747 | + error.message, |
| 1748 | + "Error in jQuery ready", |
| 1749 | + "The custom jQuery.readyException wasn't called" |
| 1750 | + ); |
| 1751 | + done(); |
| 1752 | + } ); |
| 1753 | + |
| 1754 | + jQuery( function() { |
| 1755 | + throw new Error( "Error in jQuery ready" ); |
| 1756 | + } ); |
| 1757 | +} ); |
0 commit comments