Skip to content

Commit

Permalink
Build: Update to latest semistandard
Browse files Browse the repository at this point in the history
Sorry, I can quite fluidly remember and adapt to different
spacing styles between projects with almost no context switch,
but absence/presence of semicolons traps I just can't remember
to do correctly. Switching to semistandard to align more closely
with QUnit and other jQuery projects.
  • Loading branch information
Krinkle committed Sep 7, 2020
1 parent 6e3bc32 commit 04bdd8a
Show file tree
Hide file tree
Showing 26 changed files with 2,212 additions and 774 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": "semistandard"
}
30 changes: 3 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

dist
/dist
/node_modules
/*.log
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import QUnitAdapter from './lib/adapters/QUnitAdapter.js'
import JasmineAdapter from './lib/adapters/JasmineAdapter.js'
import MochaAdapter from './lib/adapters/MochaAdapter.js'
import TapReporter from './lib/reporters/TapReporter.js'
import ConsoleReporter from './lib/reporters/ConsoleReporter.js'
import {Assertion, TestStart, TestEnd, SuiteStart, SuiteEnd} from './lib/Data.js'
import QUnitAdapter from './lib/adapters/QUnitAdapter.js';
import JasmineAdapter from './lib/adapters/JasmineAdapter.js';
import MochaAdapter from './lib/adapters/MochaAdapter.js';
import TapReporter from './lib/reporters/TapReporter.js';
import ConsoleReporter from './lib/reporters/ConsoleReporter.js';
import {Assertion, TestStart, TestEnd, SuiteStart, SuiteEnd} from './lib/Data.js';
import {autoRegister, createSuiteStart, createTestStart,
createTestEnd, createSuiteEnd} from './lib/helpers.js'
createTestEnd, createSuiteEnd} from './lib/helpers.js';

export default {
QUnitAdapter,
Expand All @@ -23,4 +23,4 @@ export default {
createTestEnd,
createSuiteEnd,
autoRegister
}
};
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ module.exports = function (config) {
browsers: ['PhantomJS'],
singleRun: true,
concurrency: Infinity
})
}
});
};
102 changes: 51 additions & 51 deletions lib/Data.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
function getAllTests (suite) {
var childSuiteTests = suite.childSuites
.map((childSuite) => getAllTests(childSuite))
.reduce((allTests, a) => allTests.concat(a), [])
.reduce((allTests, a) => allTests.concat(a), []);

return suite.tests.concat(childSuiteTests)
return suite.tests.concat(childSuiteTests);
}

function getRuntime (suite) {
if (suite.status === 'skipped' || suite.status === undefined) {
return undefined
return undefined;
}

return getAllTests(suite)
.map((test) => test.status === 'skipped' ? 0 : test.runtime)
.reduce((sum, testRuntime) => sum + testRuntime, 0)
.reduce((sum, testRuntime) => sum + testRuntime, 0);
}

function getStatus (suite) {
var passed = 0
var failed = 0
var skipped = 0
var todo = 0
var tests = getAllTests(suite)
var passed = 0;
var failed = 0;
var skipped = 0;
var todo = 0;
var tests = getAllTests(suite);

for (let i = 0; i < tests.length; i++) {
let test = tests[i]
let test = tests[i];

// If a suite contains a test whose status is still undefined,
// there is no final status for the suite as well.
if (test.status === undefined) {
return undefined
return undefined;
} else if (test.status === 'passed') {
passed++
passed++;
} else if (test.status === 'skipped') {
skipped++
skipped++;
} else if (test.status === 'todo') {
todo++
todo++;
} else {
failed++
failed++;
}
}

if (failed > 0) {
return 'failed'
return 'failed';
} else if (skipped > 0 && passed === 0) {
return 'skipped'
return 'skipped';
} else if (todo > 0 && passed === 0) {
return 'todo'
return 'todo';
} else {
return 'passed'
return 'passed';
}
}

function getSuiteStartTestCounts (suite) {
var tests = getAllTests(suite)
var tests = getAllTests(suite);

return {
total: tests.length
}
};
}

function getSuiteEndTestCounts (suite) {
var tests = getAllTests(suite)
var tests = getAllTests(suite);

return {
passed: tests.filter((test) => test.status === 'passed').length,
failed: tests.filter((test) => test.status === 'failed').length,
skipped: tests.filter((test) => test.status === 'skipped').length,
todo: tests.filter((test) => test.status === 'todo').length,
total: tests.length
}
};
}

export class Assertion {
Expand All @@ -82,12 +82,12 @@ export class Assertion {
* @param {Boolean} todo
*/
constructor (passed, actual, expected, message, stack, todo) {
this.passed = passed
this.actual = actual
this.expected = expected
this.message = message
this.stack = stack
this.todo = todo
this.passed = passed;
this.actual = actual;
this.expected = expected;
this.message = message;
this.stack = stack;
this.todo = todo;
}
}

Expand All @@ -98,9 +98,9 @@ export class TestStart {
* @param {String[]} fullName
*/
constructor (name, suiteName, fullName) {
this.name = name
this.suiteName = suiteName
this.fullName = fullName
this.name = name;
this.suiteName = suiteName;
this.fullName = fullName;
}
}

Expand All @@ -115,13 +115,13 @@ export class TestEnd {
* @param {Assertion[]} assertions
*/
constructor (name, suiteName, fullName, status, runtime, errors, assertions) {
this.name = name
this.suiteName = suiteName
this.fullName = fullName
this.status = status
this.runtime = runtime
this.errors = errors
this.assertions = assertions
this.name = name;
this.suiteName = suiteName;
this.fullName = fullName;
this.status = status;
this.runtime = runtime;
this.errors = errors;
this.assertions = assertions;
}
}

Expand All @@ -133,11 +133,11 @@ export class SuiteStart {
* @param {Suite[]} childSuites
*/
constructor (name, fullName, tests, childSuites, testCounts) {
this.name = name
this.fullName = fullName
this.tests = tests
this.childSuites = childSuites
this.testCounts = getSuiteStartTestCounts(this)
this.name = name;
this.fullName = fullName;
this.tests = tests;
this.childSuites = childSuites;
this.testCounts = getSuiteStartTestCounts(this);
}
}

Expand All @@ -157,12 +157,12 @@ export class SuiteEnd {
*/
constructor (name, fullName, tests, childSuites, status, testCounts,
runtime) {
this.name = name
this.fullName = fullName
this.tests = tests
this.childSuites = childSuites
this.status = status || getStatus(this)
this.testCounts = testCounts || getSuiteEndTestCounts(this)
this.runtime = runtime || getRuntime(this)
this.name = name;
this.fullName = fullName;
this.tests = tests;
this.childSuites = childSuites;
this.status = status || getStatus(this);
this.testCounts = testCounts || getSuiteEndTestCounts(this);
this.runtime = runtime || getRuntime(this);
}
}
Loading

0 comments on commit 04bdd8a

Please sign in to comment.