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

@lightningjs/ui-components-test-utils

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lightningjs/ui-components-test-utils - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

src/docs/Overview.stories.mdx

6

package.json
{
"name": "@lightningjs/ui-components-test-utils",
"version": "1.2.0",
"version": "1.3.0",
"description": "Helpful Jest unit test utilities for LightningJS applications utilizing the Lightning-UI-Components package.",

@@ -20,3 +20,3 @@ "repository": {

"devDependencies": {
"@lightningjs/ui-components-theme-base": "^1.0.1",
"@lightningjs/ui-components-theme-base": "^1.0.2",
"jest": "^29.3.1",

@@ -29,3 +29,3 @@ "jest-environment-jsdom": "^29.3.1",

"dependencies": {
"@lightningjs/ui-components": "^2.3.0"
"@lightningjs/ui-components": "^2.5.0"
},

@@ -32,0 +32,0 @@ "publishConfig": {

@@ -21,3 +21,3 @@ /**

import { updateManager, context } from '@lightningjs/ui-components';
import jest from 'jest-mock';
import { jest } from '@jest/globals';
import BaseTheme from '@lightningjs/ui-components-theme-base';

@@ -216,6 +216,11 @@

// output a different value of certain properties in the list array if matched
if (getBoolean.test(key)) {
// contains !! --> output value as boolean of if is truthy/falsey
key = key.substring(2, key.length);
props[key] = !!element[key];
} else if (isFunction.test(key)) {
// contains ()
// if that function exists on the element, invoke it and output the return value
// else omit that key from the output
key = key.substring(0, key.length - 2);

@@ -226,2 +231,3 @@ if (typeof element[key] === 'function') {

} else {
// doesn't match either Regex --> output the actual value of that property on the element
props[key] = element[key];

@@ -228,0 +234,0 @@ }

@@ -21,6 +21,57 @@ /**

// Helper function to extract the width and height dimensions from a src string
const extractWidthHeight = src => {
const dimensions = src.split('_')[1];
return {
width: dimensions.split('x')[0],
height: dimensions.split('x')[1]
};
};
export default class LightningUIEnvironment extends JSDOMEnvironment {
async setup() {
super.setup();
// remove unnecessary console.error messages from image retrieval errors/broken images
if (process.env.CI) {
this.global.console = {
...this.global.console,
error: () => {}
};
}
// Mock up apis that are not supported in jsdom
this.global.Image = class extends this.global.window.Image {
constructor(width, height) {
super(width, height);
// mocking this reset function to fix the issue where tests were claiming this was not a function
this.removeAttribute = () => {
if (this.src) {
this.src = null;
}
};
setTimeout(() => {
if (this.src) {
// checking for error first as that seems to be the case in WebPlatform
if (
typeof this.onerror === 'function' &&
(this.src.endsWith('brokenImage') || this.src.endsWith('Error'))
) {
this.onerror();
} else if (
typeof this.onload === 'function' &&
!this.src.endsWith('Error')
) {
if (this.src.includes('_') && this.src.includes('x')) {
const { width, height } = extractWidthHeight(this.src);
this.width = width;
this.height = height;
}
this.onload();
}
}
}, 500);
}
};
this.global.window.FontFace = function () {

@@ -27,0 +78,0 @@ this.load = () => Promise.resolve();

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