Skip to content

Commit f2af778

Browse files
committed
wrote tests for all of the props and ui elements
we can't test if the ui elements update because that would require passing in new props in response to a parent state change and this is a unit test, so no parent component
1 parent 880c649 commit f2af778

File tree

2 files changed

+566
-158
lines changed

2 files changed

+566
-158
lines changed

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ class Preferences extends React.Component {
100100
<TabList>
101101
<div className="tabs__titles">
102102
<Tab>
103-
<h4 className="tabs__title">
103+
<h4 className="tabs__title" data-testid="general-settings-tab">
104104
{this.props.t('Preferences.GeneralSettings')}
105105
</h4>
106106
</Tab>
107107
<Tab>
108-
<h4 className="tabs__title">
108+
<h4 className="tabs__title" data-testid="accessibility-tab">
109109
{this.props.t('Preferences.Accessibility')}
110110
</h4>
111111
</Tab>
@@ -126,6 +126,7 @@ class Preferences extends React.Component {
126126
className="preference__radio-button"
127127
value="light"
128128
checked={this.props.theme === 'light'}
129+
data-testid="theme-light-radio"
129130
/>
130131
<label htmlFor="light-theme-on" className="preference__option">
131132
{this.props.t('Preferences.LightTheme')}
@@ -139,6 +140,7 @@ class Preferences extends React.Component {
139140
className="preference__radio-button"
140141
value="dark"
141142
checked={this.props.theme === 'dark'}
143+
data-testid="theme-dark-radio"
142144
/>
143145
<label htmlFor="dark-theme-on" className="preference__option">
144146
{this.props.t('Preferences.DarkTheme')}
@@ -152,6 +154,7 @@ class Preferences extends React.Component {
152154
className="preference__radio-button"
153155
value="contrast"
154156
checked={this.props.theme === 'contrast'}
157+
data-testid="theme-contrast-radio"
155158
/>
156159
<label
157160
htmlFor="high-contrast-theme-on"
@@ -304,6 +307,7 @@ class Preferences extends React.Component {
304307
className="preference__radio-button"
305308
value="On"
306309
checked={this.props.linewrap}
310+
data-testid="linewrap-true-radio"
307311
/>
308312
<label htmlFor="linewrap-on" className="preference__option">
309313
{this.props.t('Preferences.On')}
@@ -317,6 +321,7 @@ class Preferences extends React.Component {
317321
className="preference__radio-button"
318322
value="Off"
319323
checked={!this.props.linewrap}
324+
data-testid="linewrap-false-radio"
320325
/>
321326
<label htmlFor="linewrap-off" className="preference__option">
322327
{this.props.t('Preferences.Off')}
@@ -339,6 +344,7 @@ class Preferences extends React.Component {
339344
className="preference__radio-button"
340345
value="On"
341346
checked={this.props.lineNumbers}
347+
data-testid="lineNumbers-true-radio"
342348
/>
343349
<label htmlFor="line-numbers-on" className="preference__option">
344350
{this.props.t('Preferences.On')}
@@ -352,6 +358,7 @@ class Preferences extends React.Component {
352358
className="preference__radio-button"
353359
value="Off"
354360
checked={!this.props.lineNumbers}
361+
data-testid="lineNumbers-false-radio"
355362
/>
356363
<label
357364
htmlFor="line-numbers-off"
@@ -375,6 +382,7 @@ class Preferences extends React.Component {
375382
className="preference__radio-button"
376383
value="On"
377384
checked={this.props.lintWarning}
385+
data-testid="lintWarning-true-radio"
378386
/>
379387
<label htmlFor="lint-warning-on" className="preference__option">
380388
{this.props.t('Preferences.On')}
@@ -388,6 +396,7 @@ class Preferences extends React.Component {
388396
className="preference__radio-button"
389397
value="Off"
390398
checked={!this.props.lintWarning}
399+
data-testid="lintWarning-false-radio"
391400
/>
392401
<label
393402
htmlFor="lint-warning-off"
@@ -423,6 +432,7 @@ class Preferences extends React.Component {
423432
id="text-output-on"
424433
value="On"
425434
checked={this.props.textOutput}
435+
data-testid="text-output-checkbox"
426436
/>
427437
<label
428438
htmlFor="text-output-on"
@@ -440,6 +450,7 @@ class Preferences extends React.Component {
440450
id="table-output-on"
441451
value="On"
442452
checked={this.props.gridOutput}
453+
data-testid="grid-output-checkbox"
443454
/>
444455
<label
445456
htmlFor="table-output-on"
@@ -457,6 +468,7 @@ class Preferences extends React.Component {
457468
id="sound-output-on"
458469
value="On"
459470
checked={this.props.soundOutput}
471+
data-testid="sound-output-checkbox"
460472
/>
461473
<label
462474
htmlFor="sound-output-on"

0 commit comments

Comments
 (0)