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)
|
Vue.filter('moment', momentFormat)
|
||||||
|
|
||||||
|
export function year (date) {
|
||||||
|
return moment(date).year()
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.filter('year', year)
|
||||||
|
|
||||||
export function capitalize (str) {
|
export function capitalize (str) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
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('filters', () => {
|
||||||
describe('truncate', () => {
|
describe('truncate', () => {
|
||||||
|
@ -32,6 +32,13 @@ describe('filters', () => {
|
||||||
expect(output).to.equal('a few seconds ago')
|
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', () => {
|
describe('capitalize', () => {
|
||||||
it('works', () => {
|
it('works', () => {
|
||||||
const input = 'hello world'
|
const input = 'hello world'
|
||||||
|
|
Loading…
Reference in New Issue