From bc7f5ff4022eb910c1e2192e8f1c24a0bc7c013a Mon Sep 17 00:00:00 2001 From: Carol Barno <32536886+CarolBarno@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:08:14 +0300 Subject: [PATCH] removed get methods from Alert.model.js (#797) removed get methods from Alert.model.js Co-authored-by: Carol-Barno --- .mailmap | 2 ++ CONTRIBUTING.md | 1 + src/components/core/Alert.vue | 8 ++++---- src/model/Alert.model.js | 12 ------------ tests/unit/model/alert.model.spec.js | 6 +++--- tests/unit/services/user.service.spec.js | 2 +- tests/unit/store/index.spec.js | 11 ++++++----- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.mailmap b/.mailmap index dfdbb7b35..c2ae8fc93 100644 --- a/.mailmap +++ b/.mailmap @@ -17,3 +17,5 @@ Tim Pillinger <26465611+wxtim@users.noreply.github.com> anewport dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Carol Barno +Carol Barno diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bda6ccbdb..b78702d34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,7 @@ below. - Edgardo Ramírez - Mel Hall - Ronnie Dutta + - Carol Barno (All contributors are identifiable with email addresses in the git version diff --git a/src/components/core/Alert.vue b/src/components/core/Alert.vue index 01d436673..734501745 100644 --- a/src/components/core/Alert.vue +++ b/src/components/core/Alert.vue @@ -19,9 +19,9 @@ along with this program. If not, see .
. - {{ alert.getText() }} + {{ alert.text }}
diff --git a/src/model/Alert.model.js b/src/model/Alert.model.js index 2d9be3544..ee586faaa 100644 --- a/src/model/Alert.model.js +++ b/src/model/Alert.model.js @@ -21,16 +21,4 @@ export default class Alert { this.icon = icon this.color = color } - - getText () { - return this.text - } - - getIcon () { - return this.icon - } - - getColor () { - return this.color - } } diff --git a/tests/unit/model/alert.model.spec.js b/tests/unit/model/alert.model.spec.js index 32941d073..acd953e0e 100644 --- a/tests/unit/model/alert.model.spec.js +++ b/tests/unit/model/alert.model.spec.js @@ -32,9 +32,9 @@ describe('Alert model', () => { const icon = 'error-icon' const color = 'success' const alert = new Alert(text, icon, color) - expect(alert.getText()).to.equal(text) - expect(alert.getIcon()).to.equal(icon) - expect(alert.getColor()).to.equal(color) + expect(alert.text).to.equal(text) + expect(alert.icon).to.equal(icon) + expect(alert.color).to.equal(color) }) }) }) diff --git a/tests/unit/services/user.service.spec.js b/tests/unit/services/user.service.spec.js index e97538153..b0dfcf85d 100644 --- a/tests/unit/services/user.service.spec.js +++ b/tests/unit/services/user.service.spec.js @@ -69,7 +69,7 @@ describe('UserService', () => { return store.dispatch('setAlert', alert) }) .finally(() => { - expect(store.state.alert.getText()).to.equal('Test Status') + expect(store.state.alert.text).to.equal('Test Status') }) }) }) diff --git a/tests/unit/store/index.spec.js b/tests/unit/store/index.spec.js index 9ce6531aa..877cdbf76 100644 --- a/tests/unit/store/index.spec.js +++ b/tests/unit/store/index.spec.js @@ -49,14 +49,15 @@ describe('index', () => { expect(store.state.alert).to.equal(null) }) it('should set alert', () => { - store.dispatch('setAlert', new Alert('my-alert', '', '')) - expect(store.state.alert.getText()).to.equal('my-alert') + const text = 'my-alert' + store.dispatch('setAlert', new Alert(text, '', '')) + expect(store.state.alert.text).to.equal(text) // repeating an alert with same text does not change anything - store.dispatch('setAlert', new Alert('my-alert', '', '')) - expect(store.state.alert.getText()).to.equal('my-alert') + store.dispatch('setAlert', new Alert(text, '', '')) + expect(store.state.alert.text).to.equal(text) // but if the text is different, it will use the new value store.dispatch('setAlert', new Alert('my-alert-2', '', '')) - expect(store.state.alert.getText()).to.equal('my-alert-2') + expect(store.state.alert.text).to.equal('my-alert-2') // and we can reset the state store.dispatch('setAlert', null) expect(store.state.alert).to.equal(null)