Skip to content
Snippets Groups Projects
Verified Commit 7e593ad0 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Added year filter

parent 99a91c1e
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,12 @@ export function momentFormat (date, format) {
Vue.filter('moment', momentFormat)
export function year (date) {
return moment(date).year()
}
Vue.filter('year', year)
export function capitalize (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
......
import {truncate, markdown, ago, capitalize} from '@/filters'
import {truncate, markdown, ago, capitalize, year} from '@/filters'
describe('filters', () => {
describe('truncate', () => {
......@@ -32,6 +32,13 @@ describe('filters', () => {
expect(output).to.equal('a few seconds ago')
})
})
describe('year', () => {
it('works', () => {
const input = '2017-07-13'
let output = year(input)
expect(output).to.equal(2017)
})
})
describe('capitalize', () => {
it('works', () => {
const input = 'hello world'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment