Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pmoo/testy

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pmoo/testy - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

132

lib/core/equality_assertion_strategy.js
'use strict';
import { deepStrictEqual, isCyclic, isFunction, isString, isUndefined, respondsTo } from '../utils.js';
import {
deepStrictEqual,
isCyclic,
isFunction,
isString,
isUndefined,
respondsTo,
subclassResponsibility,
} from '../utils.js';
import { I18nMessage } from '../i18n/i18n_messages.js';
export const EqualityAssertionStrategy = {
availableStrategies() {
export class EqualityAssertionStrategy {
static evaluate(actual, expected, criteria) {
return this.#availableStrategies()
.find(strategy => strategy.appliesTo(actual, expected, criteria))
.evaluate(actual, expected, criteria);
}
static #availableStrategies() {
return [
BothPartsUndefined,
CustomFunction,
CustomPropertyName,
ObjectWithEqualsProperty,
ObjectWithCyclicReference,
DefaultEquality,
new BothPartsUndefined(),
new CustomFunction(),
new CustomPropertyName(),
new ObjectWithEqualsProperty(),
new ObjectWithCyclicReference(),
new DefaultEquality(),
];
},
}
evaluate(actual, expected, criteria) {
return this.availableStrategies()
.find(strategy => strategy.appliesTo(actual, expected, criteria))
.evaluate(actual, expected, criteria);
},
};
appliesTo(_actual, _expected) {
return false;
}
const BothPartsUndefined = {
__proto__: EqualityAssertionStrategy,
evaluate(_actual, _expected, _criterie) {
return subclassResponsibility();
}
}
class BothPartsUndefined extends EqualityAssertionStrategy {
appliesTo(actual, expected) {
return isUndefined(actual) && isUndefined(expected);
},
}
evaluate() {
evaluate(_actual, _expected, _criterie) {
return {

@@ -37,11 +51,9 @@ comparisonResult: undefined,

};
},
};
}
}
const CustomFunction = {
__proto__: EqualityAssertionStrategy,
class CustomFunction extends EqualityAssertionStrategy {
appliesTo(_actual, _expected, criteria) {
return isFunction(criteria);
},
}

@@ -53,25 +65,23 @@ evaluate(actual, expected, criteria) {

};
},
};
}
}
const CustomPropertyName = {
__proto__: EqualityAssertionStrategy,
class CustomPropertyName extends EqualityAssertionStrategy {
appliesTo(_actual, _expected, criteria) {
return isString(criteria);
},
}
evaluate(actual, expected, criteria) {
if (this._comparisonCanBeMade(actual, expected, criteria)) {
return this._compareUsingCustomCriteria(actual, expected, criteria);
if (this.#comparisonCanBeMade(actual, expected, criteria)) {
return this.#compareUsingCustomCriteria(actual, expected, criteria);
} else {
return this._failWithCriteriaNotFoundMessage(criteria);
return this.#failWithCriteriaNotFoundMessage(criteria);
}
},
}
_comparisonCanBeMade(actual, expected, criteria) {
#comparisonCanBeMade(actual, expected, criteria) {
return respondsTo(actual, criteria) && respondsTo(expected, criteria);
},
}
_compareUsingCustomCriteria(actual, expected, criteria) {
#compareUsingCustomCriteria(actual, expected, criteria) {
return {

@@ -81,5 +91,5 @@ comparisonResult: actual[criteria](expected),

};
},
}
_failWithCriteriaNotFoundMessage(criteria) {
#failWithCriteriaNotFoundMessage(criteria) {
return {

@@ -89,13 +99,11 @@ comparisonResult: false,

};
},
};
}
}
const ObjectWithEqualsProperty = {
__proto__: EqualityAssertionStrategy,
class ObjectWithEqualsProperty extends EqualityAssertionStrategy {
appliesTo(actual, _expected) {
return respondsTo(actual, 'equals');
},
}
evaluate(actual, expected) {
evaluate(actual, expected, _criteria) {
return {

@@ -105,13 +113,11 @@ comparisonResult: actual.equals(expected),

};
},
};
}
}
const ObjectWithCyclicReference = {
__proto__: EqualityAssertionStrategy,
class ObjectWithCyclicReference extends EqualityAssertionStrategy {
appliesTo(actual, expected) {
return isCyclic(actual) || isCyclic(expected);
},
}
evaluate(_actual, _expected) {
evaluate(_actual, _expected, _criteria) {
return {

@@ -121,13 +127,11 @@ comparisonResult: false,

};
},
};
}
}
const DefaultEquality = {
__proto__: EqualityAssertionStrategy,
class DefaultEquality extends EqualityAssertionStrategy {
appliesTo(_actual, _expected) {
return true;
},
}
evaluate(actual, expected) {
evaluate(actual, expected, _criteria) {
return {

@@ -137,3 +141,3 @@ comparisonResult: deepStrictEqual(actual, expected),

};
},
};
}
}

