Skip to content

Commit ba092dc

Browse files
committed
add tests
1 parent 5165b7a commit ba092dc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {assignElementProperty} from './common-button.ts';
2+
3+
test('assignElementProperty', () => {
4+
const elForm = document.createElement('form');
5+
assignElementProperty(elForm, 'action', '/test-link');
6+
expect(elForm.action).contains('/test-link'); // the DOM always returns absolute URL
7+
assignElementProperty(elForm, 'text-content', 'dummy');
8+
expect(elForm.textContent).toBe('dummy');
9+
10+
const elInput = document.createElement('input');
11+
expect(elInput.readOnly).toBe(false);
12+
assignElementProperty(elInput, 'read-only', 'true');
13+
expect(elInput.readOnly).toBe(true);
14+
});

web_src/js/features/common-button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function onHidePanelClick(el: HTMLElement, e: MouseEvent) {
102102
throw new Error('no panel to hide'); // should never happen, otherwise there is a bug in code
103103
}
104104

105-
function assignElementProperty(el: any, name: string, val: string) {
105+
export function assignElementProperty(el: any, name: string, val: string) {
106106
name = camelize(name);
107107
const old = el[name];
108108
if (typeof old === 'boolean') {

0 commit comments

Comments
 (0)