From e04c999264be116e60d08673c2adcf723afe1687 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Mon, 18 Nov 2019 13:08:25 +0100 Subject: [PATCH] Add select remove test --- js/test/select.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/test/select.test.js b/js/test/select.test.js index 3123d43..a5b96dc 100644 --- a/js/test/select.test.js +++ b/js/test/select.test.js @@ -251,4 +251,22 @@ describe('Select tests', () => { expect(select.element.options[2].selected).toBe(true); }); + it('should remove option from select elements', () => { + // given + const select = new uSelect(element); + select.setOptions(options, options[1].listValue); + + expect(select.element.options.length).toBe(options.length); + // when + select.remove(options[0].listValue); + // then + expect(select.element).toBe(element); + expect(select.element.options.length).toBe(options.length - 1); + expect(select.element.options[0].disabled).toBe(false); + expect(select.element.options[0].defaultSelected).toBe(false); + expect(select.element.options[0].selected).toBe(true); + expect(select.element.options[0].text).toBe(options[1].listText); + expect(select.element.options[0].value).toBe(options[1].listValue); + }); + });