Added year filter
This commit is contained in:
parent
99a91c1e74
commit
7e593ad05b
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue