forked from mattdiamond/fuckitjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes mattdiamond#1
- Loading branch information
Showing
13 changed files
with
12,279 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008-2019 Pivotal Labs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
To run the tests: | ||
|
||
1. Run npm serve (or something else that gives you a simple web server | ||
from the root directory (NOT this directory). | ||
2. Visit http://localhost:<whatever port it's using>/tests/SpecRunner.html. | ||
|
||
This is a bit of a pain, but you can't just load the file from a file:// | ||
URL because of CORS. And you can't use jasmine-browser-runner either, | ||
because it cares too much about errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Jasmine Spec Runner v5.0.1</title> | ||
|
||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-5.0.1/jasmine_favicon.png"> | ||
<link rel="stylesheet" href="lib/jasmine-5.0.1/jasmine.css"> | ||
|
||
<script src="lib/jasmine-5.0.1/jasmine.js"></script> | ||
<script src="lib/jasmine-5.0.1/jasmine-html.js"></script> | ||
<script src="customBoot0.js"></script> | ||
<script src="customBoot1.js"></script> | ||
|
||
<!-- Might need this ancient jquery because nobody's been keeping fuckit.js up to date --> | ||
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> | ||
<script> | ||
window.FUCKIT_URL = '../fuckit.js'; | ||
</script> | ||
<script type='text/javascript' src='../fuckit.js'></script> | ||
<script type='text/javascript' src='fuckitSpecLoader.js'></script> | ||
|
||
<script> | ||
// Bad Things happen if we ask fuckit to load two things concurrently, | ||
// so don't. | ||
(function() { | ||
const p1 = fuckitSpecLoader('./spec/maybeASpec.js'); | ||
const p2 = p1.then(function() { | ||
return fuckitSpecLoader('./spec/actuallyASpec.js'); | ||
}); | ||
jasmineSpecReadyPromises.push(p2); | ||
}()); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright (c) 2008-2023 Pivotal Labs | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
/** | ||
This file starts the process of "booting" Jasmine. It initializes Jasmine, | ||
makes its globals available, and creates the env. This file should be loaded | ||
after `jasmine.js` and `jasmine_html.js`, but before `boot1.js` or any project | ||
source files or spec files are loaded. | ||
*/ | ||
(function() { | ||
const jasmineRequire = window.jasmineRequire || require('./jasmine.js'); | ||
|
||
/** | ||
* ## Require & Instantiate | ||
* | ||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. | ||
*/ | ||
const jasmine = jasmineRequire.core(jasmineRequire), | ||
global = jasmine.getGlobal(); | ||
global.jasmine = jasmine; | ||
|
||
/** | ||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. | ||
*/ | ||
jasmineRequire.html(jasmine); | ||
|
||
/** | ||
* Create the Jasmine environment. This is used to run all specs in a project. | ||
*/ | ||
const env = jasmine.getEnv({ | ||
// Stop Jasmine from reporting errors that fuckit.js will fix | ||
suppressLoadErrors: true | ||
}); | ||
|
||
/** | ||
* ## The Global Interface | ||
* | ||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. | ||
*/ | ||
const jasmineInterface = jasmineRequire.interface(jasmine, env); | ||
|
||
/** | ||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. | ||
*/ | ||
for (const property in jasmineInterface) { | ||
global[property] = jasmineInterface[property]; | ||
} | ||
|
||
window.jasmineSpecReadyPromises = []; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
Copyright (c) 2008-2023 Pivotal Labs | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
/** | ||
This file finishes 'booting' Jasmine, performing all of the necessary | ||
initialization before executing the loaded environment and all of a project's | ||
specs. This file should be loaded after `boot0.js` but before any project | ||
source files or spec files are loaded. Thus this file can also be used to | ||
customize Jasmine for a project. | ||
If a project is using Jasmine via the standalone distribution, this file can | ||
be customized directly. If you only wish to configure the Jasmine env, you | ||
can load another file that calls `jasmine.getEnv().configure({...})` | ||
after `boot0.js` is loaded and before this file is loaded. | ||
*/ | ||
|
||
(function() { | ||
const env = jasmine.getEnv(); | ||
|
||
/** | ||
* ## Runner Parameters | ||
* | ||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. | ||
*/ | ||
|
||
const queryString = new jasmine.QueryString({ | ||
getWindowLocation: function() { | ||
return window.location; | ||
} | ||
}); | ||
|
||
const filterSpecs = !!queryString.getParam('spec'); | ||
|
||
const config = { | ||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'), | ||
stopSpecOnExpectationFailure: queryString.getParam( | ||
'stopSpecOnExpectationFailure' | ||
), | ||
hideDisabled: queryString.getParam('hideDisabled') | ||
}; | ||
|
||
const random = queryString.getParam('random'); | ||
|
||
if (random !== undefined && random !== '') { | ||
config.random = random; | ||
} | ||
|
||
const seed = queryString.getParam('seed'); | ||
if (seed) { | ||
config.seed = seed; | ||
} | ||
|
||
/** | ||
* ## Reporters | ||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). | ||
*/ | ||
const htmlReporter = new jasmine.HtmlReporter({ | ||
env: env, | ||
navigateWithNewParam: function(key, value) { | ||
return queryString.navigateWithNewParam(key, value); | ||
}, | ||
addToExistingQueryString: function(key, value) { | ||
return queryString.fullStringWithNewParam(key, value); | ||
}, | ||
getContainer: function() { | ||
return document.body; | ||
}, | ||
createElement: function() { | ||
return document.createElement.apply(document, arguments); | ||
}, | ||
createTextNode: function() { | ||
return document.createTextNode.apply(document, arguments); | ||
}, | ||
timer: new jasmine.Timer(), | ||
filterSpecs: filterSpecs | ||
}); | ||
|
||
/** | ||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. | ||
*/ | ||
env.addReporter(jsApiReporter); | ||
env.addReporter(htmlReporter); | ||
|
||
/** | ||
* Filter which specs will be run by matching the start of the full name against the `spec` query param. | ||
*/ | ||
const specFilter = new jasmine.HtmlSpecFilter({ | ||
filterString: function() { | ||
return queryString.getParam('spec'); | ||
} | ||
}); | ||
|
||
config.specFilter = function(spec) { | ||
return specFilter.matches(spec.getFullName()); | ||
}; | ||
|
||
env.configure(config); | ||
|
||
/** | ||
* ## Execution | ||
* | ||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. | ||
*/ | ||
const currentWindowOnload = window.onload; | ||
|
||
window.onload = function() { | ||
if (currentWindowOnload) { | ||
currentWindowOnload(); | ||
} | ||
|
||
// Need to wait for fuckit.js before we start | ||
Promise.all(window.jasmineSpecReadyPromises).then(function() { | ||
htmlReporter.initialize(); | ||
env.execute(); | ||
}); | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Eat our own dog food | ||
window.fuckitSpecLoader = function(specUrl) { | ||
return new Promise(function(resolve /* no reject, obviously */) { | ||
$(document).ready(function() { | ||
console.log('trying to load', specUrl); | ||
FuckIt(specUrl).then( | ||
function() { | ||
// TODO collapse this out once working | ||
console.log('resolving', specUrl); | ||
resolve(); | ||
}, | ||
function() { | ||
// TODO | ||
console.error('oh no'); | ||
} | ||
); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.