From c146b1654de7b32ad03ca5fad6b997a48f31957c Mon Sep 17 00:00:00 2001 From: Raymond Rutjes Date: Wed, 9 Aug 2017 18:59:20 +0200 Subject: [PATCH] refactor(store): remove searchParameters getter and setter BREAKING CHANGE: if you previously used the `store.searchParameters` getters and setters of the store, you should now use `store.queryParameters` instead. --- src/__tests__/store.js | 30 +++++++++++++++--------------- src/store.js | 10 +--------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/__tests__/store.js b/src/__tests__/store.js index f9b453872..6bec1ce29 100644 --- a/src/__tests__/store.js +++ b/src/__tests__/store.js @@ -281,27 +281,27 @@ describe('Store', () => { ); }); - test('should accept new search parameters', () => { + test('should accept new query parameters', () => { const store = createStore(); - const newSearchParameters = { distinct: true }; + const newQueryParameters = { distinct: true }; - store.searchParameters = newSearchParameters; + store.queryParameters = newQueryParameters; - expect(store.searchParameters).toEqual( - expect.objectContaining(newSearchParameters) + expect(store.queryParameters).toEqual( + expect.objectContaining(newQueryParameters) ); }); test('highlighting tags set via query parameters should not leak to the helper', () => { const store = createStore(); - const newSearchParameters = { + const newQueryParameters = { highlightPreTag: '', highlightPostTag: '', }; - store.searchParameters = newSearchParameters; + store.queryParameters = newQueryParameters; expect(store._helper.state).toEqual( expect.objectContaining({ @@ -316,7 +316,7 @@ describe('Store', () => { store.highlightPreTag = ''; store.highlightPostTag = ''; - expect(store.searchParameters).toEqual( + expect(store.queryParameters).toEqual( expect.objectContaining({ highlightPreTag: '', highlightPostTag: '', @@ -324,27 +324,27 @@ describe('Store', () => { ); }); - test('page search parameter should start at 1', () => { + test('page query parameter should start at 1', () => { const store = createStore(); - expect(store.searchParameters).toHaveProperty('page', 1); + expect(store.queryParameters).toHaveProperty('page', 1); store._helper.setPage(2); - expect(store.searchParameters).toHaveProperty('page', 3); + expect(store.queryParameters).toHaveProperty('page', 3); - const newSearchParameters = Object.assign({}, store.searchParameters, { + const newQueryParameters = Object.assign({}, store.queryParameters, { page: 5, }); - store.searchParameters = newSearchParameters; + store.queryParameters = newQueryParameters; expect(store._helper.getPage()).toEqual(4); }); - test('search parameters should not contain internal highlighting tags', () => { + test('query parameters should not contain internal highlighting tags', () => { const store = createStore(); - expect(store.searchParameters).toEqual( + expect(store.queryParameters).toEqual( expect.objectContaining({ highlightPreTag: undefined, highlightPostTag: undefined, diff --git a/src/store.js b/src/store.js index 5e5666d7c..bb0d450de 100644 --- a/src/store.js +++ b/src/store.js @@ -324,15 +324,7 @@ export class Store { return this._helper.state.query; } - set queryParameters(parameters) { - this.searchParameters = parameters; - } - get queryParameters() { - return this.searchParameters; - } - - get searchParameters() { return Object.assign({}, this._helper.state, { page: this.page, highlightPreTag: this.highlightPreTag, @@ -340,7 +332,7 @@ export class Store { }); } - set searchParameters(searchParameters) { + set queryParameters(searchParameters) { const params = Object.assign({}, searchParameters); const paramKeys = Object.keys(params); paramKeys.forEach(key => {