Skip to content

Commit 175198d

Browse files
committed
Adjusted space for consistency and readability
1 parent c58121b commit 175198d

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe('CredentialsLogic', () => {
102102
engines: ['someEngine'],
103103
},
104104
});
105+
105106
CredentialsLogic.actions.addEngineName('newEngine');
106107
expect(CredentialsLogic.values).toEqual({
107108
...values,
@@ -116,6 +117,7 @@ describe('CredentialsLogic', () => {
116117
engines: undefined,
117118
},
118119
});
120+
119121
CredentialsLogic.actions.addEngineName('newEngine');
120122
expect(CredentialsLogic.values).toEqual({
121123
...values,
@@ -139,6 +141,7 @@ describe('CredentialsLogic', () => {
139141
engines: ['someEngine', 'anotherEngine'],
140142
},
141143
});
144+
142145
CredentialsLogic.actions.removeEngineName('someEngine');
143146
expect(CredentialsLogic.values).toEqual({
144147
...values,
@@ -153,6 +156,7 @@ describe('CredentialsLogic', () => {
153156
engines: ['someEngine', 'anotherEngine'],
154157
},
155158
});
159+
156160
CredentialsLogic.actions.removeEngineName('notfound');
157161
expect(CredentialsLogic.values).toEqual({
158162
...values,
@@ -177,6 +181,7 @@ describe('CredentialsLogic', () => {
177181
engines: ['someEngine', 'anotherEngine'],
178182
},
179183
});
184+
180185
CredentialsLogic.actions.setAccessAllEngines(true);
181186
expect(CredentialsLogic.values).toEqual({
182187
...values,
@@ -192,6 +197,7 @@ describe('CredentialsLogic', () => {
192197
engines: ['someEngine', 'anotherEngine'],
193198
},
194199
});
200+
195201
CredentialsLogic.actions.setAccessAllEngines(false);
196202
expect(CredentialsLogic.values).toEqual({
197203
...values,
@@ -458,6 +464,7 @@ describe('CredentialsLogic', () => {
458464
describe('apiTokens', () => {
459465
it('should be set', () => {
460466
mount();
467+
461468
CredentialsLogic.actions.setCredentialsData(meta, [newToken, newToken]);
462469
expect(CredentialsLogic.values).toEqual({
463470
...values,
@@ -469,6 +476,7 @@ describe('CredentialsLogic', () => {
469476
describe('meta', () => {
470477
it('should be set', () => {
471478
mount();
479+
472480
CredentialsLogic.actions.setCredentialsData(meta, [newToken, newToken]);
473481
expect(CredentialsLogic.values).toEqual({
474482
...values,
@@ -482,6 +490,7 @@ describe('CredentialsLogic', () => {
482490
mount({
483491
isCredentialsDataComplete: false,
484492
});
493+
485494
CredentialsLogic.actions.setCredentialsData(meta, [newToken, newToken]);
486495
expect(CredentialsLogic.values).toEqual({
487496
...values,
@@ -503,6 +512,7 @@ describe('CredentialsLogic', () => {
503512
mount({
504513
isCredentialsDetailsComplete: false,
505514
});
515+
506516
CredentialsLogic.actions.setCredentialsDetails(credentialsDetails);
507517
expect(CredentialsLogic.values).toEqual({
508518
...values,
@@ -516,6 +526,7 @@ describe('CredentialsLogic', () => {
516526
mount({
517527
engines: [],
518528
});
529+
519530
CredentialsLogic.actions.setCredentialsDetails(credentialsDetails);
520531
expect(CredentialsLogic.values).toEqual({
521532
...values,
@@ -536,6 +547,7 @@ describe('CredentialsLogic', () => {
536547
mount({
537548
nameInputBlurred: false,
538549
});
550+
539551
CredentialsLogic.actions.setNameInputBlurred(true);
540552
expect(CredentialsLogic.values).toEqual({
541553
...values,
@@ -559,6 +571,7 @@ describe('CredentialsLogic', () => {
559571
read: false,
560572
},
561573
});
574+
562575
CredentialsLogic.actions.setTokenReadWrite({ name: 'read', checked: true });
563576
expect(CredentialsLogic.values).toEqual({
564577
...values,
@@ -586,6 +599,7 @@ describe('CredentialsLogic', () => {
586599
name: 'bar',
587600
},
588601
});
602+
589603
CredentialsLogic.actions.setTokenName('New Name');
590604
expect(CredentialsLogic.values).toEqual({
591605
...values,
@@ -597,6 +611,7 @@ describe('CredentialsLogic', () => {
597611
describe('activeApiTokenRawName', () => {
598612
it('updates the raw name, with no formatting applied', () => {
599613
mount();
614+
600615
CredentialsLogic.actions.setTokenName('New Name');
601616
expect(CredentialsLogic.values).toEqual({
602617
...values,
@@ -628,6 +643,7 @@ describe('CredentialsLogic', () => {
628643
access_all_engines: true,
629644
},
630645
});
646+
631647
CredentialsLogic.actions.setTokenType(ADMIN);
632648
expect(CredentialsLogic.values).toEqual({
633649
...values,
@@ -647,6 +663,7 @@ describe('CredentialsLogic', () => {
647663
access_all_engines: true,
648664
},
649665
});
666+
650667
CredentialsLogic.actions.setTokenType(PRIVATE);
651668
expect(CredentialsLogic.values).toEqual({
652669
...values,
@@ -664,6 +681,7 @@ describe('CredentialsLogic', () => {
664681
access_all_engines: false,
665682
},
666683
});
684+
667685
CredentialsLogic.actions.setTokenType(PRIVATE);
668686
expect(CredentialsLogic.values).toEqual({
669687
...values,
@@ -685,8 +703,15 @@ describe('CredentialsLogic', () => {
685703
engines: [{}, {}],
686704
},
687705
});
706+
688707
CredentialsLogic.actions.setTokenType(ADMIN);
689-
expect(CredentialsLogic.values.activeApiToken.engines).toEqual([]);
708+
expect(CredentialsLogic.values).toEqual({
709+
...values,
710+
activeApiToken: {
711+
...values.activeApiToken,
712+
engines: [],
713+
},
714+
});
690715
});
691716
});
692717

@@ -698,6 +723,7 @@ describe('CredentialsLogic', () => {
698723
engines: [{}, {}],
699724
},
700725
});
726+
701727
CredentialsLogic.actions.setTokenType(PRIVATE);
702728
expect(CredentialsLogic.values).toEqual({
703729
...values,
@@ -719,6 +745,7 @@ describe('CredentialsLogic', () => {
719745
write: false,
720746
},
721747
});
748+
722749
CredentialsLogic.actions.setTokenType(PRIVATE);
723750
expect(CredentialsLogic.values).toEqual({
724751
...values,
@@ -738,6 +765,7 @@ describe('CredentialsLogic', () => {
738765
write: true,
739766
},
740767
});
768+
741769
CredentialsLogic.actions.setTokenType(ADMIN);
742770
expect(CredentialsLogic.values).toEqual({
743771
...values,
@@ -759,6 +787,7 @@ describe('CredentialsLogic', () => {
759787
read: false,
760788
},
761789
});
790+
762791
CredentialsLogic.actions.setTokenType(PRIVATE);
763792
expect(CredentialsLogic.values).toEqual({
764793
...values,
@@ -778,6 +807,7 @@ describe('CredentialsLogic', () => {
778807
read: true,
779808
},
780809
});
810+
781811
CredentialsLogic.actions.setTokenType(ADMIN);
782812
expect(CredentialsLogic.values).toEqual({
783813
...values,
@@ -798,6 +828,7 @@ describe('CredentialsLogic', () => {
798828
type: ADMIN,
799829
},
800830
});
831+
801832
CredentialsLogic.actions.setTokenType(PRIVATE);
802833
expect(CredentialsLogic.values).toEqual({
803834
...values,
@@ -857,6 +888,7 @@ describe('CredentialsLogic', () => {
857888
describe('activeApiTokenRawName', () => {
858889
it('should set `activeApiTokenRawName` to the name of the provided token', () => {
859890
mount();
891+
860892
CredentialsLogic.actions.toggleCredentialsForm(newToken);
861893
expect(CredentialsLogic.values).toEqual({
862894
...values,
@@ -866,6 +898,7 @@ describe('CredentialsLogic', () => {
866898

867899
it('should set `activeApiTokenRawName` to the default value if no token is provided', () => {
868900
mount();
901+
869902
CredentialsLogic.actions.toggleCredentialsForm();
870903
expect(CredentialsLogic.values).toEqual({
871904
...values,
@@ -889,6 +922,7 @@ describe('CredentialsLogic', () => {
889922
describe('activeApiToken', () => {
890923
it('should set `activeApiToken` to the provided token', () => {
891924
mount();
925+
892926
CredentialsLogic.actions.toggleCredentialsForm(newToken);
893927
expect(CredentialsLogic.values).toEqual({
894928
...values,
@@ -900,6 +934,7 @@ describe('CredentialsLogic', () => {
900934
mount({
901935
activeApiToken: newToken,
902936
});
937+
903938
CredentialsLogic.actions.toggleCredentialsForm();
904939
expect(CredentialsLogic.values).toEqual({
905940
...values,
@@ -914,6 +949,7 @@ describe('CredentialsLogic', () => {
914949
mount({
915950
activeApiTokenIsExisting: false,
916951
});
952+
917953
CredentialsLogic.actions.toggleCredentialsForm(newToken);
918954
expect(CredentialsLogic.values).toEqual({
919955
...values,
@@ -926,6 +962,7 @@ describe('CredentialsLogic', () => {
926962
activeApiTokenIsExisting: true,
927963
});
928964
const { id, ...newTokenWithoutId } = newToken;
965+
929966
CredentialsLogic.actions.toggleCredentialsForm(newTokenWithoutId);
930967
expect(CredentialsLogic.values).toEqual({
931968
...values,
@@ -937,6 +974,7 @@ describe('CredentialsLogic', () => {
937974
mount({
938975
activeApiTokenIsExisting: true,
939976
});
977+
940978
CredentialsLogic.actions.toggleCredentialsForm();
941979
expect(CredentialsLogic.values).toEqual({
942980
...values,
@@ -958,6 +996,7 @@ describe('CredentialsLogic', () => {
958996
mount({
959997
activeApiTokenRawName: 'foo',
960998
});
999+
9611000
CredentialsLogic.actions.hideCredentialsForm();
9621001
expect(CredentialsLogic.values).toEqual({
9631002
...values,
@@ -971,6 +1010,7 @@ describe('CredentialsLogic', () => {
9711010
mount({
9721011
showCredentialsForm: true,
9731012
});
1013+
9741014
CredentialsLogic.actions.hideCredentialsForm();
9751015
expect(CredentialsLogic.values).toEqual({
9761016
...values,
@@ -993,6 +1033,7 @@ describe('CredentialsLogic', () => {
9931033
mount({
9941034
isCredentialsDetailsComplete: true,
9951035
});
1036+
9961037
CredentialsLogic.actions.resetCredentials();
9971038
expect(CredentialsLogic.values).toEqual({
9981039
...values,
@@ -1006,6 +1047,7 @@ describe('CredentialsLogic', () => {
10061047
mount({
10071048
isCredentialsDataComplete: true,
10081049
});
1050+
10091051
CredentialsLogic.actions.resetCredentials();
10101052
expect(CredentialsLogic.values).toEqual({
10111053
...values,
@@ -1019,6 +1061,7 @@ describe('CredentialsLogic', () => {
10191061
mount({
10201062
formErrors: ['I am an error'],
10211063
});
1064+
10221065
CredentialsLogic.actions.resetCredentials();
10231066
expect(CredentialsLogic.values).toEqual({
10241067
...values,
@@ -1033,6 +1076,7 @@ describe('CredentialsLogic', () => {
10331076
mount();
10341077
jest.spyOn(CredentialsLogic.actions, 'fetchCredentials').mockImplementationOnce(() => {});
10351078
jest.spyOn(CredentialsLogic.actions, 'fetchDetails').mockImplementationOnce(() => {});
1079+
10361080
CredentialsLogic.actions.initializeCredentialsData();
10371081
expect(CredentialsLogic.actions.fetchCredentials).toHaveBeenCalled();
10381082
expect(CredentialsLogic.actions.fetchDetails).toHaveBeenCalled();
@@ -1056,7 +1100,6 @@ describe('CredentialsLogic', () => {
10561100
(HttpLogic.values.http.get as jest.Mock).mockReturnValue(Promise.resolve({ meta, results }));
10571101

10581102
CredentialsLogic.actions.fetchCredentials(2);
1059-
10601103
expect(HttpLogic.values.http.get).toHaveBeenCalledWith('/api/app_search/credentials', {
10611104
query: {
10621105
'page[current]': 2,
@@ -1071,7 +1114,6 @@ describe('CredentialsLogic', () => {
10711114
(HttpLogic.values.http.get as jest.Mock).mockReturnValue(Promise.reject('An error occured'));
10721115

10731116
CredentialsLogic.actions.fetchCredentials(2);
1074-
10751117
await flushPromises();
10761118
expect(flashAPIErrors).toHaveBeenCalledWith('An error occured');
10771119
});
@@ -1084,6 +1126,7 @@ describe('CredentialsLogic', () => {
10841126
.spyOn(CredentialsLogic.actions, 'setCredentialsDetails')
10851127
.mockImplementationOnce(() => {});
10861128
(HttpLogic.values.http.get as jest.Mock).mockReturnValue(Promise.resolve(credentialsDetails));
1129+
10871130
CredentialsLogic.actions.fetchDetails();
10881131
expect(HttpLogic.values.http.get).toHaveBeenCalledWith('/api/app_search/credentials/details');
10891132
await flushPromises();
@@ -1097,7 +1140,6 @@ describe('CredentialsLogic', () => {
10971140
(HttpLogic.values.http.get as jest.Mock).mockReturnValue(Promise.reject('An error occured'));
10981141

10991142
CredentialsLogic.actions.fetchDetails();
1100-
11011143
await flushPromises();
11021144
expect(flashAPIErrors).toHaveBeenCalledWith('An error occured');
11031145
});
@@ -1110,6 +1152,7 @@ describe('CredentialsLogic', () => {
11101152
mount();
11111153
jest.spyOn(CredentialsLogic.actions, 'onApiKeyDelete').mockImplementationOnce(() => {});
11121154
(HttpLogic.values.http.delete as jest.Mock).mockReturnValue(Promise.resolve());
1155+
11131156
CredentialsLogic.actions.deleteApiKey(tokenName);
11141157
expect(HttpLogic.values.http.delete).toHaveBeenCalledWith(
11151158
`/api/app_search/credentials/${tokenName}`
@@ -1125,7 +1168,6 @@ describe('CredentialsLogic', () => {
11251168
);
11261169

11271170
CredentialsLogic.actions.deleteApiKey(tokenName);
1128-
11291171
await flushPromises();
11301172
expect(flashAPIErrors).toHaveBeenCalledWith('An error occured');
11311173
});

x-pack/plugins/enterprise_search/public/applications/app_search/utils/format_api_name/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ describe('formatApiName', () => {
1010
it('replaces non-alphanumeric characters with dashes', () => {
1111
expect(formatApiName('f1 &&o$ 1 2 *&%da')).toEqual('f1-o-1-2-da');
1212
});
13+
1314
it('strips leading and trailing non-alphanumeric characters', () => {
1415
expect(formatApiName('$$hello world**')).toEqual('hello-world');
1516
});
17+
1618
it('strips leading and trailing whitespace', () => {
1719
expect(formatApiName(' test ')).toEqual('test');
1820
});
21+
1922
it('lowercases text', () => {
2023
expect(formatApiName('SomeName')).toEqual('somename');
2124
});

0 commit comments

Comments
 (0)