Added year filter

This commit is contained in:
Eliot Berriot 2018-03-07 23:02:33 +01:00
parent 99a91c1e74
commit 7e593ad05b
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 14 additions and 1 deletions

View File

@ -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)
}

View File

@ -1,4 +1,4 @@
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'