Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Fix/stats #332

Merged
merged 2 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Stats.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div :class="bem()" v-if="totalResults > 0">
<slot :totalResults="totalResults" :processingTime="processingTime" :query="query">
{{ totalResults }} results found in {{ processingTime }}ms
{{ totalResults.toLocaleString() }} results found in {{ processingTime.toLocaleString() }}ms
</slot>
</div>
</template>
Expand All @@ -20,7 +20,7 @@ export default {
return this.searchStore.query;
},
totalResults() {
return this.searchStore.totalResults.toLocaleString();
return this.searchStore.totalResults;
},
processingTime() {
return this.searchStore.processingTimeMS;
Expand Down
11 changes: 11 additions & 0 deletions src/components/__tests__/__snapshots__/stats.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Stats renders proper HTML 1`] = `

<div class="ais-stats">
10,000 results found in 1,000ms
</div>

`;

exports[`Stats should not be displayed if there are no results 1`] = `undefined`;
32 changes: 32 additions & 0 deletions src/components/__tests__/stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Vue from 'vue';
import Stats from '../Stats.vue';

const searchStore = {
query: 'search query',
totalResults: 10000,
processingTimeMS: 1000,
};

describe('Stats', () => {
test('renders proper HTML', () => {
const Component = Vue.extend(Stats);
const vm = new Component({
propsData: {
searchStore,
},
}).$mount();

expect(vm.$el.outerHTML).toMatchSnapshot();
});

test('should not be displayed if there are no results', () => {
const Component = Vue.extend(Stats);
const vm = new Component({
propsData: {
searchStore: Object.assign({}, searchStore, { totalResults: 0 }),
},
}).$mount();

expect(vm.$el.outerHTML).toMatchSnapshot();
});
});