CSR-222: revised button to be button markup, not link
This commit is contained in:
parent
cc3d20d47c
commit
8de2948bcf
2 changed files with 10 additions and 14 deletions
|
|
@ -3,19 +3,20 @@ import buttonBack from "./button-back";
|
||||||
|
|
||||||
describe("back button", () => {
|
describe("back button", () => {
|
||||||
|
|
||||||
test("renders a link", () => {
|
test("renders a button", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const myFunction = () => {};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(buttonBack, {
|
const wrapper = shallowMount(buttonBack, {
|
||||||
propsData: {
|
propsData: {
|
||||||
backButtonUrl: "#",
|
backButtonAction: myFunction,
|
||||||
backButtonAccessibleText: "something",
|
backButtonAccessibleText: "something",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.find("a").exists()).toBe(true);
|
expect(wrapper.find("button").exists()).toBe(true);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -32,7 +33,7 @@ describe("back button", () => {
|
||||||
});
|
});
|
||||||
const handleClickMethod = jest.spyOn(wrapper.vm, "handleClick");
|
const handleClickMethod = jest.spyOn(wrapper.vm, "handleClick");
|
||||||
|
|
||||||
await wrapper.find("a").trigger("click");
|
await wrapper.find("button").trigger("click");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(handleClickMethod).toHaveBeenCalled();
|
expect(handleClickMethod).toHaveBeenCalled();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<a
|
<button
|
||||||
v-if="backButtonUrl || backButtonAction"
|
v-if="backButtonAction"
|
||||||
:href="backButtonUrl || '#'"
|
|
||||||
@click="handleClick($event)"
|
@click="handleClick($event)"
|
||||||
class="back-button-wrapper d-flex p-0"
|
class="back-button-wrapper d-flex p-0"
|
||||||
:aria-label="backButtonAccessibleText"
|
:aria-label="backButtonAccessibleText"
|
||||||
|
|
@ -10,17 +9,13 @@
|
||||||
<div class="arrow-left"></div>
|
<div class="arrow-left"></div>
|
||||||
<div class="box"></div>
|
<div class="box"></div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "buttonBack",
|
name: "buttonBack",
|
||||||
props: {
|
props: {
|
||||||
backButtonUrl: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
backButtonAccessibleText: {
|
backButtonAccessibleText: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
@ -28,12 +23,12 @@ export default {
|
||||||
backButtonAction: {
|
backButtonAction: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
|
required: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick: function (event) {
|
handleClick: function () {
|
||||||
if (this.backButtonAction) {
|
if (this.backButtonAction) {
|
||||||
event.preventDefault();
|
|
||||||
this.backButtonAction();
|
this.backButtonAction();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue