Hello I would like to do some testing of my pipe, I don't know really what to write in my spec.ts file anyone that could help me come up with something? Here is my pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'dateAdder'
})
export class DateAdderPipe implements PipeTransform {
transform(value: string | Date): string {
// Sets string date
let oldDate = new Date(value);
// add one extra hour to the existing date
oldDate.setHours(oldDate.getHours() + 1);
// Sets and takes in the format, takes another argument and makes use of a formats to shape the "convertation". Makes the time go 1 hour ahead
let onlyDate = (oldDate.getFullYear()+'-'+ ('0' + (oldDate.getMonth() + 1)).slice(-2) + '-' + ('0' + oldDate.getDate()).slice(-2));
// formats the time an hour ahead
// returns the data
return onlyDate
}
}
Aucun commentaire:
Enregistrer un commentaire