@@ -19,3 +19,3 @@ 'use strict';

#randomOrder;
#testExecutiontimeoutMs;
#testExecutionTimeoutMs;

@@ -63,3 +63,3 @@ constructor(callbacks) {

setTestExecutionTimeoutMs(timeoutMs) {
this.#testExecutiontimeoutMs = timeoutMs;
this.#testExecutionTimeoutMs = timeoutMs;
}

@@ -141,3 +141,3 @@

randomOrderMode: this.#randomOrder,
testExecutionTimeoutMs: this.#testExecutiontimeoutMs,
testExecutionTimeoutMs: this.#testExecutionTimeoutMs,
};

@@ -144,0 +144,0 @@ }

@@ -6,3 +6,3 @@ {

"total": "Total tests:",
"total_time": "total time",
"total_time": "Total time",
"wip": "WIP",

@@ -64,3 +64,3 @@ "skip": "SKIP",

"total": "Total de tests:",
"total_time": "tiempo total",
"total_time": "Tiempo total",
"wip": "PENDIENTE",

@@ -122,3 +122,3 @@ "skip": "NO EJECUTADO",

"total": "Test totali:",
"total_time": "tempo totale",
"total_time": "Tempo totale",
"wip": "IN CORSO",

@@ -125,0 +125,0 @@ "skip": "SALTA",

@@ -56,3 +56,3 @@ 'use strict';

onFinish: runner =>
this.#formatter.displayRunnerEnd(runner),
this.onRunnerFinish(runner),
onSuccess: _runner =>

@@ -68,6 +68,5 @@ this.#exitWithCode(ConsoleUI.successfulExitCode()),

async start(configuration, paths, runnerBlock) {
this.#formatter.start();
this.#formatter.startTimer();
this.#formatter.displayInitialInformation(configuration, paths);
await runnerBlock.call();
this.#formatter.end();
}

@@ -87,2 +86,7 @@

onRunnerFinish(runner) {
this.#formatter.displayRunnerEnd(runner);
this.#formatter.endTimer();
}
// private

@@ -89,0 +93,0 @@

@@ -27,7 +27,7 @@ 'use strict';

start() {
startTimer() {
this.#console.time(this.#timerName);
}
end() {
endTimer() {
this.#console.timeEnd(this.#timerName);

@@ -34,0 +34,0 @@ }

{
"name": "@pmoo/testy",
"version": "7.0.0",
"version": "7.0.1",
"description": "A minimal testing framework, for educational purposes.",

@@ -5,0 +5,0 @@ "homepage": "https://ngarbezza.github.io/testy/",

@@ -8,3 +8,3 @@ # Testy

[![coverage](https://img.shields.io/codeclimate/coverage/ngarbezza/testy?logo=code-climate)](https://codeclimate.com/github/ngarbezza/testy)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fngarbezza%2Ftesty%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/ngarbezza/testy/main)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&logo=stryker&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fngarbezza%2Ftesty%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/ngarbezza/testy/main)
\

@@ -16,9 +16,9 @@ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ngarbezza_testy&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ngarbezza_testy)

\
![GitHub Repo stars](https://img.shields.io/github/stars/ngarbezza/testy?style=flat&logo=github)
![open-issues](https://img.shields.io/github/issues-raw/ngarbezza/testy?logo=github)
![closed-issues](https://img.shields.io/github/issues-closed-raw/ngarbezza/testy?logo=github)
![open-prs](https://img.shields.io/github/issues-pr-raw/ngarbezza/testy?logo=github)
\
![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@pmoo/testy.svg?logo=npm)
\
![downloads](https://img.shields.io/npm/dt/@pmoo/testy.svg?logo=npm)
![dependencies](https://img.shields.io/librariesio/release/npm/@pmoo/testy)
![dependencies](https://img.shields.io/librariesio/release/npm/@pmoo/testy?logo=npm)
\

@@ -25,0 +25,0 @@ ![package-size](https://img.shields.io/bundlephobia/min/@pmoo/testy.svg?logo=npm)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc