Skip to content

Commit

Permalink
test: extend #legendFormatter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
setaman committed Apr 30, 2021
1 parent 4ba1fe6 commit 726125c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 5 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,9 @@
>
</ve-progress>
</div>
<ve-progress
half
line-position="center"
:progress="50"
:legend-formatter="
({ currentValue }) => `<span><b>${currentValue}</b></span> <span><b>${currentValue}</b></span> `
"
>
<ve-progress half line-position="center" :progress="50">
<template #default="{ counterTick }">
<span> Olechka {{ counterTick.currentValue }} </span>
<span> Olechka {{ counterTick.currentValue }} {{ logStuff(counterTick) }} </span>
</template>
</ve-progress>
</div>
Expand Down Expand Up @@ -163,6 +156,9 @@ export default {
},
},
methods: {
logStuff(stuff) {
console.log(stuff);
},
formattedPrice(value) {
return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(value);
},
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/container.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ describe("[ EllipseProgressContainer.vue ]", () => {
done();
}, 100);
});
it("isHTML returns false by default ", () => {
expect(factory({ legendFormatter: () => "Custom" }).vm.isHTML).to.be.false;
});
describe("#legendFormatter HTML return value", () => {
const customFormat = (value) => `<span class="my-custom-format">Formatted ${value}</span>`;
const formatter = ({ currentValue }) => customFormat(currentValue);
const counterWrapper = factory({ value: 50, legendFormatter: formatter, animation: "default 0 0" });

it("recognises HTML formatter return value ", (done) => {
setTimeout(() => {
expect(counterWrapper.vm.isHTML).to.be.true;
done();
}, 10);
it("recognises HTML formatter return value ", () => {
expect(counterWrapper.vm.isHTML).to.be.true;
});
it("renders the formatter returned HTML", () => {
expect(counterWrapper.find(".my-custom-format").exists()).to.be.true;
Expand Down

0 comments on commit 726125c

Please sign in to comment.