Skip to content

Commit

Permalink
Use exported speclj functions over cljs.core methods in js script
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoncorrea committed May 28, 2024
1 parent 934d94f commit 8e01665
Showing 1 changed file with 43 additions and 50 deletions.
93 changes: 43 additions & 50 deletions bin/specs.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="iso-8859-1" content="text/html" http-equiv="Content-Type"/>
<title>Speclj Specs</title>
<!--<script src="../js/es5-shim.js" type="text/javascript"></script>-->
<script src="../target/cljs/goog/base.js" type="text/javascript"></script>
<script src="../target/specs.js" type="text/javascript"></script>
<script type="text/javascript">
String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
<meta charset="iso-8859-1" content="text/html" http-equiv="Content-Type"/>
<title>Speclj Specs</title>
<!--<script src="../js/es5-shim.js" type="text/javascript"></script>-->
<script src="../target/cljs/goog/base.js" type="text/javascript"></script>
<script src="../target/specs.js" type="text/javascript"></script>
<script type="text/javascript">
String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1
}

// Load all the specs
for (var k in goog.debugLoader_.dependencies_) {
var dep = goog.debugLoader_.dependencies_[k];
for (var i = 0; i < dep.provides.length; i++) {
var ns = dep.provides[i];
// console.log(ns);
if (ns.endsWith("_spec")) {
goog.require(ns)
}
}
}
// Load all the specs
for (let k in goog.debugLoader_.dependencies_) {
let dep = goog.debugLoader_.dependencies_[k]
dep.provides
.filter(ns => ns.endsWith("_spec"))
.forEach(goog.require)
}

runSpecsConfigured = function (color, reporter) {
speclj.run.standard.arm();
return speclj.run.standard.run_specs(
"color", color, "reporters", [reporter]
);
};
runSpecsConfigured = function (color, reporter) {
speclj.run.standard.arm()
return speclj.run.standard.run_specs(
"color", color,
"reporters", [reporter]
)
}

runSpecs = function () {
return runSpecsConfigured(false, "documentation");
}
runSpecs = function () {
return runSpecsConfigured(false, "documentation")
}

runSpecsFiltered = function (affectedSpecs) {
if (affectedSpecs != null) {
console.log("Only running affected specs:");
var descriptionAtom = speclj.config.active_runner().descriptions;
cljs.core.swap_BANG_(descriptionAtom, function (descriptions) {
return cljs.core.filter(function (description) {
return description.ns in affectedSpecs;
}, descriptions);
});
cljs.core.doall(cljs.core.map(function (description) {
console.log(" ", description.ns);
}, cljs.core.deref(descriptionAtom)));
}
return runSpecsConfigured(true, "documentation");
}
</script>
runSpecsFiltered = function (affectedSpecs) {
if (affectedSpecs != null) {
console.log("Only running affected specs:")
var runner = speclj.config.active_runner()
speclj.running.filter_descriptions(runner, affectedSpecs)
speclj.running.get_descriptions(runner)
.forEach((description) =>
console.log(" ", description.ns))
}
return runSpecsConfigured(true, "documentation")
}
</script>
</head>
<body>
<h3 style="margin: 1em">Speclj CLJS Specs</h3>

<p style="margin: 1em; width: 400px;">
Typically these specs are run using a headless browser driven by a script.
But you can run them here if you like.
That is, assuming all the cljs has been compiled in development.
<br/>
Open up the browser console:
Typically these specs are run using a headless browser driven by a script.
But you can run them here if you like.
That is, assuming all the cljs has been compiled in development.
<br/>
Open up the browser console:
</p>
<pre style="margin: 1em; padding: 1em; width: 400px; border: 1px dotted slategray; background-color: lightgray;">
runSpecs()
Expand Down

0 comments on commit 8e01665

Please sign in to comment.