Skip to content

Commit

Permalink
removed get methods from Alert.model.js (#797)
Browse files Browse the repository at this point in the history
removed get methods from Alert.model.js

Co-authored-by: Carol-Barno <cbarno@innovexsolutions.co.ke>
  • Loading branch information
CarolBarno and Carol-Barno authored Oct 8, 2021
1 parent b97780b commit bc7f5ff
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Tim Pillinger <26465611+wxtim@users.noreply.github.com> <tim.pillin
Ash Newport <anewport@dxc.com> anewport <anewport@dxc.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Carol Barno <carol.barno.dev@gmail.com>
Carol Barno <cbarno@innovexsolutions.co.ke>
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ below.
- Edgardo Ramírez
- Mel Hall
- Ronnie Dutta
- Carol Barno
<!-- end-shortlog -->

(All contributors are identifiable with email addresses in the git version
Expand Down
8 changes: 4 additions & 4 deletions src/components/core/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div v-if="alert">
<v-alert
:value="true"
:type="alert.getColor()"
:icon="alert.getIcon()"
:class="getColor(alert.getColor())"
:type="alert.color"
:icon="alert.icon"
:class="getColor(alert.color)"
dismissible
tile
light
Expand All @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<template v-slot:close="props">
<v-icon @click="closeAlert(props.toggle)">{{ svgPaths.close }}</v-icon>
</template>
{{ alert.getText() }}
{{ alert.text }}
</v-alert>
</div>
</template>
Expand Down
12 changes: 0 additions & 12 deletions src/model/Alert.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
6 changes: 3 additions & 3 deletions tests/unit/model/alert.model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
2 changes: 1 addition & 1 deletion tests/unit/services/user.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
})
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/store/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bc7f5ff

Please sign in to comment.