Skip to content

Commit 05ae42c

Browse files
refactor: config adjustments
1 parent d3effde commit 05ae42c

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ runValueAccessorTests({
2929
declarations: [ComboboxComponent],
3030
},
3131
supportsOnBlur: true,
32-
getNativeControlSelector: 'input.combobox-input',
32+
nativeControlSelector: 'input.combobox-input',
3333
internalValueChangeSetter: (fixture, value) => {
3434
fixture.componentInstance.setValue(value, true);
3535
},
@@ -79,9 +79,9 @@ This is related to the ability to track blur events in order to set `emitOn: 'bl
7979

8080
If set to true, component will be tested to not call `onTouched` event when value changed.
8181
Instead of this, it will be expected to trigger this function
82-
by html blur event using native control (see `getNativeControlSelector`in this config).
82+
by html blur event using native control (see `nativeControlSelector`in this config).
8383

84-
#### getNativeControlSelector?: string
84+
#### nativeControlSelector?: string
8585

8686
CSS selector for the element, that should dispatch `blur` event. Required and used only if `supportsOnBlur` is set to true.
8787
Provided selected will be used to programmatically dispatch `blur` event.
@@ -95,7 +95,7 @@ Example:
9595
For the CVA with HTML as above the following should be provided:
9696

9797
```typescript
98-
getNativeControlSelector: 'input.combobox-input';
98+
nativeControlSelector: 'input.combobox-input';
9999
```
100100

101101
#### internalValueChangeSetter: (fixture: ComponentFixture<H>, value: any) => void

apps/integration/src/app/controls/combobox/combobox.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runValueAccessorTests({
77
declarations: [ComboboxComponent],
88
},
99
supportsOnBlur: true,
10-
getNativeControlSelector: 'input.combobox-input',
10+
nativeControlSelector: 'input.combobox-input',
1111
internalValueChangeSetter: (fixture, value) => {
1212
fixture.componentInstance.setValue(value, true);
1313
},

apps/integration/src/app/controls/toggle/toggle.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runValueAccessorTests({
99
imports: [FormsModule],
1010
},
1111
supportsOnBlur: true,
12-
getNativeControlSelector: 'input.toggle__input',
12+
nativeControlSelector: 'input.toggle__input',
1313
internalValueChangeSetter: (fixture, value) => {
1414
fixture.componentInstance.setValue(value, true);
1515
},

libs/ngx-cva-test-suite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Standardise your custom UI form components with ControlValueAccessor Test Suite",
44
"author": "Dmitriy Stepanenko",
55
"license": "MIT",
6-
"version": "1.0.1",
6+
"version": "1.0.2",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/dmitry-stepanenko/ngx-cva-test-suite"

libs/ngx-cva-test-suite/src/lib/models/test-config.models.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface CVATestConfig<T extends CVAComponentType, H = T> {
3737
*
3838
* If set to true, component will be tested to not call `onTouched` event when value changed.
3939
* Instead of this, it will be expected to trigger this function
40-
* by html blur event using native control (see `getNativeControlSelector`in this config).
40+
* by html blur event using native control (see `nativeControlSelector`in this config).
4141
*/
4242
supportsOnBlur: boolean;
4343
/**
@@ -51,10 +51,10 @@ export interface CVATestConfig<T extends CVAComponentType, H = T> {
5151
* For the CVA with HTML as above the following should be provided:
5252
*
5353
* ```typescript
54-
* getNativeControlSelector: 'input.combobox-input'
54+
* nativeControlSelector: 'input.combobox-input'
5555
* ```
5656
*/
57-
getNativeControlSelector?: string;
57+
nativeControlSelector?: string;
5858
/**
5959
* Tests the approach that is used to set value in the component, when the change is internal
6060
* (e.g. by clicking on an option of the select or typing in the input field).

libs/ngx-cva-test-suite/src/lib/ngx-cva-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ runValueAccessorTests<DefaultValueAccessor, DefaultCVAWrapperComponent>({
2727
getTestingComponent: (fixture) => fixture.componentInstance.defaultCtrl,
2828
},
2929
supportsOnBlur: true,
30-
getNativeControlSelector: 'input[ngDefaultControl]',
30+
nativeControlSelector: 'input[ngDefaultControl]',
3131
internalValueChangeSetter: null,
3232
getComponentValue: (fixture) => fixture.componentInstance.value,
3333
resetCustomValue: { value: '' },

libs/ngx-cva-test-suite/src/lib/ngx-cva-test-suite.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { TestRunnerResolver } from './utils/test-runner-resolver';
2222
* declarations: [ComboboxComponent],
2323
* },
2424
* supportsOnBlur: true,
25-
* getNativeControlSelector: 'input.combobox-input',
25+
* nativeControlSelector: 'input.combobox-input',
2626
* internalValueChangeSetter: (fixture, value) => {
2727
* fixture.componentInstance.setValue(value, true);
2828
* },
@@ -207,8 +207,8 @@ export function runValueAccessorTests<T extends CVAComponentType, H = T>(config:
207207
setupPlainValues();
208208
let nativeControlDebugElement: DebugElement;
209209
let nativeControl: EventTarget | undefined;
210-
if (config.getNativeControlSelector) {
211-
nativeControlDebugElement = fixture.debugElement.query(By.css(config.getNativeControlSelector));
210+
if (config.nativeControlSelector) {
211+
nativeControlDebugElement = fixture.debugElement.query(By.css(config.nativeControlSelector));
212212
nativeControl = nativeControlDebugElement?.nativeElement;
213213
}
214214
expect(nativeControl).toBeDefined();
@@ -226,8 +226,8 @@ function getValues(): [string, string, string] {
226226
}
227227

228228
function validateConfig(config: CVATestConfig<any>) {
229-
if (config.supportsOnBlur && typeof config.getNativeControlSelector !== 'string') {
230-
throw new Error('Expected "getNativeControlSelector" to be defined, if "supportsOnBlur" is set to true.');
229+
if (config.supportsOnBlur && typeof config.nativeControlSelector !== 'string') {
230+
throw new Error('Expected "nativeControlSelector" to be defined, if "supportsOnBlur" is set to true.');
231231
}
232232
}
233233

scripts/local-publish.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ npm run build-package
1515
echo "Running \"npm pack\".."
1616
cd dist/libs/ngx-cva-test-suite/
1717
npm pack
18-
echo "Publishing.."
19-
npm publish
18+
19+
if [ $# -ne 0 ] && [ $1 = '--publish' ]
20+
then
21+
echo "Publishing.."
22+
npm publish
23+
else
24+
echo 'Stopped before publishing'
25+
fi

0 commit comments

Comments
 (0)