CSR-222: include header as link; updates

This commit is contained in:
Adam Caouette 2021-12-20 14:58:04 -05:00
parent 8de2948bcf
commit d393d12bec
4 changed files with 31 additions and 30 deletions

View file

@ -14,4 +14,19 @@ describe("FunnelSubHeader.vue", () => {
expect(wrapper.find("h2").text()).toContain("FunnelSubHeader Content");
wrapper.unmount();
});
it("Should render the button inside of header if backButtonAction provided", () => {
// Act
const testFn = () => {}
const wrapper = shallowMount(FunnelSubHeader, {
propsData: {
text: "FunnelSubHeader Content",
hasBackButton: true,
backButtonAction: testFn,
},
});
// Assert
expect(wrapper.find("h2").find("button").text()).toContain("FunnelSubHeader Content");
wrapper.unmount();
});
});

View file

@ -1,7 +1,14 @@
<template>
<div class="current_car_info-text">
<div class="d-flex align-items-center justify-content-center">
<h2 class="text-center fs-5 d-block fw-normal mb-0">{{ text }}</h2>
<h2 class="text-center fs-5 d-block fw-normal mb-0">
<button v-if="hasBackButton && backButtonAction" @click="backButtonAction">
{{ text }}
</button>
<span v-else>
{{ text }}
</span>
</h2>
<buttonBack
v-if="hasBackButton"
:backButtonAccessibleText="backButtonAccessibleText"
@ -32,6 +39,12 @@ export default {
<style lang="scss">
h2 {
color: $gray-550;
button {
border: none;
background: none;
color: inherit;
}
}
.back-button-wrapper {
margin-left: .25rem;

View file

@ -20,24 +20,4 @@ describe("back button", () => {
wrapper.unmount();
});
test("should execute handleClick function if it is clicked on", async () => {
// Arrange
const myFunction = () => {};
// Act
const wrapper = shallowMount(buttonBack, {
propsData: {
backButtonAction: myFunction,
backButtonAccessibleText: "something",
},
});
const handleClickMethod = jest.spyOn(wrapper.vm, "handleClick");
await wrapper.find("button").trigger("click");
// Assert
expect(handleClickMethod).toHaveBeenCalled();
wrapper.unmount();
});
});

View file

@ -1,7 +1,7 @@
<template>
<button
v-if="backButtonAction"
@click="handleClick($event)"
@click="backButtonAction"
class="back-button-wrapper d-flex p-0"
:aria-label="backButtonAccessibleText"
>
@ -19,20 +19,13 @@ export default {
backButtonAccessibleText: {
type: String,
required: true,
default: "",
},
backButtonAction: {
type: Function,
default: null,
required: true,
}
},
methods: {
handleClick: function () {
if (this.backButtonAction) {
this.backButtonAction();
}
},
},
};
</script>