From 47f79abd0ef23bba1973eba38f8ee7246e710985 Mon Sep 17 00:00:00 2001 From: Valentin Kunz Date: Fri, 3 Jun 2022 12:49:54 +0200 Subject: [PATCH 1/2] apply default options explicitly while initializing --- src/SearchControl.ts | 2 +- src/__tests__/SearchControl.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SearchControl.ts b/src/SearchControl.ts index 9ca2b2d2f..ea30ce73e 100644 --- a/src/SearchControl.ts +++ b/src/SearchControl.ts @@ -164,7 +164,7 @@ const Control: SearchControl = { } // merge given options with control defaults - this.options = { ...this.options, ...options }; + this.options = { ...defaultOptions, ...options }; this.classNames = { ...this.classNames, ...options.classNames }; this.markers = new L.FeatureGroup(); diff --git a/src/__tests__/SearchControl.spec.js b/src/__tests__/SearchControl.spec.js index f4d108b03..faf3f27d0 100644 --- a/src/__tests__/SearchControl.spec.js +++ b/src/__tests__/SearchControl.spec.js @@ -84,3 +84,9 @@ test('Change view on result', () => { expect(map.setView).toHaveBeenCalled(); }); + +test('Default options are applied', () => { + const control = new SearchControl({ provider: jest.fn() }); + + expect(control.options).toEqual(expect.objectContaining({ style: 'button' })); +}); From 81703ac12dcd2ca4c2848cf9b8bc413e3ca54e9b Mon Sep 17 00:00:00 2001 From: Valentin Kunz Date: Fri, 3 Jun 2022 13:05:08 +0200 Subject: [PATCH 2/2] ci: run tests against multiple leaflet versions --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f04520572..83392fcd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,9 @@ jobs: runs-on: ubuntu-latest needs: [setup] timeout-minutes: 5 + strategy: + matrix: + leaflet: ["1.6.0", "1.7.1", "1.8.0"] steps: - uses: actions/checkout@v2 @@ -96,6 +99,9 @@ jobs: path: node_modules key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + - name: install specific leaflet version + run: npm install leaflet@${{ matrix.leaflet }} + - name: unit tests run: npm run ci:test env: