@thednp/shorty 1.0.3 → 2.0.0-alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +224 -0
- package/.lgtm.yml +9 -0
- package/.prettierrc.json +15 -0
- package/README.md +195 -198
- package/cypress/e2e/att.cy.ts +46 -0
- package/cypress/e2e/boolean.cy.ts +44 -0
- package/cypress/e2e/class.cy.ts +28 -0
- package/cypress/e2e/event.cy.ts +51 -0
- package/cypress/e2e/get.cy.ts +168 -0
- package/cypress/e2e/is.cy.ts +233 -0
- package/cypress/e2e/misc.cy.ts +331 -0
- package/cypress/e2e/selectors.cy.ts +85 -0
- package/cypress/fixtures/custom-elem.js +18 -0
- package/cypress/plugins/esbuild-istanbul.ts +50 -0
- package/cypress/plugins/tsCompile.ts +34 -0
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/e2e.ts +21 -0
- package/cypress/support/index.js +22 -0
- package/cypress/test.html +63 -0
- package/cypress.config.ts +30 -0
- package/dist/shorty.cjs +2 -0
- package/dist/shorty.cjs.map +1 -0
- package/dist/shorty.d.ts +1502 -0
- package/dist/shorty.js +2 -2628
- package/dist/shorty.js.map +1 -0
- package/dist/shorty.mjs +552 -0
- package/dist/shorty.mjs.map +1 -0
- package/dts.config.ts +22 -0
- package/package.json +33 -38
- package/src/attr/getAttribute.ts +11 -0
- package/src/attr/getAttributeNS.ts +12 -0
- package/src/attr/hasAttribute.ts +10 -0
- package/src/attr/hasAttributeNS.ts +12 -0
- package/src/attr/removeAttribute.ts +9 -0
- package/src/attr/removeAttributeNS.ts +11 -0
- package/src/attr/setAttribute.ts +11 -0
- package/src/attr/setAttributeNS.ts +12 -0
- package/src/blocks/{documentBody.js → documentBody.ts} +0 -0
- package/src/blocks/{documentElement.js → documentElement.ts} +0 -0
- package/src/blocks/{documentHead.js → documentHead.ts} +0 -0
- package/src/boolean/isApple.ts +14 -0
- package/src/boolean/{isFirefox.js → isFirefox.ts} +2 -3
- package/src/boolean/{isMobile.js → isMobile.ts} +1 -2
- package/src/boolean/support3DTransform.ts +8 -0
- package/src/boolean/supportAnimation.ts +8 -0
- package/src/boolean/{supportPassive.js → supportPassive.ts} +3 -3
- package/src/boolean/supportTouch.ts +7 -0
- package/src/boolean/supportTransform.ts +8 -0
- package/src/boolean/supportTransition.ts +8 -0
- package/src/class/addClass.ts +11 -0
- package/src/class/hasClass.ts +11 -0
- package/src/class/removeClass.ts +11 -0
- package/src/event/off.ts +14 -0
- package/src/event/on.ts +14 -0
- package/src/event/one.ts +25 -0
- package/src/get/{getBoundingClientRect.js → getBoundingClientRect.ts} +14 -12
- package/src/get/{getDocument.js → getDocument.ts} +11 -7
- package/src/get/getDocumentBody.ts +13 -0
- package/src/get/getDocumentElement.ts +13 -0
- package/src/get/getDocumentHead.ts +12 -0
- package/src/get/{getElementAnimationDelay.js → getElementAnimationDelay.ts} +10 -9
- package/src/get/{getElementAnimationDuration.js → getElementAnimationDuration.ts} +10 -8
- package/src/get/getElementStyle.ts +25 -0
- package/src/get/{getElementTransitionDelay.js → getElementTransitionDelay.ts} +12 -8
- package/src/get/{getElementTransitionDuration.js → getElementTransitionDuration.ts} +12 -8
- package/src/get/{getNodeScroll.js → getNodeScroll.ts} +9 -5
- package/src/get/{getParentNode.js → getParentNode.ts} +11 -6
- package/src/get/{getRectRelativeToOffsetParent.js → getRectRelativeToOffsetParent.ts} +15 -7
- package/src/get/getUID.ts +42 -0
- package/src/get/{getWindow.js → getWindow.ts} +9 -6
- package/src/{index.js → index.ts} +37 -43
- package/src/interface/boundingClientRect.d.ts +10 -0
- package/src/interface/css4Declaration.d.ts +4 -0
- package/src/interface/customElement.d.ts +8 -0
- package/src/interface/navigatorUA.d.ts +15 -0
- package/src/interface/offsetRect.d.ts +6 -0
- package/src/interface/originalEvent.d.ts +4 -0
- package/src/is/isArray.ts +9 -0
- package/src/is/isCanvas.ts +13 -0
- package/src/is/isCustomElement.ts +13 -0
- package/src/is/isDocument.ts +13 -0
- package/src/is/{isElement.js → isElement.ts} +10 -5
- package/src/is/{isElementInScrollRange.js → isElementInScrollRange.ts} +4 -4
- package/src/is/{isElementInViewport.js → isElementInViewport.ts} +6 -12
- package/src/is/isElementsArray.ts +13 -0
- package/src/is/isFunction.ts +10 -0
- package/src/is/isHTMLCollection.ts +12 -0
- package/src/is/isHTMLElement.ts +13 -0
- package/src/is/isHTMLImageElement.ts +12 -0
- package/src/is/isJSON.ts +20 -0
- package/src/is/isMap.ts +11 -0
- package/src/is/isMedia.ts +20 -0
- package/src/is/isNode.ts +17 -0
- package/src/is/isNodeList.ts +13 -0
- package/src/is/isNumber.ts +9 -0
- package/src/is/isObject.ts +10 -0
- package/src/is/isRTL.ts +11 -0
- package/src/is/isSVGElement.ts +13 -0
- package/src/is/{isScaledElement.js → isScaledElement.ts} +9 -7
- package/src/is/isShadowRoot.ts +12 -0
- package/src/is/isString.ts +9 -0
- package/src/is/isTableElement.ts +14 -0
- package/src/is/isWeakMap.ts +11 -0
- package/src/is/isWindow.ts +13 -0
- package/src/misc/ArrayFrom.ts +11 -0
- package/src/misc/Float32ArrayFrom.ts +10 -0
- package/src/misc/Float64ArrayFrom.ts +10 -0
- package/src/misc/ObjectAssign.ts +43 -0
- package/src/misc/ObjectEntries.ts +11 -0
- package/src/misc/ObjectHasOwn.ts +17 -0
- package/src/misc/ObjectKeys.ts +10 -0
- package/src/misc/ObjectValues.ts +11 -0
- package/src/misc/createCustomEvent.ts +28 -0
- package/src/misc/createElement.ts +40 -0
- package/src/misc/createElementNS.ts +45 -0
- package/src/misc/data.ts +82 -0
- package/src/misc/dispatchEvent.ts +9 -0
- package/src/misc/distinct.ts +18 -0
- package/src/misc/{emulateAnimationEnd.js → emulateAnimationEnd.ts} +8 -9
- package/src/misc/{emulateTransitionEnd.js → emulateTransitionEnd.ts} +8 -9
- package/src/misc/focus.ts +9 -0
- package/src/misc/getInstance.ts +9 -0
- package/src/misc/{noop.js → noop.ts} +4 -1
- package/src/misc/normalizeOptions.ts +55 -0
- package/src/misc/normalizeValue.ts +30 -0
- package/src/misc/{passiveHandler.js → passiveHandler.ts} +1 -2
- package/src/misc/reflow.ts +9 -0
- package/src/misc/setElementStyle.ts +23 -0
- package/src/misc/timer.ts +84 -0
- package/src/misc/toLowerCase.ts +9 -0
- package/src/misc/toUpperCase.ts +9 -0
- package/src/selectors/closest.ts +20 -0
- package/src/selectors/{getCustomElements.js → getCustomElements.ts} +8 -4
- package/src/selectors/getElementById.ts +16 -0
- package/src/selectors/getElementsByClassName.ts +22 -0
- package/src/selectors/getElementsByTagName.ts +20 -0
- package/src/selectors/matches.ts +10 -0
- package/src/selectors/querySelector.ts +22 -0
- package/src/selectors/{querySelectorAll.js → querySelectorAll.ts} +7 -5
- package/src/strings/{DOMContentLoadedEvent.js → DOMContentLoadedEvent.ts} +0 -1
- package/src/strings/{DOMMouseScrollEvent.js → DOMMouseScrollEvent.ts} +0 -1
- package/src/strings/{abortEvent.js → abortEvent.ts} +0 -1
- package/src/strings/{addEventListener.js → addEventListener.ts} +0 -1
- package/src/strings/{animationDelay.js → animationDelay.ts} +0 -1
- package/src/strings/{animationDuration.js → animationDuration.ts} +0 -1
- package/src/strings/{animationEndEvent.js → animationEndEvent.ts} +0 -1
- package/src/strings/{animationName.js → animationName.ts} +0 -1
- package/src/strings/{ariaChecked.js → ariaChecked.ts} +0 -1
- package/src/strings/{ariaDescribedBy.js → ariaDescribedBy.ts} +0 -1
- package/src/strings/{ariaDescription.js → ariaDescription.ts} +0 -1
- package/src/strings/{ariaExpanded.js → ariaExpanded.ts} +0 -1
- package/src/strings/{ariaHasPopup.js → ariaHasPopup.ts} +0 -1
- package/src/strings/{ariaHidden.js → ariaHidden.ts} +0 -1
- package/src/strings/{ariaLabel.js → ariaLabel.ts} +0 -1
- package/src/strings/{ariaLabelledBy.js → ariaLabelledBy.ts} +0 -1
- package/src/strings/{ariaModal.js → ariaModal.ts} +0 -1
- package/src/strings/{ariaPressed.js → ariaPressed.ts} +0 -1
- package/src/strings/{ariaSelected.js → ariaSelected.ts} +0 -1
- package/src/strings/{ariaValueMax.js → ariaValueMax.ts} +0 -1
- package/src/strings/{ariaValueMin.js → ariaValueMin.ts} +0 -1
- package/src/strings/{ariaValueNow.js → ariaValueNow.ts} +0 -1
- package/src/strings/{ariaValueText.js → ariaValueText.ts} +0 -1
- package/src/strings/{beforeunloadEvent.js → beforeunloadEvent.ts} +0 -1
- package/src/strings/{bezierEasings.js → bezierEasings.ts} +0 -1
- package/src/strings/{blurEvent.js → blurEvent.ts} +0 -1
- package/src/strings/{changeEvent.js → changeEvent.ts} +0 -1
- package/src/strings/{contextmenuEvent.js → contextmenuEvent.ts} +0 -1
- package/src/strings/dragEvent.ts +5 -0
- package/src/strings/dragendEvent.ts +5 -0
- package/src/strings/dragenterEvent.ts +5 -0
- package/src/strings/dragleaveEvent.ts +5 -0
- package/src/strings/dragoverEvent.ts +5 -0
- package/src/strings/dragstartEvent.ts +5 -0
- package/src/strings/{errorEvent.js → errorEvent.ts} +0 -1
- package/src/strings/{focusEvent.js → focusEvent.ts} +0 -1
- package/src/strings/{focusEvents.js → focusEvents.ts} +0 -1
- package/src/strings/{focusinEvent.js → focusinEvent.ts} +0 -1
- package/src/strings/{focusoutEvent.js → focusoutEvent.ts} +0 -1
- package/src/strings/{gesturechangeEvent.js → gesturechangeEvent.ts} +0 -1
- package/src/strings/{gestureendEvent.js → gestureendEvent.ts} +0 -1
- package/src/strings/{gesturestartEvent.js → gesturestartEvent.ts} +0 -1
- package/src/strings/{keyAlt.js → keyAlt.ts} +1 -1
- package/src/strings/{keyArrowDown.js → keyArrowDown.ts} +1 -1
- package/src/strings/{keyArrowLeft.js → keyArrowLeft.ts} +1 -1
- package/src/strings/{keyArrowRight.js → keyArrowRight.ts} +1 -1
- package/src/strings/{keyArrowUp.js → keyArrowUp.ts} +1 -1
- package/src/strings/{keyBackspace.js → keyBackspace.ts} +1 -1
- package/src/strings/{keyCapsLock.js → keyCapsLock.ts} +1 -1
- package/src/strings/{keyControl.js → keyControl.ts} +1 -1
- package/src/strings/{keyDelete.js → keyDelete.ts} +1 -1
- package/src/strings/{keyEnter.js → keyEnter.ts} +1 -1
- package/src/strings/{keyEscape.js → keyEscape.ts} +1 -1
- package/src/strings/{keyInsert.js → keyInsert.ts} +1 -1
- package/src/strings/{keyMeta.js → keyMeta.ts} +1 -1
- package/src/strings/{keyPause.js → keyPause.ts} +1 -1
- package/src/strings/{keyScrollLock.js → keyScrollLock.ts} +1 -1
- package/src/strings/{keyShift.js → keyShift.ts} +1 -1
- package/src/strings/{keySpace.js → keySpace.ts} +1 -1
- package/src/strings/{keyTab.js → keyTab.ts} +1 -1
- package/src/strings/{keyboardEventKeys.js → keyboardEventKeys.ts} +0 -1
- package/src/strings/{keydownEvent.js → keydownEvent.ts} +0 -1
- package/src/strings/{keypressEvent.js → keypressEvent.ts} +0 -1
- package/src/strings/{keyupEvent.js → keyupEvent.ts} +0 -1
- package/src/strings/{loadEvent.js → loadEvent.ts} +0 -1
- package/src/strings/{loadstartEvent.js → loadstartEvent.ts} +0 -1
- package/src/strings/{mouseClickEvents.js → mouseClickEvents.ts} +0 -1
- package/src/strings/mouseHoverEvents.ts +8 -0
- package/src/strings/{mouseSwipeEvents.js → mouseSwipeEvents.ts} +4 -2
- package/src/strings/{mouseclickEvent.js → mouseclickEvent.ts} +0 -1
- package/src/strings/{mousedblclickEvent.js → mousedblclickEvent.ts} +0 -1
- package/src/strings/{mousedownEvent.js → mousedownEvent.ts} +0 -1
- package/src/strings/{mouseenterEvent.js → mouseenterEvent.ts} +0 -1
- package/src/strings/{mousehoverEvent.js → mousehoverEvent.ts} +0 -1
- package/src/strings/{mouseinEvent.js → mouseinEvent.ts} +0 -1
- package/src/strings/{mouseleaveEvent.js → mouseleaveEvent.ts} +0 -1
- package/src/strings/{mousemoveEvent.js → mousemoveEvent.ts} +0 -1
- package/src/strings/{mouseoutEvent.js → mouseoutEvent.ts} +0 -1
- package/src/strings/{mouseoverEvent.js → mouseoverEvent.ts} +0 -1
- package/src/strings/{mouseupEvent.js → mouseupEvent.ts} +0 -1
- package/src/strings/{mousewheelEvent.js → mousewheelEvent.ts} +0 -1
- package/src/strings/{moveEvent.js → moveEvent.ts} +0 -1
- package/src/strings/{nativeEvents.js → nativeEvents.ts} +0 -0
- package/src/strings/{offsetHeight.js → offsetHeight.ts} +0 -1
- package/src/strings/{offsetWidth.js → offsetWidth.ts} +0 -1
- package/src/strings/{orientationchangeEvent.js → orientationchangeEvent.ts} +0 -1
- package/src/strings/{pointercancelEvent.js → pointercancelEvent.ts} +0 -1
- package/src/strings/{pointerdownEvent.js → pointerdownEvent.ts} +0 -1
- package/src/strings/{pointerleaveEvent.js → pointerleaveEvent.ts} +0 -1
- package/src/strings/{pointermoveEvent.js → pointermoveEvent.ts} +0 -1
- package/src/strings/{pointerupEvent.js → pointerupEvent.ts} +0 -1
- package/src/strings/{readystatechangeEvent.js → readystatechangeEvent.ts} +0 -1
- package/src/strings/{removeEventListener.js → removeEventListener.ts} +0 -1
- package/src/strings/{resetEvent.js → resetEvent.ts} +0 -1
- package/src/strings/{resizeEvent.js → resizeEvent.ts} +0 -1
- package/src/strings/{scrollEvent.js → scrollEvent.ts} +0 -1
- package/src/strings/{scrollHeight.js → scrollHeight.ts} +0 -1
- package/src/strings/{scrollWidth.js → scrollWidth.ts} +0 -1
- package/src/strings/{selectEvent.js → selectEvent.ts} +0 -1
- package/src/strings/{selectendEvent.js → selectendEvent.ts} +0 -1
- package/src/strings/{selectstartEvent.js → selectstartEvent.ts} +0 -1
- package/src/strings/{submitEvent.js → submitEvent.ts} +0 -1
- package/src/strings/tabindex.ts +5 -0
- package/src/strings/touchEvents.ts +10 -0
- package/src/strings/{touchcancelEvent.js → touchcancelEvent.ts} +0 -1
- package/src/strings/{touchendEvent.js → touchendEvent.ts} +0 -1
- package/src/strings/{touchmoveEvent.js → touchmoveEvent.ts} +0 -1
- package/src/strings/{touchstartEvent.js → touchstartEvent.ts} +0 -1
- package/src/strings/{transitionDelay.js → transitionDelay.ts} +0 -1
- package/src/strings/{transitionDuration.js → transitionDuration.ts} +0 -1
- package/src/strings/{transitionEndEvent.js → transitionEndEvent.ts} +0 -1
- package/src/strings/{transitionProperty.js → transitionProperty.ts} +0 -2
- package/src/strings/{unloadEvent.js → unloadEvent.ts} +0 -1
- package/src/strings/{userAgent.js → userAgent.ts} +0 -0
- package/src/strings/userAgentData.ts +9 -0
- package/tsconfig.json +30 -0
- package/vite.config.ts +30 -0
- package/dist/shorty.esm.js +0 -2599
- package/dist/shorty.esm.min.js +0 -2
- package/dist/shorty.min.js +0 -2
- package/src/attr/getAttribute.js +0 -9
- package/src/attr/getAttributeNS.js +0 -10
- package/src/attr/hasAttribute.js +0 -9
- package/src/attr/hasAttributeNS.js +0 -10
- package/src/attr/removeAttribute.js +0 -9
- package/src/attr/removeAttributeNS.js +0 -10
- package/src/attr/setAttribute.js +0 -10
- package/src/attr/setAttributeNS.js +0 -11
- package/src/boolean/isApple.js +0 -13
- package/src/boolean/support3DTransform.js +0 -9
- package/src/boolean/supportAnimation.js +0 -9
- package/src/boolean/supportTouch.js +0 -7
- package/src/boolean/supportTransform.js +0 -9
- package/src/boolean/supportTransition.js +0 -9
- package/src/class/addClass.js +0 -10
- package/src/class/hasClass.js +0 -10
- package/src/class/removeClass.js +0 -10
- package/src/event/off.js +0 -9
- package/src/event/on.js +0 -9
- package/src/event/one.js +0 -23
- package/src/get/getDocumentBody.js +0 -10
- package/src/get/getDocumentElement.js +0 -11
- package/src/get/getDocumentHead.js +0 -10
- package/src/get/getElementAnimationDelayLegacy.js +0 -21
- package/src/get/getElementAnimationDurationLegacy.js +0 -21
- package/src/get/getElementStyle.js +0 -20
- package/src/get/getElementTransitionDelayLegacy.js +0 -21
- package/src/get/getElementTransitionDurationLegacy.js +0 -21
- package/src/get/getUID.js +0 -34
- package/src/is/isArray.js +0 -8
- package/src/is/isCustomElement.js +0 -8
- package/src/is/isDocument.js +0 -10
- package/src/is/isElementsArray.js +0 -12
- package/src/is/isFunction.js +0 -8
- package/src/is/isHTMLCollection.js +0 -8
- package/src/is/isHTMLElement.js +0 -9
- package/src/is/isHTMLImageElement.js +0 -8
- package/src/is/isMedia.js +0 -14
- package/src/is/isNode.js +0 -9
- package/src/is/isNodeList.js +0 -9
- package/src/is/isNumber.js +0 -8
- package/src/is/isObject.js +0 -8
- package/src/is/isRTL.js +0 -9
- package/src/is/isSVGElement.js +0 -11
- package/src/is/isShadowRoot.js +0 -9
- package/src/is/isString.js +0 -8
- package/src/is/isTableElement.js +0 -11
- package/src/is/isWindow.js +0 -9
- package/src/misc/ArrayFrom.js +0 -8
- package/src/misc/Float32ArrayFrom.js +0 -7
- package/src/misc/Float64ArrayFrom.js +0 -7
- package/src/misc/ObjectAssign.js +0 -7
- package/src/misc/ObjectEntries.js +0 -7
- package/src/misc/ObjectKeys.js +0 -7
- package/src/misc/ObjectValues.js +0 -7
- package/src/misc/OriginalEvent.js +0 -20
- package/src/misc/createElement.js +0 -27
- package/src/misc/createElementNS.js +0 -30
- package/src/misc/data.js +0 -78
- package/src/misc/dispatchEvent.js +0 -8
- package/src/misc/distinct.js +0 -10
- package/src/misc/emulateAnimationEndLegacy.js +0 -41
- package/src/misc/emulateTransitionEndLegacy.js +0 -41
- package/src/misc/focus.js +0 -7
- package/src/misc/normalizeOptions.js +0 -49
- package/src/misc/normalizeValue.js +0 -34
- package/src/misc/passiveHandlerLegacy.js +0 -10
- package/src/misc/reflow.js +0 -8
- package/src/misc/setElementStyle.js +0 -19
- package/src/misc/timer.js +0 -75
- package/src/misc/toLowerCase.js +0 -8
- package/src/misc/toUpperCase.js +0 -8
- package/src/misc/version.js +0 -8
- package/src/selectors/closest.js +0 -16
- package/src/selectors/getElementById.js +0 -14
- package/src/selectors/getElementsByClassName.js +0 -15
- package/src/selectors/getElementsByTagName.js +0 -15
- package/src/selectors/matches.js +0 -10
- package/src/selectors/matchesLegacy.js +0 -23
- package/src/selectors/querySelector.js +0 -19
- package/src/strings/animationDelayLegacy.js +0 -9
- package/src/strings/animationDurationLegacy.js +0 -9
- package/src/strings/animationEndEventLegacy.js +0 -9
- package/src/strings/animationNameLegacy.js +0 -9
- package/src/strings/mouseHoverEvents.js +0 -7
- package/src/strings/touchEvents.js +0 -8
- package/src/strings/transitionDelayLegacy.js +0 -9
- package/src/strings/transitionDurationLegacy.js +0 -9
- package/src/strings/transitionEndEventLegacy.js +0 -9
- package/src/strings/transitionPropertyLegacy.js +0 -12
- package/src/strings/userAgentData.js +0 -7
- package/types/index.d.ts +0 -257
- package/types/module/shorty.ts +0 -248
- package/types/shorty.d.ts +0 -2316
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
// import SHORTY from '../../src/index';
|
|
5
|
+
import * as SHORTY from '../../src/index';
|
|
6
|
+
|
|
7
|
+
describe('Shorty Library Tests', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
cy.visit('cypress/test.html');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('Test misc folder - emulateTransitionEnd - no transition', () => {
|
|
13
|
+
const {
|
|
14
|
+
dispatchEvent,
|
|
15
|
+
emulateTransitionEnd,
|
|
16
|
+
createCustomEvent,
|
|
17
|
+
reflow,
|
|
18
|
+
querySelector,
|
|
19
|
+
setElementStyle,
|
|
20
|
+
getElementStyle,
|
|
21
|
+
removeClass,
|
|
22
|
+
addClass,
|
|
23
|
+
one,
|
|
24
|
+
} = SHORTY;
|
|
25
|
+
|
|
26
|
+
cy
|
|
27
|
+
.window()
|
|
28
|
+
.then(win => {
|
|
29
|
+
const el = querySelector('.alert', win.document) as HTMLElement;
|
|
30
|
+
const btn = querySelector('.btn-close', el);
|
|
31
|
+
const alertHideEvent = createCustomEvent('hide-alert', { relatedTarget: null });
|
|
32
|
+
|
|
33
|
+
setElementStyle(el, {
|
|
34
|
+
transition: 'none',
|
|
35
|
+
transitionProperty: 'none',
|
|
36
|
+
transitionDuration: '0s',
|
|
37
|
+
'transition-delay': '0s',
|
|
38
|
+
'--transition-prop': 'none',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(getElementStyle(el, 'transitionProperty')).to.equal('none');
|
|
42
|
+
expect(getElementStyle(el, 'transition-duration')).to.equal('0s');
|
|
43
|
+
expect(getElementStyle(el, 'transitionDelay')).to.equal('0s');
|
|
44
|
+
expect(getElementStyle(el, '--transition-prop')).to.equal('none');
|
|
45
|
+
|
|
46
|
+
cy.log('emulateTransitionEnd').then(() => {
|
|
47
|
+
one(el, 'hide-alert', function hideHandler(e) {
|
|
48
|
+
cy.log('hide-alert triggered');
|
|
49
|
+
expect(e.target).to.equal(el);
|
|
50
|
+
expect(e.relatedTarget).to.equal(btn);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
one(btn, 'click', function handleBtn(e) {
|
|
54
|
+
cy.log('clicked btn');
|
|
55
|
+
expect(e.target).to.equal(btn);
|
|
56
|
+
removeClass(el, 'show');
|
|
57
|
+
reflow(el);
|
|
58
|
+
alertHideEvent.relatedTarget = btn;
|
|
59
|
+
dispatchEvent(el, alertHideEvent);
|
|
60
|
+
emulateTransitionEnd(el, function () {
|
|
61
|
+
addClass(el, 'show');
|
|
62
|
+
cy.log('transitionend triggered');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
btn.click();
|
|
67
|
+
cy.wait(100);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('Test misc folder - emulateTransitionEnd - default', () => {
|
|
73
|
+
const {
|
|
74
|
+
dispatchEvent,
|
|
75
|
+
emulateTransitionEnd,
|
|
76
|
+
createCustomEvent,
|
|
77
|
+
reflow,
|
|
78
|
+
querySelector,
|
|
79
|
+
removeClass,
|
|
80
|
+
addClass,
|
|
81
|
+
one,
|
|
82
|
+
focus,
|
|
83
|
+
} = SHORTY;
|
|
84
|
+
|
|
85
|
+
cy
|
|
86
|
+
// .wait('@pageload')
|
|
87
|
+
.window()
|
|
88
|
+
.then(win => {
|
|
89
|
+
const el = querySelector('.alert', win.document);
|
|
90
|
+
const btn = querySelector('.btn-close', el);
|
|
91
|
+
const alertHideEvent = createCustomEvent('hide-alert', { relatedTarget: null });
|
|
92
|
+
|
|
93
|
+
cy.log('begin **emulateTransitionEnd**').then(() => {
|
|
94
|
+
one(el, 'hide-alert', function hideHandler(e) {
|
|
95
|
+
cy.log('hide-alert triggered');
|
|
96
|
+
expect(e.target).to.equal(el);
|
|
97
|
+
expect(e.relatedTarget).to.equal(btn);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
one(btn, 'click', function handleBtn(e) {
|
|
101
|
+
cy.log('clicked btn');
|
|
102
|
+
expect(e.target).to.equal(btn);
|
|
103
|
+
removeClass(el, 'show');
|
|
104
|
+
reflow(el);
|
|
105
|
+
alertHideEvent.relatedTarget = btn;
|
|
106
|
+
dispatchEvent(el, alertHideEvent);
|
|
107
|
+
emulateTransitionEnd(el, function () {
|
|
108
|
+
addClass(el, 'show');
|
|
109
|
+
focus(btn);
|
|
110
|
+
console.log('transitionend triggered');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
btn.click();
|
|
115
|
+
cy.wait(300);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('Test misc folder - emulateAnimationEnd - default', () => {
|
|
121
|
+
const { emulateAnimationEnd, getElementStyle, querySelector, addClass } = SHORTY;
|
|
122
|
+
cy
|
|
123
|
+
// .wait('@pageload')
|
|
124
|
+
.window()
|
|
125
|
+
.then(win => {
|
|
126
|
+
const el = querySelector('.alert', win.document);
|
|
127
|
+
|
|
128
|
+
cy.log('begin **emulateAnimationEnd**').then(() => {
|
|
129
|
+
addClass(el, 'animate-test');
|
|
130
|
+
emulateAnimationEnd(el, () => {
|
|
131
|
+
console.log('animationend fired');
|
|
132
|
+
expect(getElementStyle(el, 'animationName'), 'animationName').to.equal('animate-test');
|
|
133
|
+
expect(getElementStyle(el, 'animationDuration'), 'animationDuration').to.equal('0.3s');
|
|
134
|
+
expect(getElementStyle(el, 'animationDelay'), 'animationDelay').to.equal('0s');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
cy.wait(350);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('Test misc folder - emulateAnimationEnd - no duration', () => {
|
|
143
|
+
const { emulateAnimationEnd, setElementStyle, getElementStyle, querySelector, addClass } =
|
|
144
|
+
SHORTY;
|
|
145
|
+
cy
|
|
146
|
+
// .wait('@pageload')
|
|
147
|
+
.window()
|
|
148
|
+
.then(win => {
|
|
149
|
+
const el = querySelector('.alert', win.document);
|
|
150
|
+
setElementStyle(el, { animationDuration: '0s' });
|
|
151
|
+
|
|
152
|
+
cy.log('begin **emulateAnimationEnd**').then(() => {
|
|
153
|
+
addClass(el, 'animate-test');
|
|
154
|
+
emulateAnimationEnd(el, () => {
|
|
155
|
+
console.log('animationend fired');
|
|
156
|
+
expect(getElementStyle(el, 'animationName'), 'animationName').to.equal('animate-test');
|
|
157
|
+
expect(getElementStyle(el, 'animationDuration'), 'animationDuration').to.equal('0s');
|
|
158
|
+
expect(getElementStyle(el, 'animationDelay'), 'animationDelay').to.equal('0s');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
cy.wait(100);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('Test misc folder - everything else', () => {
|
|
167
|
+
const {
|
|
168
|
+
ArrayFrom,
|
|
169
|
+
Float32ArrayFrom,
|
|
170
|
+
Float64ArrayFrom,
|
|
171
|
+
distinct,
|
|
172
|
+
noop,
|
|
173
|
+
ObjectHasOwn,
|
|
174
|
+
ObjectEntries,
|
|
175
|
+
ObjectAssign,
|
|
176
|
+
ObjectKeys,
|
|
177
|
+
ObjectValues,
|
|
178
|
+
createElement,
|
|
179
|
+
createElementNS,
|
|
180
|
+
Data,
|
|
181
|
+
getInstance,
|
|
182
|
+
normalizeOptions,
|
|
183
|
+
Timer,
|
|
184
|
+
toLowerCase,
|
|
185
|
+
toUpperCase,
|
|
186
|
+
querySelector,
|
|
187
|
+
getElementsByClassName,
|
|
188
|
+
} = SHORTY;
|
|
189
|
+
cy
|
|
190
|
+
// .wait('@pageload')
|
|
191
|
+
.window()
|
|
192
|
+
.then(win => {
|
|
193
|
+
const el = querySelector('.alert', win.document);
|
|
194
|
+
const table = querySelector('.table', win.document);
|
|
195
|
+
|
|
196
|
+
const defaults = { op1: true, op2: true, op3: 5, title: null };
|
|
197
|
+
const jsOps = { op1: false, op2: false, op3: 8, title: 'something' };
|
|
198
|
+
expect(ObjectHasOwn(jsOps,'op3')).to.be.true;
|
|
199
|
+
expect(ObjectHasOwn(jsOps,'momo')).to.be.false;
|
|
200
|
+
expect(ObjectHasOwn(null,'momo')).to.be.false;
|
|
201
|
+
expect(normalizeOptions(el, defaults, {}, 'bs'), 'normalizeOptions(data)').to.deep.equal({
|
|
202
|
+
op1: false,
|
|
203
|
+
op2: true,
|
|
204
|
+
op3: 10,
|
|
205
|
+
title: null,
|
|
206
|
+
});
|
|
207
|
+
expect(normalizeOptions(el, defaults, jsOps, 'bs'), 'normalizeOptions(js)').to.deep.equal({
|
|
208
|
+
op1: false,
|
|
209
|
+
op2: false,
|
|
210
|
+
op3: 8,
|
|
211
|
+
title: 'something',
|
|
212
|
+
});
|
|
213
|
+
expect(noop()).to.be.undefined;
|
|
214
|
+
|
|
215
|
+
Timer.set('el', noop, 150);
|
|
216
|
+
Timer.set(el, () => console.log(el.tagName + ' has timer of 150'), 150, 'alert');
|
|
217
|
+
expect(Timer.get('el', 'alert')).to.be.null;
|
|
218
|
+
expect(Timer.get(el, 'alert')).to.not.be.undefined;
|
|
219
|
+
Timer.clear('el', 'alert');
|
|
220
|
+
Timer.clear(el, 'alert');
|
|
221
|
+
expect(Timer.get(el, 'alert')).to.be.null;
|
|
222
|
+
|
|
223
|
+
Timer.set(el, () => console.log(el.tagName + ' has timer of 250'), 250);
|
|
224
|
+
expect(Timer.get(el)).to.not.be.null;
|
|
225
|
+
Timer.clear(el);
|
|
226
|
+
expect(Timer.get(el)).to.be.null;
|
|
227
|
+
|
|
228
|
+
expect([0, 1, 1, 2, 3, 3].filter(distinct), 'filter(DISTINCT)').to.deep.equal([0, 1, 2, 3]);
|
|
229
|
+
|
|
230
|
+
expect(toLowerCase('textSample'), 'toLowerCase(string)').to.equal('textsample');
|
|
231
|
+
expect(toUpperCase('textSample'), 'toUpperCase(string)').to.equal('TEXTSAMPLE');
|
|
232
|
+
|
|
233
|
+
expect(
|
|
234
|
+
ObjectAssign({ c: 3 }, { a: 1, b: 2 }),
|
|
235
|
+
'ObjectAssign(object1, object2)',
|
|
236
|
+
).to.deep.equal({ a: 1, b: 2, c: 3 });
|
|
237
|
+
expect(ObjectEntries({ a: 1, b: 2 }), 'ObjectEntries(object)').to.deep.equal([
|
|
238
|
+
['a', 1],
|
|
239
|
+
['b', 2],
|
|
240
|
+
]);
|
|
241
|
+
expect(ObjectKeys({ a: 1, b: 2 }), 'ObjectKeys(object)').to.deep.equal(['a', 'b']);
|
|
242
|
+
expect(ObjectValues({ a: 1, b: 2 }), 'ObjectValues(object)').to.deep.equal([1, 2]);
|
|
243
|
+
|
|
244
|
+
expect(Float32ArrayFrom([0, 1, 2, 3]), 'Float32ArrayFrom(array)').to.be.instanceOf(
|
|
245
|
+
Float32Array,
|
|
246
|
+
);
|
|
247
|
+
expect(Float64ArrayFrom([0, 1, 2, 3]), 'Float64ArrayFrom(array)').to.be.instanceOf(
|
|
248
|
+
Float64Array,
|
|
249
|
+
);
|
|
250
|
+
expect(Float64ArrayFrom([0, 1, 2, 3]).length, 'Float64ArrayFrom(array)').to.eq(4);
|
|
251
|
+
|
|
252
|
+
expect(
|
|
253
|
+
ArrayFrom(new Float32Array([0, 1, 2, 3])),
|
|
254
|
+
'ArrayFrom(Float32Array)',
|
|
255
|
+
).to.be.instanceOf(Array);
|
|
256
|
+
expect(ArrayFrom(new Float64Array([0, 1, 2, 3])), 'Array(Float64Array)').to.be.instanceOf(
|
|
257
|
+
Array,
|
|
258
|
+
);
|
|
259
|
+
expect(
|
|
260
|
+
ArrayFrom(getElementsByClassName('table', win.document)),
|
|
261
|
+
'ArrayFrom(HTMLCollection)',
|
|
262
|
+
).to.deep.equal([table]);
|
|
263
|
+
|
|
264
|
+
expect(createElement(), 'createElement()').to.be.undefined;
|
|
265
|
+
expect(createElement('input'), 'createElement(string)').to.be.instanceOf(HTMLInputElement);
|
|
266
|
+
expect(
|
|
267
|
+
createElement({
|
|
268
|
+
tagName: 'p',
|
|
269
|
+
className: 'lead',
|
|
270
|
+
innerText: 'This is a newly created paragraph.',
|
|
271
|
+
}),
|
|
272
|
+
'createElement(object)',
|
|
273
|
+
).to.be.instanceOf(HTMLParagraphElement);
|
|
274
|
+
expect(
|
|
275
|
+
createElement({
|
|
276
|
+
className: 'lead',
|
|
277
|
+
innerText: 'This is a newly created paragraph.',
|
|
278
|
+
}),
|
|
279
|
+
'createElement(incompleteObject)',
|
|
280
|
+
).to.be.undefined;
|
|
281
|
+
|
|
282
|
+
expect(createElementNS(), 'createElementNS()').to.be.undefined;
|
|
283
|
+
expect(
|
|
284
|
+
createElementNS('http://www.w3.org/2000/svg', 'svg'),
|
|
285
|
+
'createElementNS(ns, string)',
|
|
286
|
+
).to.be.instanceOf(SVGElement);
|
|
287
|
+
expect(
|
|
288
|
+
createElementNS('http://www.w3.org/1999/xhtml', {
|
|
289
|
+
tagName: 'button',
|
|
290
|
+
className: 'btn',
|
|
291
|
+
innerText: 'New Item',
|
|
292
|
+
}),
|
|
293
|
+
'createElementNS(ns, object)',
|
|
294
|
+
).to.be.instanceOf(HTMLButtonElement);
|
|
295
|
+
expect(
|
|
296
|
+
createElementNS('http://www.w3.org/2000/svg', {
|
|
297
|
+
tagName: 'path',
|
|
298
|
+
className: 'icon',
|
|
299
|
+
d: 'M98,158l157,156L411,158l27,27L255,368L71,185L98,158z',
|
|
300
|
+
}),
|
|
301
|
+
'createElementNS(ns, object)',
|
|
302
|
+
).to.be.instanceOf(SVGPathElement);
|
|
303
|
+
expect(
|
|
304
|
+
createElementNS('http://www.w3.org/2000/svg', {
|
|
305
|
+
tagName: '',
|
|
306
|
+
className: 'icon',
|
|
307
|
+
d: 'M98,158l157,156L411,158l27,27L255,368L71,185L98,158z',
|
|
308
|
+
}),
|
|
309
|
+
'createElementNS(ns, object)',
|
|
310
|
+
).to.be.undefined;
|
|
311
|
+
|
|
312
|
+
Data.set(el);
|
|
313
|
+
expect(Data.get(el), 'not enough params - Data.get(node)').to.be.null;
|
|
314
|
+
|
|
315
|
+
Data.set('str', 'strKey', 'data');
|
|
316
|
+
expect(Data.get('str', 'strKey'), 'not HTMLElement - Data.get(string, string, string)').to
|
|
317
|
+
.be.null;
|
|
318
|
+
|
|
319
|
+
Data.set(el, 'Alert', { element: el });
|
|
320
|
+
expect(Data.get(el, 'Alert'), 'Data.get(node, key)').to.deep.equal({ element: el });
|
|
321
|
+
expect(getInstance(el, 'Alert'), 'getInstance(node, key)').to.deep.equal({ element: el });
|
|
322
|
+
expect(Data.getAllFor('Alert').size, 'Data.getAllFor(string).size').to.equal(1);
|
|
323
|
+
|
|
324
|
+
Data.remove(el, 'Alert');
|
|
325
|
+
expect(Data.get(el, 'Alert'), 'removed - Data.get(node, string)').to.be.null;
|
|
326
|
+
expect(getInstance(el, 'Alert'), 'removed - getInstance(node, string)').to.be.null;
|
|
327
|
+
expect(Data.getAllFor('Alert'), 'removed - Data.getAllFor(string)').to.be.null;
|
|
328
|
+
Data.remove(el, 'Alert');
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
// import SHORTY from '../../src/index';
|
|
5
|
+
import * as SHORTY from '../../src/index';
|
|
6
|
+
|
|
7
|
+
import CustomElem from '../fixtures/custom-elem';
|
|
8
|
+
|
|
9
|
+
describe('Shorty Library Tests', () => {
|
|
10
|
+
before(() => {
|
|
11
|
+
cy.visit('cypress/test.html')
|
|
12
|
+
.wait(100);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('Test selectors folder', () => {
|
|
16
|
+
const {
|
|
17
|
+
closest,
|
|
18
|
+
getCustomElements,
|
|
19
|
+
getElementById,
|
|
20
|
+
getElementsByClassName,
|
|
21
|
+
getElementsByTagName,
|
|
22
|
+
matches,
|
|
23
|
+
querySelector,
|
|
24
|
+
querySelectorAll,
|
|
25
|
+
} = SHORTY;
|
|
26
|
+
|
|
27
|
+
cy
|
|
28
|
+
.get('.alert')
|
|
29
|
+
.then($alert => {
|
|
30
|
+
const [el] = $alert;
|
|
31
|
+
const win = el.ownerDocument.defaultView;
|
|
32
|
+
|
|
33
|
+
const CE = new CustomElem();
|
|
34
|
+
win.document.body.append(CE);
|
|
35
|
+
|
|
36
|
+
expect(querySelectorAll('div'), 'querySelectorAll(div)').to.have.length(0);
|
|
37
|
+
expect(querySelectorAll('div', win.document), 'querySelectorAll(div, parent)').to.have.length(1);
|
|
38
|
+
|
|
39
|
+
expect(querySelector(), 'querySelector()').to.be.null;
|
|
40
|
+
expect(querySelector(el), 'querySelector(node)').to.equal(el);
|
|
41
|
+
expect(querySelector('.alert'), 'querySelector(selector)').to.be.null;
|
|
42
|
+
expect(querySelector('.alert', win.document), 'querySelector(selector, parent)').to.eq(el);
|
|
43
|
+
|
|
44
|
+
expect(closest(el), 'closest()').to.be.null;
|
|
45
|
+
expect(closest(el, 'wombat'), 'closest(invalid)').to.be.null;
|
|
46
|
+
expect(closest(el, 'body'), 'closest(body)').to.eq(win.document.body);
|
|
47
|
+
|
|
48
|
+
expect(getCustomElements(), 'getCustomElements()').to.deep.equal([]);
|
|
49
|
+
expect(getCustomElements(win.document), 'getCustomElements(expected)').to.deep.equal([CE]);
|
|
50
|
+
|
|
51
|
+
expect(getElementById(), 'getElementById()').to.be.null;
|
|
52
|
+
expect(getElementById('alertDemo'), 'getElementById(id)').to.be.null;
|
|
53
|
+
expect(
|
|
54
|
+
getElementById('alertDemo', win.document),
|
|
55
|
+
'getElementById(id, parent)',
|
|
56
|
+
).to.be.instanceOf(win.HTMLDivElement);
|
|
57
|
+
|
|
58
|
+
expect(getElementsByClassName(), 'getElementsByClassName()').to.be.instanceOf(
|
|
59
|
+
HTMLCollection,
|
|
60
|
+
);
|
|
61
|
+
expect(
|
|
62
|
+
getElementsByClassName('alert'),
|
|
63
|
+
'getElementsByClassName(selector)',
|
|
64
|
+
).to.be.instanceOf(HTMLCollection);
|
|
65
|
+
expect(
|
|
66
|
+
getElementsByClassName('alert', win.document),
|
|
67
|
+
'getElementsByClassName(selector, parent)',
|
|
68
|
+
).to.be.instanceOf(win.HTMLCollection);
|
|
69
|
+
|
|
70
|
+
expect(getElementsByTagName(), 'getElementsByTagName()').to.be.instanceOf(HTMLCollection);
|
|
71
|
+
expect(getElementsByTagName('div'), 'getElementsByTagName(selector)').to.be.instanceOf(
|
|
72
|
+
HTMLCollection,
|
|
73
|
+
);
|
|
74
|
+
expect(
|
|
75
|
+
getElementsByTagName('div', win.document),
|
|
76
|
+
'getElementsByTagName(selector, parent)',
|
|
77
|
+
).to.be.instanceOf(win.HTMLCollection);
|
|
78
|
+
|
|
79
|
+
expect(
|
|
80
|
+
[...getElementsByClassName('alert', win.document)].filter(x => matches(x, 'div')),
|
|
81
|
+
'matches(node, selector)',
|
|
82
|
+
).to.deep.equal([el]);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const CEP = document.createElement('p');
|
|
2
|
+
CEP.innerText = 'Sample Custom Element';
|
|
3
|
+
|
|
4
|
+
export default class CustomElem extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.attachShadow({ mode: 'open' });
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
this.shadowRoot.append(CEP);
|
|
12
|
+
}
|
|
13
|
+
disconnectedCallback() {
|
|
14
|
+
this.shadowRoot.innerHTML = '';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
customElements.define('custom-elem', CustomElem);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// sources
|
|
2
|
+
// * https://github.com/enketo/enketo-express/blob/master/tools/esbuild-plugin-istanbul.js
|
|
3
|
+
'use strict';
|
|
4
|
+
import esbuild from 'esbuild';
|
|
5
|
+
import { promises } from 'fs';
|
|
6
|
+
import { createInstrumenter } from 'istanbul-lib-instrument';
|
|
7
|
+
import { extname, sep } from 'path';
|
|
8
|
+
import tsCompile from './tsCompile';
|
|
9
|
+
|
|
10
|
+
// import Cypress settings
|
|
11
|
+
const sourceFolder = 'src';
|
|
12
|
+
const [name] = process.cwd().split(sep).slice(-1);
|
|
13
|
+
|
|
14
|
+
const sourceFilter = `${name}${sep}${sourceFolder}`;
|
|
15
|
+
const instrumenter = createInstrumenter({
|
|
16
|
+
compact: false,
|
|
17
|
+
esModules: true,
|
|
18
|
+
preserveComments: true,
|
|
19
|
+
autoWrap: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const createEsbuildIstanbulPlugin = (): esbuild.Plugin => {
|
|
23
|
+
return {
|
|
24
|
+
name: 'istanbul',
|
|
25
|
+
setup(build: esbuild.PluginBuild) {
|
|
26
|
+
build.onLoad(
|
|
27
|
+
{ filter: /\.(ts|tsx)$/ },
|
|
28
|
+
async ({ path }: esbuild.OnLoadArgs): Promise<{ contents: string } & Record<string, any>> => {
|
|
29
|
+
|
|
30
|
+
if (!path.includes(sourceFilter)) {
|
|
31
|
+
// console.log("> compiling typescript %s for output build", path);
|
|
32
|
+
const contents = await promises.readFile(path, 'utf8');
|
|
33
|
+
return {
|
|
34
|
+
contents: ['.ts', '.tsx'].includes(extname(path)) ? tsCompile(path).outputText : contents,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// console.log("🧡 instrumenting %s for output coverage", path);
|
|
39
|
+
const { outputText, sourceMap } = tsCompile(path);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
contents: instrumenter.instrumentSync(outputText, path, sourceMap),
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default createEsbuildIstanbulPlugin;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// compile.ts
|
|
2
|
+
import TypeScript from 'typescript';
|
|
3
|
+
import { basename } from 'path';
|
|
4
|
+
import { RawSourceMap } from 'source-map';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
export default function tsCompile(
|
|
8
|
+
path: string,
|
|
9
|
+
ops?: Partial<TypeScript.TranspileOptions>,
|
|
10
|
+
): TypeScript.TranspileOutput & { sourceMap: RawSourceMap } {
|
|
11
|
+
// Default options -- you could also perform a merge, or use the project tsconfig.json
|
|
12
|
+
const options: TypeScript.TranspileOptions = Object.assign(
|
|
13
|
+
{
|
|
14
|
+
compilerOptions: {
|
|
15
|
+
allowJs: true,
|
|
16
|
+
esModuleInterop: true,
|
|
17
|
+
removeComments: false,
|
|
18
|
+
target: 99, // ESNext
|
|
19
|
+
allowSyntheticDefaultImports: true,
|
|
20
|
+
isolatedModules: true,
|
|
21
|
+
noEmitHelpers: true,
|
|
22
|
+
sourceMap: true,
|
|
23
|
+
} as Partial<TypeScript.CompilerOptions>,
|
|
24
|
+
},
|
|
25
|
+
ops,
|
|
26
|
+
);
|
|
27
|
+
const contents = readFileSync(path, { encoding: 'utf8' });
|
|
28
|
+
const { outputText, sourceMapText } = TypeScript.transpileModule(contents, options);
|
|
29
|
+
const sourceMap: RawSourceMap = JSON.parse(sourceMapText || '');
|
|
30
|
+
sourceMap.file = basename(path);
|
|
31
|
+
sourceMap.sources = [basename(path)];
|
|
32
|
+
|
|
33
|
+
return { outputText, sourceMap, sourceMapText };
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************
|
|
3
|
+
// This example commands.ts shows you how to
|
|
4
|
+
// create various custom commands and overwrite
|
|
5
|
+
// existing commands.
|
|
6
|
+
//
|
|
7
|
+
// For more comprehensive examples of custom
|
|
8
|
+
// commands please read more here:
|
|
9
|
+
// https://on.cypress.io/custom-commands
|
|
10
|
+
// ***********************************************
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
// -- This is a parent command --
|
|
14
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
// -- This is a child command --
|
|
18
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// -- This is a dual command --
|
|
22
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
23
|
+
//
|
|
24
|
+
//
|
|
25
|
+
// -- This will overwrite an existing command --
|
|
26
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
27
|
+
//
|
|
28
|
+
// declare global {
|
|
29
|
+
// namespace Cypress {
|
|
30
|
+
// interface Chainable {
|
|
31
|
+
// login(email: string, password: string): Chainable<void>
|
|
32
|
+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
33
|
+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
34
|
+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.ts is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import "./commands";
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
|
21
|
+
import "@cypress/code-coverage/support";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/index.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
|
21
|
+
|
|
22
|
+
import '@cypress/code-coverage/support'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>BSN Testing Page</title>
|
|
6
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
|
|
7
|
+
<style>
|
|
8
|
+
@keyframes animate-me {
|
|
9
|
+
0% { opacity: 1; }
|
|
10
|
+
50% { opacity: 0; }
|
|
11
|
+
100% { opacity: 1; }
|
|
12
|
+
}
|
|
13
|
+
@keyframes animate-test {
|
|
14
|
+
from { left: 0px; }
|
|
15
|
+
to { left: 150px; }
|
|
16
|
+
}
|
|
17
|
+
.animate-test {
|
|
18
|
+
animation-name: animate-test;
|
|
19
|
+
animation-duration: 0.3s;
|
|
20
|
+
animation-timing-function: ease-out;
|
|
21
|
+
animation-delay: 0s;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
</head>
|
|
25
|
+
<body class="container p-5">
|
|
26
|
+
<h3>Shorty Examples</h3>
|
|
27
|
+
<div id="alertDemo" class="alert alert-warning alert-dismissible fade show" data-cy="alert" data-bs-op1="false" data-bs-op2="true" data-bs-op3="10" data-bs-title="" role="alert">
|
|
28
|
+
<button type="button" class="btn-close bg-none" data-bs-target="alertDemo" data-bs-dismiss="alert" aria-label="Close">
|
|
29
|
+
<svg viewBox="0 0 16 16" class="align-top"><path name="x" d="M4.646 4.646a0.5 0.5 0 0 1 0.708 0L8 7.293l2.646 -2.647a0.5 0.5 0 0 1 0.708 0.708L8.707 8l2.647 2.646a0.5 0.5 0 0 1 -0.708 0.708L8 8.707l-2.646 2.647A0.5 0.5 0 0 1 4.646 10.646L7.293 8L4.646 5.354a0.5 0.5 0 0 1 0 -0.708z"></path></svg>
|
|
30
|
+
</button>
|
|
31
|
+
<p><b>Holy guacamole!</b> Best check yo self, you're not looking too good.</p>
|
|
32
|
+
<img src="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgODAgNDMiIHdpZHRoPSI4MCIgaGVpZ2h0PSI0MyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICAgICAgICAgICAgICAgIDxyZWN0IGZpbGw9IndoaXRlIiBzdHJva2U9IiNjY2MiIHN0cm9rZS13aWR0aD0iMSIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgcng9IjUiPjwvcmVjdD4NCiAgICAgICAgICAgICAgICAgIDx0ZXh0IGRpcmVjdGlvbj0ibHRyIiBmaWxsPSIjMzMzIiB4PSIyNSIgeT0iMjUiIGZvbnQtc2l6ZT0iMTQiPklNRzwvdGV4dD4NCiAgICAgICAgICAgICAgICA8L3N2Zz4=" alt="Image">
|
|
33
|
+
</div>
|
|
34
|
+
<table class="table">
|
|
35
|
+
<thead>
|
|
36
|
+
<tr>
|
|
37
|
+
<th>Event Type</th>
|
|
38
|
+
<th>Description</th>
|
|
39
|
+
</tr>
|
|
40
|
+
</thead>
|
|
41
|
+
<tbody>
|
|
42
|
+
<tr>
|
|
43
|
+
<td><code>show.bs.tooltip</code></td>
|
|
44
|
+
<td>This event fires immediately when the <code>show</code> instance method is called.<br>
|
|
45
|
+
<b>This event can be default prevented.</b></td>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<td><code>shown.bs.tooltip</code></td>
|
|
49
|
+
<td>This event is fired when the tooltip has been made visible to the user.</td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td><code>hide.bs.tooltip</code></td>
|
|
53
|
+
<td>This event is fired immediately when the <code>hide</code> instance method has been called.<br>
|
|
54
|
+
<b>This event can be default prevented.</b></td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td><code>hidden.bs.tooltip</code></td>
|
|
58
|
+
<td>This event is fired when the tooltip has finished being hidden from the user.</td>
|
|
59
|
+
</tr>
|
|
60
|
+
</tbody>
|
|
61
|
+
</table>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|