Skip to content

Commit d0dfe92

Browse files
committed
fixed test and hardened code
1 parent bb1d216 commit d0dfe92

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function tabWidget (options: TabWidgetOptions) {
235235
const tab = selectedTab1 || selectedTab0 || tabContainer.children[0] as HTMLButtonElement
236236
const clickMe = tab.firstChild
237237
// @ts-ignore
238-
clickMe.click()
238+
if (clickMe) clickMe.click()
239239
} else if (!options.startEmpty) {
240240
(tabContainer.children[0].firstChild as HTMLButtonElement).click() // Open first tab
241241
}

test/unit/widgets/forms/__snapshots__/basic.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports[`basicField adds the basic field to the container, if provided 1`] = `
2222
<input
2323
maxlength="4096"
2424
size="20"
25-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
25+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
2626
type="text"
2727
/>
2828
</div>
@@ -51,7 +51,7 @@ exports[`basicField creates a basic field 1`] = `
5151
<input
5252
maxlength="4096"
5353
size="20"
54-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
54+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
5555
type="text"
5656
/>
5757
</div>

test/unit/widgets/forms/autocomplete/__snapshots__/autocomplete.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ exports[`autocompleteField clicking on row of greenn table then accecpt button s
5555
<input
5656
data-testid="autocomplete-input"
5757
size="60"
58-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
58+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
5959
type="text"
6060
/>
6161
</td>
@@ -146,7 +146,7 @@ exports[`autocompleteField creates a autocomplete field 1`] = `
146146
<input
147147
data-testid="autocomplete-input"
148148
size="60"
149-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
149+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
150150
type="text"
151151
/>
152152
</td>
@@ -215,7 +215,7 @@ exports[`autocompleteField on inpt fetches data (fixing wikidata timeout issue)
215215
<input
216216
data-testid="autocomplete-input"
217217
size="60"
218-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
218+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
219219
type="text"
220220
/>
221221
</td>
@@ -272,7 +272,7 @@ exports[`autocompleteField typing more search term till unique selects the whole
272272
<input
273273
data-testid="autocomplete-input"
274274
size="60"
275-
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;"
275+
style="background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;"
276276
type="text"
277277
/>
278278
</td>

test/unit/widgets/forms/basic.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe('basicField', () => {
208208
inputElement.value = '555-1234'
209209
const event = new Event('keyup')
210210
inputElement.dispatchEvent(event)
211-
expect(inputElement.getAttribute('style')).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;color: green;')
211+
expect(inputElement.getAttribute('style')).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;color: green;')
212212
})
213213

214214
it('goes red if value doesnt match pattern', () => {
@@ -237,7 +237,7 @@ describe('basicField', () => {
237237
inputElement.value = 'not a valid phone number'
238238
const event = new Event('keyup')
239239
inputElement.dispatchEvent(event)
240-
expect(inputElement.getAttribute('style')).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;color: red;')
240+
expect(inputElement.getAttribute('style')).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;color: red;')
241241
})
242242

243243
it('handles change if value doesnt match pattern', () => {
@@ -648,7 +648,7 @@ describe('basicField', () => {
648648
callbackFunction
649649
)
650650
const style = (result.childNodes[1].childNodes[0] as HTMLInputElement).getAttribute('style')
651-
expect(style).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;text-align: right;')
651+
expect(style).toEqual('background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.4em;text-align: right;')
652652
})
653653

654654
it('Defaults to textInputStyle', () => {

0 commit comments

Comments
 (0)