File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 4848 "displayName" : " Unit" ,
4949 "preset" : " @activewidgets/testing" ,
5050 "moduleNameMapper" : {
51- "@activewidgets/components" : " <rootDir>/jquery " ,
51+ "@activewidgets/components" : " <rootDir>/js " ,
5252 "@activewidgets/testing" : " <rootDir>/test/adapter/jquery.js"
5353 }
5454 },
Original file line number Diff line number Diff line change 1+
2+ import { getQueriesForElement } from '@testing-library/dom' ;
3+ import '@activewidgets/components' ;
4+ import $ from 'jquery' ;
5+
6+
7+ export function render ( component , props ) {
8+
9+ let baseElement = document . body ,
10+ container = baseElement . appendChild ( document . createElement ( 'div' ) ) ,
11+ el = container . appendChild ( document . createElement ( component ) ) ;
12+
13+ let i , $el = $ ( el ) ;
14+
15+ for ( i in props ) {
16+ if ( i . slice ( 0 , 2 ) == 'on' ) {
17+ $el . on ( i . slice ( 2 ) . toLowerCase ( ) , event => props [ i ] ( event . detail ) ) ;
18+ }
19+ else {
20+ $el . prop ( i , props [ i ] ) ;
21+ }
22+ }
23+
24+ $el . mount ( ) ;
25+
26+ return {
27+ container,
28+ baseElement,
29+ ...getQueriesForElement ( baseElement )
30+ }
31+ } ;
32+
33+
34+ export function cleanup ( ) {
35+ document . body . innerHTML = '' ;
36+ } ;
37+
38+
39+ if ( typeof afterEach === 'function' ) {
40+ afterEach ( cleanup ) ;
41+ }
You can’t perform that action at this time.
0 commit comments