()
| 1842 | } |
| 1843 | |
| 1844 | function Sandbox() { |
| 1845 | var sandbox = this; |
| 1846 | var collection = []; |
| 1847 | var fakeRestorers = []; |
| 1848 | var promiseLib; |
| 1849 | |
| 1850 | sandbox.serverPrototype = fakeServer; |
| 1851 | |
| 1852 | // this is for testing only |
| 1853 | sandbox.getFakes = function getFakes() { |
| 1854 | return collection; |
| 1855 | }; |
| 1856 | |
| 1857 | // this is for testing only |
| 1858 | sandbox.getRestorers = function() { |
| 1859 | return fakeRestorers; |
| 1860 | }; |
| 1861 | |
| 1862 | sandbox.createStubInstance = function createStubInstance(constructor) { |
| 1863 | if (typeof constructor !== "function") { |
| 1864 | throw new TypeError("The constructor should be a function."); |
| 1865 | } |
| 1866 | return this.stub(Object.create(constructor.prototype)); |
| 1867 | }; |
| 1868 | |
| 1869 | sandbox.inject = function inject(obj) { |
| 1870 | obj.spy = function() { |
| 1871 | return sandbox.spy.apply(null, arguments); |
| 1872 | }; |
| 1873 | |
| 1874 | obj.stub = function() { |
| 1875 | return sandbox.stub.apply(null, arguments); |
| 1876 | }; |
| 1877 | |
| 1878 | obj.mock = function() { |
| 1879 | return sandbox.mock.apply(null, arguments); |
| 1880 | }; |
| 1881 | |
| 1882 | if (sandbox.clock) { |
| 1883 | obj.clock = sandbox.clock; |
| 1884 | } |
| 1885 | |
| 1886 | if (sandbox.server) { |
| 1887 | obj.server = sandbox.server; |
| 1888 | obj.requests = sandbox.server.requests; |
| 1889 | } |
| 1890 | |
| 1891 | obj.match = match; |
| 1892 | |
| 1893 | return obj; |
| 1894 | }; |
| 1895 | |
| 1896 | sandbox.mock = function mock() { |
| 1897 | var m = sinonMock.apply(null, arguments); |
| 1898 | |
| 1899 | push(collection, m); |
| 1900 | usePromiseLibrary(promiseLib, m); |
| 1901 |
nothing calls this directly
no test coverage detected