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

unexpected-htmllike

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unexpected-htmllike - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

@@ -380,9 +380,19 @@ 'use strict';

var source = value.toString();
var matchSource = source.match(/^\s*function (\w*?)\s*\(([^\)]*)\)\s*\{([\s\S]*?( *)?)\}\s*$/);
var name = typeof value.name === 'string' && value.name || matchSource[1];
var args = matchSource[2];
var body = matchSource[3];
if (body.indexOf('\n') !== -1 || body.length > 30) {
pen.prismKeyword('function ').prismVariable(name).prismPunctuation('(').prismVariable(args).prismPunctuation(') { /* ... */ }');
if (value && typeof value.toString === 'function') {
var source = value.toString();
var matchSource = source.match(/^\s*function (\w*?)\s*\(([^\)]*)\)\s*\{([\s\S]*?( *)?)\}\s*$/);
if (matchSource) {
var name = typeof value.name === 'string' && value.name || matchSource[1];
var args = matchSource[2];
var body = matchSource[3];
if (body.indexOf('\n') !== -1 || body.length > 30) {
pen.prismKeyword('function ').prismVariable(name).prismPunctuation('(').prismVariable(args).prismPunctuation(') { /* ... */ }');
} else {
pen.append(inspect(value));
}
} else {
if (source && source.length < 30) {
pen.append('function ').append(source);
}
}
} else {

@@ -389,0 +399,0 @@ pen.append(inspect(value));

@@ -168,2 +168,21 @@ 'use strict';

it('outputs a function with a custom toString() directly', function () {
var testFunc = function testFunc() {
console.log('hello world');
};
testFunc.toString = function () {
return 'spy';
};
(0, _painter2['default'])(pen, {
type: 'ELEMENT',
name: 'MyComponent',
attributes: [{ name: 'onClick', value: testFunc }]
}, expect.diff, expect.inspect);
expect(pen.toString(), 'to equal', '<MyComponent onClick={function spy} />');
});
it('outputs a changed attribute', function () {

@@ -170,0 +189,0 @@

{
"name": "unexpected-htmllike",
"version": "2.0.0",
"version": "2.0.1",
"description": "Helper library for unexpected plugins that perform assertions on XML like structures",

@@ -5,0 +5,0 @@ "author": {

@@ -398,13 +398,23 @@

var source = value.toString();
var matchSource = source.match(/^\s*function (\w*?)\s*\(([^\)]*)\)\s*\{([\s\S]*?( *)?)\}\s*$/);
var name = (typeof value.name === 'string' && value.name) || matchSource[1];
var args = matchSource[2];
var body = matchSource[3];
if (body.indexOf('\n') !== -1 || body.length > 30) {
pen.prismKeyword('function ')
.prismVariable(name)
.prismPunctuation('(')
.prismVariable(args)
.prismPunctuation(') { /* ... */ }');
if (value && typeof value.toString === 'function') {
var source = value.toString();
var matchSource = source.match(/^\s*function (\w*?)\s*\(([^\)]*)\)\s*\{([\s\S]*?( *)?)\}\s*$/);
if (matchSource) {
var name = (typeof value.name === 'string' && value.name) || matchSource[1];
var args = matchSource[2];
var body = matchSource[3];
if (body.indexOf('\n') !== -1 || body.length > 30) {
pen.prismKeyword('function ')
.prismVariable(name)
.prismPunctuation('(')
.prismVariable(args)
.prismPunctuation(') { /* ... */ }');
} else {
pen.append(inspect(value));
}
} else {
if (source && source.length < 30) {
pen.append('function ').append(source);
}
}
} else {

@@ -411,0 +421,0 @@ pen.append(inspect(value));

@@ -212,2 +212,26 @@

it('outputs a function with a custom toString() directly', () => {
const testFunc = function testFunc() {
console.log('hello world');
};
testFunc.toString = function () {
return 'spy';
};
Painter(pen, {
type: 'ELEMENT',
name: 'MyComponent',
attributes: [
{ name: 'onClick', value: testFunc }
]
}, expect.diff, expect.inspect);
expect(pen.toString(), 'to equal',
'<MyComponent onClick={function spy} />');
});
it('outputs a changed attribute', () => {

@@ -214,0 +238,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet