it('uses the set expires_at property', function () {
   token.token.expires_at = startOfYesterday();
   const expiredToken = oauth2.accessToken.create(token.token);
   expect(isValid(expiredToken.token.expires_at)).to.be.equal(true);
   expect(isEqual(expiredToken.token.expires_at, token.token.expires_at))
     .to.be.equal(true);
 });
 it('parses a set expires_at property', function () {
   const yesterday = startOfYesterday();
   token.token.expires_at = yesterday.toString();
   const expiredToken = oauth2.accessToken.create(token.token);
   expect(isValid(expiredToken.token.expires_at)).to.be.equal(true);
   expect(isEqual(expiredToken.token.expires_at, token.token.expires_at))
     .to.be.equal(true);
 });
Exemple #3
0
function toWeeks(days) {
    let weeks = [];
    let week = []; 
    let currentWeek = lastDayOfWeek(days[0]); 
    
    for (let nth = 0; nth < days.length; nth++) {
        if (isEqual(currentWeek, lastDayOfWeek(days[nth]))) {
            week.push(days[nth]); 
        } else {
            weeks.push(week); 
            week = [];
            week.push(days[nth]);
            currentWeek = lastDayOfWeek(days[nth])
        }
    }
    
    return weeks;
}
Exemple #4
0
// Day(Key, day, style, reminders)
function Weeks({dates, onClick, getReminders }) {
  // get the last day of the week from the first day in the list 
  let lastDayInWeek = lastDayOfWeek(dates[0]);
  
  // stores the day inside a week 
  let week = [];
  
  // stores the weeks
  let weeks = [];
    
  for (let nth = 0; nth <= dates.length; nth++) {
    // create day component 
    // create reminder component
    // store reminder component inside day component
    let dayComponent = (
      <Day key={dates[nth]} day={getDate(dates[nth]).toString()} style={nth === 0 ? _styleDay(getDay(dates[nth])) : {}}>
        <Reminders reminders={getReminders(dates[nth])} onClick={onClick}/>
      </Day>
    ); 
      
    if (isEqual(lastDayInWeek, lastDayOfWeek(dates[nth]))) {
      week.push(dayComponent);     
    } else {
      weeks.push(<div className="calendar__week" key={getISOWeek(dates[nth]) + "-" + getYear(dates[nth])}>{week}</div>); 
      // reset week
      week = []; 
      // add new day to the empty week
      week.push(dayComponent);
      
      lastDayInWeek = lastDayOfWeek(dates[nth]);
    }
      
  }
    
  return (
    <React.Fragment>
      {weeks}
    </React.Fragment>
  );
}