From fbde1ae069722fd1630434b3fb9af93e323b9765 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 6 Aug 2016 05:47:29 +1000 Subject: [PATCH] Isolate runner's logic from entry-point --- bin/atom-mocha | 25 ------------------------- lib/main.js | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/bin/atom-mocha b/bin/atom-mocha index fc8d350..2d50c1b 100755 --- a/bin/atom-mocha +++ b/bin/atom-mocha @@ -1,30 +1,5 @@ #!/usr/local/bin/node --es_staging "use strict"; -/** Bring on a real test-runner */ -const Mocha = require("mocha"); -const Chai = require("chai"); -Chai.should(); - - -/** Check if an element contains one or more CSS classes */ -Chai.Assertion.addMethod("class", function(classNames){ - const subject = Chai.util.flag(this, "object"); - const classList = subject.classList; - - if(!Array.isArray(classNames)) - classNames = classNames.split(/\s+/g); - - for(let name of classNames){ - this.assert( - classList.contains(name), - "expected classList '" + subject.className + "' to include #{exp}", - "expected classList '" + subject.className + "' not to include #{exp}", - name - ); - } -}); - - /** Connect Atom to our test runner */ module.exports = require("../lib/main.js"); diff --git a/lib/main.js b/lib/main.js index e40f0e6..15eecb7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -5,6 +5,31 @@ const fs = require("fs"); const path = require("path"); +/** Bring on a real test-runner */ +const Mocha = require("mocha"); +const Chai = require("chai"); +Chai.should(); + + +/** Check if an element contains one or more CSS classes */ +Chai.Assertion.addMethod("class", function(classNames){ + const subject = Chai.util.flag(this, "object"); + const classList = subject.classList; + + if(!Array.isArray(classNames)) + classNames = classNames.split(/\s+/g); + + for(let name of classNames){ + this.assert( + classList.contains(name), + "expected classList '" + subject.className + "' to include #{exp}", + "expected classList '" + subject.className + "' not to include #{exp}", + name + ); + } +}); + + const patchReporter = require("./reporter-patch"); module.exports = function(args){