From ac44be339b5895e029854bc3b53617e6c600d282 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 15 Aug 2017 15:11:59 +0200 Subject: [PATCH] Add test for making sure `addQueryArgs` updates existing arguments. This is to ensure it will not leave duplicate arguments behind. --- packages/url/src/test/index.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/url/src/test/index.test.js b/packages/url/src/test/index.test.js index 82e5729a8cab2..08d29b64d47c9 100644 --- a/packages/url/src/test/index.test.js +++ b/packages/url/src/test/index.test.js @@ -17,4 +17,11 @@ describe( 'addQueryArgs', () => { expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.com/beach?night=false&sun=true&sand=false' ); } ); + + test( 'should update args to an URL with conflicting query string', () => { + const url = 'https://andalouses.com/beach?night=false&sun=false&sand=true'; + const args = { sun: 'true', sand: 'false' }; + + expect( addQueryArgs( url, args ) ).toBe( 'https://andalouses.com/beach?night=false&sun=true&sand=false' ); + } ); } );