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

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
4
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

101

lib/Document.js

@@ -19,4 +19,5 @@ "use strict";

const doc = MockElement($);
doc.getElement = getElement;
doc._getElement = getElement;
doc.$ = $;
doc.getElementById = getElementById;

@@ -44,7 +45,7 @@ Object.defineProperty(doc, "head", {

function getHead() {
return doc.getElement($("head"));
return getElement($("head"));
}
function getBody() {
return doc.getElement($("body"));
return getElement($("body"));
}

@@ -65,4 +66,12 @@

function getElementById(id) {
const $idElm = $(`#${id}`).eq(0);
if ($idElm && $idElm.length) return getElement($idElm);
return null;
}
function MockElement($elm) {
const tagName = $elm[0] && $elm[0].name;
const isDocument = $elm === $;
const tagName = (($elm[0] && $elm[0].name) || "").toLowerCase();
let top = 761, bottom = top + 760 * 2, height = bottom - top;

@@ -80,3 +89,2 @@ const emitter = new EventEmitter();

getAttribute,
getElementById,
getElementsByClassName,

@@ -141,19 +149,51 @@ getElementsByTagName,

Object.defineProperty(element, "value", {
get: () => {
return getAttribute("value");
},
set: (value) => {
return setAttribute("value", value);
}
});
Object.defineProperty(element, "textContent", {
get: () => $elm.html(),
set: (value) => $elm.html(value)
get: () => {
if (isDocument) return null;
return tagName === "script" ? $elm.html() : $elm.text();
},
set: (value) => {
if (isDocument) return;
return tagName === "script" ? $elm.html(value) : $elm.text(value);
}
});
Object.defineProperty(element, "checked", {
get: () => {
return getAttribute("checked") === "checked";
},
set: (value) => {
const oldValue = (getAttribute("checked") === "checked");
uncheckRadioButtons();
if (value) {
setAttribute("checked", "checked");
if (!oldValue) {
emitter.emit("change", emptyEvent());
}
}
}
});
return element;
function getElementFirstChild() {
return doc.getElement(find("> :first-child"));
return getElement(find("> :first-child"));
}
function getElementLastChild() {
return doc.getElement(find("> :last-child"));
return getElement(find("> :last-child"));
}
function toMockElement(idx, elm) {
return doc.getElement($(elm));
return getElement($(elm));
}

@@ -166,3 +206,3 @@

function getElementsByTagName(query) {
return find(`${query}`).map((idx, elm) => doc.getElement($(elm))).toArray();
return find(`${query}`).map((idx, elm) => getElement($(elm))).toArray();
}

@@ -197,3 +237,3 @@

function find(selector) {
if ($elm === $) {
if (isDocument) {
return $(selector);

@@ -204,8 +244,2 @@ }

function getElementById(id) {
const $idElm = $(`#${id}`).eq(0);
if ($idElm) return doc.getElement($idElm);
}
function getDataset() {

@@ -270,2 +304,33 @@ if (!$elm || !$elm[0] || !$elm[0].attribs) return {};

function uncheckRadioButtons() {
if ($elm.attr("type") !== "radio") return;
const name = $elm.attr("name");
const $form = $elm.closest("form");
if ($form && $form.length) {
return $form.find(`input[type="radio"][name="${name}"]`).removeAttr("checked");
}
$(`input[type="radio"][name="${name}"]`).removeAttr("checked");
}
function emptyEvent() {
let defaultPrevented;
const event = {
preventDefault,
stopPropagation: () => {}
};
Object.defineProperty(event, "defaultPrevented", {
get: () => defaultPrevented
});
return event;
function preventDefault() {
defaultPrevented = true;
}
}
function getClassList() {

@@ -272,0 +337,0 @@ if (!$elm.attr) return;

2

package.json
{
"name": "@expressen/tallahassee",
"version": "0.1.1",
"version": "0.2.0",
"description": "Expressen client testing framework",

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

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