New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lazy-assert

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-assert - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

examples/1-mocha/__test/methods-lazy.test.js.report/1-2-plus-3.actual

13

examples/4-mocha-test-api/__test/test-api-lazy.test.js

@@ -23,2 +23,15 @@ var axios = require('axios');

it('测试测试', function () {
var result = /* call() */ {
data: {
user: {
name: 'liang'
},
personList: [1, 4, 3, null, 'abc']
}
};
lazy.peekValidate('something', result)
});
it('测试 get /hello', function (done) {

@@ -25,0 +38,0 @@ instance.get('/hello').then(function (response) {

2

package.json
{
"name": "lazy-assert",
"version": "0.2.12",
"version": "0.2.13",
"description": "An way of doing assertion for lazy people ...",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -16,3 +16,4 @@ var lazy = require('../index');

it('Should create suggest file', function() {
it('Should create related files' +
'', function() {
var _warn = console.warn;

@@ -26,3 +27,3 @@ console.warn = function() {};

var paths = lazy.getReportPaths('temp-peek');
lazy.ok(fs.existsSync(paths.validator), 'expected file should exist');
lazy.ok(fs.existsSync(paths.validator), 'validator file should exist');
lazy.ok(fs.existsSync(paths.suggest), 'suggest file should exist');

@@ -29,0 +30,0 @@

var assert = require('assert');
var utils = require('./utils');
var _ = require('lodash');

@@ -258,6 +259,6 @@ try {

* value: any // This is the value for peeking
* depthOrPlugin: @#.processValue.depthOrPlugin
* depthOrPlugin: #@.processValue.depthOrPlugin
*/
peek: function (peekKey, value, depthOrPlugin) {
lazyAssert.checkArguments(peekKey);
lazyAssert.checkArguments(peekKey, true);

@@ -279,3 +280,4 @@ var paths = lazyAssert.getReportPaths(peekKey);

assert.equal(
actual, expected,
_.trim(actual),
_.trim(expected),
(this.testLocation ? this.testLocation + ' : ' : '')

@@ -309,2 +311,4 @@ + (this._hint ? this._hint + ' : ' : '')

compare: function (peekKey, actualTargetValue, expectedPreparedValue, depthOrPlugin) {
lazyAssert.checkArguments(peekKey, false);
var actualString = utils.trim(lazyAssert.stringify(actualTargetValue, depthOrPlugin));

@@ -336,4 +340,6 @@ var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue));

assertCompare: function (peekKey, actualTargetValue, expectedPreparedValue, depthOrPlugin) {
lazyAssert.checkArguments(peekKey, false);
var actualString = utils.trim(lazyAssert.stringify(actualTargetValue, depthOrPlugin));
var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue, depthOrPlugin));
var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue));

@@ -347,7 +353,37 @@ if (actualString !== expectedString) {

validate: function (peekKey, actualTargetValue, validator) {
if (!peekKey) {
throw utils.newError('no-peek-key', 'No peek key is set for this validation');
peekCompare: function (peekKey, actualTargetValue, depthOrPlugin) {
lazyAssert.checkArguments(peekKey);
var paths = lazyAssert.getReportPaths(peekKey);
var expectedPreparedValue;
if (!fs.existsSync(paths.expectJS)) {
utils.write(paths.expectJS, '__tmp_expect__ = undefined;');
expectedPreparedValue = undefined;
}
else {
expectedPreparedValue = eval(utils.read(paths.expectJS));
}
var actualString = utils.trim(lazyAssert.stringify(actualTargetValue, depthOrPlugin));
var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue));
var actualPreparedValue = lazyAssert.prepareValue(actualTargetValue, depthOrPlugin);
utils.write(paths.actualJS,
'__tmp_expect__ = '
+ JSON.stringify(actualPreparedValue, null, 4)
+ ';'
);
assert.equal(
actualString,
expectedString,
peekKey
);
},
validate: function (peekKey, actualTargetValue, validator) {
lazyAssert.checkArguments(peekKey, false);
var result = lazyAssert.validators.validate(actualTargetValue, validator);

@@ -383,3 +419,3 @@

peekValidate: function (peekKey, actualTargetValue) {
lazyAssert.checkArguments(peekKey);
lazyAssert.checkArguments(peekKey, true);

@@ -405,2 +441,3 @@ var paths = lazyAssert.getReportPaths(peekKey);

+ JSON.stringify(suggest, null, 4)
+ ';'
)

@@ -411,4 +448,4 @@ }

checkArguments: function (peekKey) {
if (!this.testLocation) {
checkArguments: function (peekKey, checkTestLocation) {
if (checkTestLocation && !this.testLocation) {
throw utils.newError('no-test-set', 'No test script set for this test.');

@@ -425,4 +462,6 @@ }

var actualPath = utils.j(reportPath, peekKey + '.actual');
var expectJSPath = utils.j(reportPath, peekKey + '.expected.js');
var actualJSPath = utils.j(reportPath, peekKey + '.actual.js');
var suggestPath = utils.j(reportPath, peekKey + '.suggest.js');
var validatarPath = utils.j(reportPath, peekKey + '.validator.js');
var validatorPath = utils.j(reportPath, peekKey + '.validator.js');

@@ -433,4 +472,6 @@ return {

actual: actualPath,
expectJS: expectJSPath,
actualJS: actualJSPath,
suggest: suggestPath,
validator: validatarPath
validator: validatorPath
}

@@ -437,0 +478,0 @@ },

var utils = require('./utils');
/**
* @start-def: lazyUtils: {}
*/
module.exports = {

@@ -241,3 +244,3 @@ load: function (lazyAssert) {

*
* @jsdef: target, pattern => result
* @def: .pattern: target, pattern => result
*

@@ -244,0 +247,0 @@ * ///

@@ -77,3 +77,5 @@ var utils = require('./utils');

* objectConfig: {key: #@~Validator}
*
*/
/**
* @def: .validate: peekKey, actualTargetValue, validator => result

@@ -1068,4 +1070,4 @@ * peekKey: string // The key to help marking the output easier

console.log('@@d', result);
console.log('@@d', problemPaths);
// console.log('@@d', result);
// console.log('@@d', problemPaths);

@@ -1132,3 +1134,3 @@ console.warn('[WARN] $VAL =');

&& typeof rawValue !== 'function') {
console.log('@@d', JSON.stringify(rawValue));
// console.log('@@d', JSON.stringify(rawValue));
return (JSON.stringify(rawValue) || 'undefined').split('"').join('\'')

@@ -1135,0 +1137,0 @@ + validatorsUtils.getNoticeFlag(path, problemPaths);

@@ -18,3 +18,3 @@ var utils = require('./utils');

// @start-def: .prototype: {}
// @start-def: .prototype: {}
Peek.prototype = {

@@ -56,3 +56,3 @@ /**

* // Basically the same as #@.set, except for it doesn't throw an error when setting an existing key
* @def: forceSet: key, value, depthOrPlugin => this
* @def: .forceSet: key, value, depthOrPlugin => this
*/

@@ -59,0 +59,0 @@ forceSet: function (key, value, depthOrPlugin) {

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