/**
 * Gets the repositories of the user from Github
 */

/* eslint-disable no-constant-condition */

import { take, call, put, select } from 'redux-saga/effects';

import { LOAD_REPOS } from 'containers/App/constants';
import { reposLoaded, repoLoadingError } from 'containers/App/actions';

import request from 'utils/request';
import { selectUsername } from 'containers/HomePage/selectors';

// Bootstrap sagas
export default [
  getGithubData,
];

// Individual exports for testing
export function* getGithubData() {
  while (true) {
    yield take(LOAD_REPOS);
    const username = yield select(selectUsername());
    const requestURL = `https://api.github.com/users/${username}/repos?type=all&sort=updated`;

    // Use call from redux-saga for easier testing
    const repos = yield call(request, requestURL);

    // We return an object in a specific format, see utils/request.js for more information
    if (repos.err === undefined || repos.err === null) {
      yield put(reposLoaded(repos.data, username));
    } else {
      console.log(repos.err.response); // eslint-disable-line no-console
      yield put(repoLoadingError(repos.err));
    }
  }
}

@@ -518,27 +518,8 @@
 ) %7B%0A
-  while (true) %7B%0A  
   yi
@@ -540,18 +540,16 @@
 REPOS);%0A
-  
   const 
@@ -591,18 +591,16 @@
 ame());%0A
-  
   const 
@@ -685,18 +685,16 @@
 ated%60;%0A%0A
-  
   // Use
@@ -736,18 +736,16 @@
 sting%0A  
- 
- 
 const re
@@ -784,18 +784,16 @@
 tURL);%0A%0A
-  
   // We 
@@ -873,18 +873,16 @@
 rmation%0A
-  
   if (re
@@ -928,26 +928,24 @@
 null) %7B%0A    
-  
 yield put(re
@@ -980,18 +980,16 @@
 me));%0A  
- 
- 
 %7D else %7B
@@ -989,18 +989,16 @@
  else %7B%0A
-  
     cons
@@ -1064,18 +1064,16 @@
 ole%0A    
-  
 yield pu
@@ -1108,14 +1108,8 @@
 ));%0A
-    %7D%0A
   %7D%0A

Fix example saga