Skip to content

Commit

Permalink
Add helpers to adjust profile view, add content based on user data, t…
Browse files Browse the repository at this point in the history
…ests added

relates #14 #44
  • Loading branch information
helenzhou6 committed May 12, 2018
1 parent cf19d02 commit 79aebeb
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 41 deletions.
4 changes: 4 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ require('dotenv').config();
// import route controllers
const controllers = require('./controllers/index');

// import helpers
const helpers = require('./views/helpers/index');

// github oauth 2.0 passport setup
require('./oauth');

Expand All @@ -26,6 +29,7 @@ app.engine(
layoutsDir: path.join(__dirname, 'views', 'layouts'),
partialsDir: path.join(__dirname, 'views', 'partials'),
defaultLayout: 'main',
helpers,
}),
);

Expand Down
25 changes: 23 additions & 2 deletions src/test/unit.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const test = require('tape');

const { updateUserSession } = require('../controllers/middleware');
const { jobStatusText, jobPrefIsPublic } = require('../views/helpers/index');

test('Test if tape is working', (t) => {
t.ok(true, 'tape is working');
t.end();
});

// UPDATE USER SESSION
// MIDDLEWARE -- Update User Session Function
test('Test updateUserSession - registeredProfile: true', (t) => {
const originalRequest = {
user: {
Expand Down Expand Up @@ -66,4 +67,24 @@ test('Test updateUserSession - registeredProfile: false', (t) => {
t.deepEquals(actual, expected, 'returns expected result (deepequals)');
t.deepEquals(request, originalRequest, 'not mutated original request object');
t.end();
});
});

// HANDLEBARS HELPERS

// jobStatusText function tests

test('Test jobStatusText', (t) => {
t.equals(jobStatusText('red'), 'Not Looking', 'jobStatusText(red) returns correct result');
t.equals(jobStatusText('orange'), 'Open to opportunities', 'jobStatusText(orange) returns correct result');
t.equals(jobStatusText('green'), 'Currently Looking', 'jobStatusText(green) returns correct result');
t.end();
});


// jobPrefIsPublic function tests

test('Test jobPrefIsPublic', (t) => {
t.equals(jobPrefIsPublic('private'), false, 'jobPrefIsPrivate(\'private\') returns correct result');
t.equals(jobPrefIsPublic('public'), true, 'jobPrefIsPrivate(\'public\') returns correct result');
t.end();
});
4 changes: 4 additions & 0 deletions src/views/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
jobStatusText: require('./jobStatusText'),
jobPrefIsPublic: require('./jobPrefIsPublic'),
};
9 changes: 9 additions & 0 deletions src/views/helpers/jobPrefIsPublic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = (jobViewPref) => {
switch (jobViewPref) {
case 'public':
return true;
break;
default:
return false;
}
}
12 changes: 12 additions & 0 deletions src/views/helpers/jobStatusText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = (jobStatus) => {
switch (jobStatus) {
case 'green':
return 'Currently Looking';
break;
case 'orange':
return 'Open to opportunities';
break;
default:
return 'Not Looking';
}
}
10 changes: 5 additions & 5 deletions src/views/partials/profile_jobDetails.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<form method="POST" action="/saveDetails" novalidate>
<span>* Required</span>
<label for="job_view_pref">Preferred
<input type="radio" id="job_pref_public" name="job_view_pref" value="public" checked>
<input type="radio" id="job_pref_public" name="job_view_pref" value="public">
<label for="job_pref_public">Public</label>

<input type="radio" id="job_pref_private" name="job_view_pref" value="private">
<input type="radio" id="job_pref_private" name="job_view_pref" value="private" checked>
<label for="job_pref_private">Private</label>
</label>
<label for="job_search_status">Job Search Status *
Expand All @@ -17,9 +17,9 @@
</label>
<label for="years_experience">Years experience
<select id="years_experience" name="years_experience">
<option value="{'min_years_exp': 0, 'max_years_exp': 2}">Less than two years</option>
<option value="{'min_years_exp': 2, 'max_years_exp': 5}">Two to five years</option>
<option value="{'min_years_exp': 5, 'max_years_exp': 100}">More than five years</option>
<option value="{min_years_exp: 0, max_years_exp: 2}">Less than two years</option>
<option value="{min_years_exp: 2, max_years_exp: 5}">Two to five years</option>
<option value="{min_years_exp: 5, max_years_exp: 100}">More than five years</option>
</select>
</label>
<label for="github_cv_url">GitHub CV URL
Expand Down
74 changes: 40 additions & 34 deletions src/views/partials/profile_viewMode.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,65 @@
<div>
{{#if user.github_avatar_url}}
<img src="{{user.github_avatar_url}}" alt="my profile picture" class="profile-avatar"> {{/if}}
<p>Name Name</p>
<p>FAC13</p>


<p>{{user.full_name}}</p>
<p>{{#if user.fac_code_id}}{{user.fac_code_id}}{{/if}}</p>
</div>
{{!-- links --}}
<ul>
{{#if user.github_handle}}
<li>
<a>
<i class="icon icon-github"></i>github</a>
<a href="https://github.com/{{user.github_handle}}" target="_blank">
<i class="icon icon-github">github icon</i>{{user.github_handle}}</a>
</li>
<li<a>
<i class="icon icon-linkedin"></i>linkedin</a>
</li>
<li>
<a>
<i class="icon icon-twitter"></i>twitter</a>
</li>

{{/if}} {{#if user.linkedin_url}}
<li>
<a href="https://github.com/{{user.linkedin_url}}" target="_blank">
<i class="icon icon-linkedin">linkedin icon</i>{{user.linkedin_url}}</a>
</li>
{{/if}} {{#if user.linkedin_url}}
<li>
<a href="https://github.com/{{user.twitter_handle}}" target="_blank">
<i class="icon icon-twitter">Twitter icon</i>{{user.twitter_handle}}</a>
</li>
{{/if}}
</ul>

{{!-- tech stack --}}
<ul>
<li>Javascript</li>
<li>Node.js</li>
<li>CSS3</li>
<li>HTML5</li>
</ul>
<button>Add</button>
{{!-- contact --}}
<a>
<i class="icon icon-gitter"></i>Contact me on Gitter</a>

{{#if user.github_handle}}
<a href="https://gitter.im/{{user.github_handle}}" target="_blank">
<i class="icon icon-gitter">gitter icon</i>Contact me on Gitter</a>
{{/if}}
</section>

<section>

<header>
<h1>
Job Search
</h1>
<i class="icon icon-private">lock</i>
{{#if user.job_view_pref}} {{#if jobPrefIsPublic user.job_view_pref}}
<i class="icon icon-visible">eye icon</i>
{{/if}} {{else}}
<i class="icon icon-private">lock</i>{{/if}}
</header>
<button>Edit Me</button>
<h2>Status</h2>
<p>Looking for work</p>

<h2>Career Interests</h2>
<li>
<ul>Permanent Dev</ul>
<ul>Freelance</ul>
</li>

{{#if user.job_search_status}}
<i class="icon icon-jobstatus-{{user.job_search_status}}">{{user.job_search_status}} circle</i>
<p>{{jobStatusText user.job_search_status}}</p>
{{else}}
<i class="icon icon-jobstatus-red">red circle</i>
<p>Not Looking</p>
{{/if}} {{#if user.max_years_exp}}
<p>Has {{user.max_years_exp}} years experience</p>{{/if}} {{#if user.github_cv_url}}
<a href="{{user.github_cv_url}}" target="_blank">
<i class="icon icon-github">github icon</i>Github CV
</a>
{{/if}} {{#if user.cv_url}}
<a href="{{user.cv_url}}" target="_blank">
<i class="icon icon-cv">cv icon</i>PDF of CV
</a>
{{/if}}
</section>
</article>

Expand Down

0 comments on commit 79aebeb

Please sign in to comment.