chore: fix tests
This commit is contained in:
parent
9434a2fae7
commit
b45f340aba
8 changed files with 22 additions and 26 deletions
|
|
@ -3,4 +3,4 @@ CHANGELOG.md
|
|||
bundlesize/
|
||||
_site
|
||||
_site-dev
|
||||
.history
|
||||
.history
|
||||
|
|
|
|||
|
|
@ -345,9 +345,18 @@ const FormatMixinImplementation = superclass =>
|
|||
*/
|
||||
__handlePreprocessor() {
|
||||
const unprocessedValue = this.value;
|
||||
let currentCaretIndex = this.value.length;
|
||||
// Be gentle with Safari
|
||||
if (
|
||||
this._inputNode &&
|
||||
'selectionStart' in this._inputNode &&
|
||||
/** @type {HTMLInputElement} */ (this._inputNode)?.type !== 'range'
|
||||
) {
|
||||
currentCaretIndex = /** @type {number} */ (this._inputNode.selectionStart);
|
||||
}
|
||||
const preprocessedValue = this.preprocessor(this.value, {
|
||||
...this.formatOptions,
|
||||
currentCaretIndex: this._inputNode?.selectionStart || this.value.length,
|
||||
currentCaretIndex,
|
||||
prevViewValue: this.__prevViewValue,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,8 @@ describe('Validator', () => {
|
|||
}
|
||||
}
|
||||
|
||||
const vali = new MyValidator(
|
||||
{},
|
||||
{ getMessage: async () => 'This is the custom error message' },
|
||||
);
|
||||
// @ts-ignore needed for test
|
||||
const vali = new MyValidator({}, { getMessage: 'This is the custom error message' });
|
||||
const { getMessage } = getProtectedMembers(vali);
|
||||
|
||||
await expectThrowsAsync(
|
||||
|
|
@ -98,7 +96,7 @@ describe('Validator', () => {
|
|||
name: 'MyValidator',
|
||||
type: 'error',
|
||||
params: 'myParam',
|
||||
config: { my: 'config', getMessage: configSpy },
|
||||
config: { fieldName: 'X', getMessage: configSpy },
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -125,7 +123,7 @@ describe('Validator', () => {
|
|||
name: 'MyValidator',
|
||||
type: 'error',
|
||||
params: 'myParam',
|
||||
config: { my: 'config' },
|
||||
config: { fieldName: 'X' },
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
"access": "public"
|
||||
},
|
||||
"customElements": "custom-elements.json",
|
||||
"customElementsManifest": "custom-elements.json",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./define": "./define.js",
|
||||
|
|
|
|||
|
|
@ -209,18 +209,5 @@ export function runInputTelDropdownSuite({ klass = LionInputTelDropdown } = {})
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When refs.dropdown is a FormControl (LionSelectRich/LionCombobox)', () => {
|
||||
it('updates dropdown value ', async () => {
|
||||
const el = await fixture(html` <${tag} .modelValue="${'+31612345678'}"></${tag}> `);
|
||||
expect(el.activeRegion).to.equal('NL');
|
||||
// @ts-expect-error [allow protected]
|
||||
el._setActiveRegion('BE');
|
||||
await el.updateComplete;
|
||||
expect(getDropdownValue(/** @type {DropdownElement} */ (el.refs.dropdown.value))).to.equal(
|
||||
'BE',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ class WithFormControlInputTelDropdown extends LionInputTelDropdown {
|
|||
// @ts-expect-error
|
||||
runInputTelSuite({ klass: LionInputTelDropdown });
|
||||
runInputTelDropdownSuite();
|
||||
// @ts-expect-error
|
||||
// Runs it for LionSelectRich, which uses .modelValue/@model-value-changed instead of .value/@change
|
||||
runInputTelDropdownSuite({ klass: WithFormControlInputTelDropdown });
|
||||
|
||||
describe('WithFormControlInputTelDropdown', () => {
|
||||
// @ts-expect-error
|
||||
// Runs it for LionSelectRich, which uses .modelValue/@model-value-changed instead of .value/@change
|
||||
runInputTelDropdownSuite({ klass: WithFormControlInputTelDropdown });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@
|
|||
"access": "public"
|
||||
},
|
||||
"customElements": "custom-elements.json",
|
||||
"customElementsManifest": "custom-elements.json",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./define": "./define.js",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const packages = fs
|
|||
.filter(
|
||||
dir => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test`),
|
||||
)
|
||||
// .filter(x => x.endsWith('-dropdown'))
|
||||
.concat(
|
||||
fs
|
||||
.readdirSync('packages/helpers')
|
||||
|
|
|
|||
Loading…
Reference in a new issue