CSR-222: include header as link; updates
This commit is contained in:
parent
8de2948bcf
commit
d393d12bec
4 changed files with 31 additions and 30 deletions
|
|
@ -14,4 +14,19 @@ describe("FunnelSubHeader.vue", () => {
|
||||||
expect(wrapper.find("h2").text()).toContain("FunnelSubHeader Content");
|
expect(wrapper.find("h2").text()).toContain("FunnelSubHeader Content");
|
||||||
wrapper.unmount();
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="current_car_info-text">
|
<div class="current_car_info-text">
|
||||||
<div class="d-flex align-items-center justify-content-center">
|
<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
|
<buttonBack
|
||||||
v-if="hasBackButton"
|
v-if="hasBackButton"
|
||||||
:backButtonAccessibleText="backButtonAccessibleText"
|
:backButtonAccessibleText="backButtonAccessibleText"
|
||||||
|
|
@ -32,6 +39,12 @@ export default {
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
h2 {
|
h2 {
|
||||||
color: $gray-550;
|
color: $gray-550;
|
||||||
|
|
||||||
|
button {
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.back-button-wrapper {
|
.back-button-wrapper {
|
||||||
margin-left: .25rem;
|
margin-left: .25rem;
|
||||||
|
|
|
||||||
|
|
@ -20,24 +20,4 @@ describe("back button", () => {
|
||||||
wrapper.unmount();
|
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
v-if="backButtonAction"
|
v-if="backButtonAction"
|
||||||
@click="handleClick($event)"
|
@click="backButtonAction"
|
||||||
class="back-button-wrapper d-flex p-0"
|
class="back-button-wrapper d-flex p-0"
|
||||||
:aria-label="backButtonAccessibleText"
|
:aria-label="backButtonAccessibleText"
|
||||||
>
|
>
|
||||||
|
|
@ -19,20 +19,13 @@ export default {
|
||||||
backButtonAccessibleText: {
|
backButtonAccessibleText: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
default: "",
|
||||||
},
|
},
|
||||||
backButtonAction: {
|
backButtonAction: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
required: true,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
handleClick: function () {
|
|
||||||
if (this.backButtonAction) {
|
|
||||||
this.backButtonAction();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue