{"@attributes":{"version":"2.0"},"channel":{"title":"DEV Community: HawiCaesar","description":"The latest articles on DEV Community by HawiCaesar (@hawicaesar).","link":"https:\/\/dev.to\/hawicaesar","image":{"url":"https:\/\/media2.dev.to\/dynamic\/image\/width=90,height=90,fit=cover,gravity=auto,format=auto\/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F16351%2F95bfff1e-e7b0-4812-b3e6-272b941cb150.jpeg","title":"DEV Community: HawiCaesar","link":"https:\/\/dev.to\/hawicaesar"},"language":"en","item":[{"title":"On having a remote design sprint","pubDate":"Thu, 20 Sep 2018 06:35:08 +0000","link":"https:\/\/dev.to\/hawicaesar\/on-having-a-remote-design-sprint-kak","guid":"https:\/\/dev.to\/hawicaesar\/on-having-a-remote-design-sprint-kak","description":"<p>Design sprints are a great way to allow a team a shortcut to learning without building and launching an application. Critical business questions are also answered through design during design sprint. I recently concluded a design sprint with our lead engineer and the situation was quite a learning experience. I will share what happened during the sprint and then share my reflections.<\/p>\n\n<p>The company I work for is currently based in the US specifically in Kansas City. They are a small startup of about 10 people. We had our first kick off on Monday. During this session, we had various introductions from both me and the lead engineer. In addition to this, we added something interesting about ourselves. Keep in mind the lead engineer, Ryan, is also the sole developer on the team. We then had a deep dive into product offered by the company and the problem it was trying to solve. I had a couple of questions that I asked him that allowed me to be on the same page for what we are solving for. It was a lot to take in for day 1.<\/p>\n\n<p>On day 2, we had another session where we discussed what we were going to build and how it was related to what he had built before. I had a few solutions on how to approach the idea. But then Ryan threw a few bits and pieces of information which had my ideas irrelevant. This led me to have a brainstorm session of understanding the problem. Why this approach? The team did not consist of a designer and Ryan had no working solution of what the system should look like but he knew what it should solve for. This immediately led me to think of a design sprint. I informed him of the same and told him how to best approach the situation to solve for the problem. I gathered a few resources relating to having a design sprint. The best resource I felt was from this link (<a href=\"http:\/\/www.gv.com\/sprint\/\">http:\/\/www.gv.com\/sprint\/<\/a>)<\/p>\n\n<p>Day 3 came in and we had already discussed much of the problem. The most bit was to follow the timeline given in the link. This is where we discussed solutions of what we were going to solve for. We used stickies.io to portray ideas for the solutions we had. What was difficult about this day was that Ryan added a few more pieces of information that I had not considered yet. We had to go back to the drawing board and discuss what the problem was. The problem was that we had to cover a wide range of issues he had when developing the system. After this session, we agreed that we were on the same page with the array of issues to be considered before solving the problem. We also allowed ourselves to break off and sketch up our own solutions.<\/p>\n\n<p>On day 4, we discussed the mockups we had but, Ryan did not have time to sketch the mockups with the tools we had so he drew them on paper. I went through the mockups I sketched and explained what I had in mind when I had drawn them up. He gave me feedback about the different sketches. This was also a hard day as Ryan quickly realized he had not communicated all the issues well. We discussed them again and we moved to a much clearer approach of how to solve the array of issues. There were ideas he wanted to address but he realized that an MVP was more important and we discussed some ideas we could add for later.<\/p>\n\n<p>On day 5, I had re-sketched the mockups based on the previous day\u2019s discussion. This day\u2019s discussion was much more fruitful but some mockups were still lacking on some issues that were not fully addressed. I suggested that we can iterate on the mockups that were not fully addressed. In addition to this, I also suggested that since there are some that are ready, we can go ahead and add task stories for them to be built rather than waiting for all the mockups. He agreed to this and the idea to iterate on the mockups that were lacking on the concept.<\/p>\n\n<p>Some Key takeaways<\/p>\n\n<ul>\n<li>Get to understand the whole problem first. This allows you to focus your solutions on the whole problem and probably have a combinatorial effort when discussing each other\u2019s mockups<\/li>\n<li>Allow yourself to be in the mindset of the design sprint. Make sure you all have time to discuss the problem, get solutions, agree on the best solution and move forward.<\/li>\n<li>Choose your online tools wisely. Ryan uses a different Operating System from mine. Balsamiq cloud is good for quick mockups(wireframes), stickies.io for quickly getting ideas across, having reflections, choosing what works well and what does not work well.<\/li>\n<\/ul>\n\n<p>I am curious to know, how have you approached a remote design sprint? Did you have a designer do all the work or did you involve them?<\/p>\n\n","category":"design"},{"title":"No, I don't know what closures are...yet","pubDate":"Fri, 15 Dec 2017 12:02:32 +0000","link":"https:\/\/dev.to\/hawicaesar\/no-i-dont-know-what-closures-areyet-568","guid":"https:\/\/dev.to\/hawicaesar\/no-i-dont-know-what-closures-areyet-568","description":"<p>I want share an interesting lesson I learned on closures. The journey to this lesson all started when I commented on a PR and the author of the PR said he added the extra <code>()<\/code> to a function <code>this.handleToggle<\/code> as the function was a closure. This scratched my brain for a while. I mean, I knew what closures were or at least an idea of it. I decided to write it down in my note book as I would come back to it later. I then remembered a friend of mine recommended I start <a href=\"https:\/\/github.com\/getify\/You-Dont-Know-JS\">here<\/a> when looking into js. I quickly went to this github repo and looked for the chapter on closures. The text book definition I thought I would find was not there. However, Kyle Simpson used examples and explained \"to me like I am 5\" I grasped the concept.<\/p>\n\n<p>An interesting code snippet that baffled me though was this<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kd\">var<\/span> <span class=\"nx\">i<\/span><span class=\"o\">=<\/span><span class=\"mi\">1<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">5<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nx\">setTimeout<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n        <span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span> <span class=\"nx\">i<\/span> <span class=\"p\">);<\/span>\n    <span class=\"p\">},<\/span> <span class=\"mi\">100<\/span> <span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>which you might think prints out<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight console\"><code><span class=\"go\">1\n2\n3\n4\n5\n<\/span><\/code><\/pre>\n\n<\/div>\n\n\n\n<p>This actually prints out 6 five times on the console. Try it out. Weird ? Not really. I simply wanted to see the above output. I played around with it and still got 6 five times on the console. Why did not continue reading is because I thought I knew that what I read at first was enough to try out the loop example without reading further. I even added a 0 to have to timeout not have any delay. No luck! I continued reading Kyle Simpsons book and found out he had a solution to this. It turns out what I (and many developers may have done) was trying to <\/p>\n\n<p><code>imply that each iteration of the loop \"captures\" its own copy of i, at the time of the iteration. But, the way scope works, all 5 of those functions, though they are defined separately in each loop iteration, all are closed over the same shared global scope, which has, in fact, only one i in it.<br>\n<\/code><\/p>\n\n<p>Kyle Simpson provided a solution by either using an IIFE or the ES6 sibling of <code>var<\/code>, <code>let<\/code>.<\/p>\n\n<p>using an IIFE<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kd\">var<\/span> <span class=\"nx\">i<\/span><span class=\"o\">=<\/span><span class=\"mi\">1<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">5<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"p\">(<\/span><span class=\"kd\">function<\/span><span class=\"p\">(<\/span><span class=\"nx\">j<\/span><span class=\"p\">){<\/span>\n        <span class=\"nx\">setTimeout<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n            <span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span> <span class=\"nx\">j<\/span> <span class=\"p\">);<\/span>\n        <span class=\"p\">},<\/span> <span class=\"nx\">j<\/span> <span class=\"p\">);<\/span>\n    <span class=\"p\">})(<\/span> <span class=\"nx\">i<\/span> <span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>using <code>let<\/code><br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kd\">let<\/span> <span class=\"nx\">i<\/span><span class=\"o\">=<\/span><span class=\"mi\">1<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">5<\/span><span class=\"p\">;<\/span> <span class=\"nx\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nx\">setTimeout<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n        <span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span> <span class=\"nx\">i<\/span> <span class=\"p\">);<\/span>\n    <span class=\"p\">},<\/span> <span class=\"mi\">100<\/span> <span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>I approached a senior dev and he explained the same issue only that emphasized how dangerous <code>var<\/code> can be. <code>var<\/code> was hoisting the value of i and therefore the the value of 6 is always printed. What I forgot ask is this. For the first code snippet, is the whole loop running such that var does get to 6 and then run all the <code>setTimeouts<\/code> later and then display 6 as the value of i ?<\/p>\n\n<p>Finally what closures are:<\/p>\n\n<p>Those who like to hook onto a definition, I did a little digging and a post by Eric Elliot who explains it well <a href=\"https:\/\/medium.com\/javascript-scene\/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36\">here<\/a>.<\/p>\n\n<p>Eric Elliot<br>\n<code><br>\nA closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function\u2019s scope from an inner function. <br>\n<\/code><\/p>\n\n<p>I got access to one of Kyle Simpson videos and he explains as follows<\/p>\n\n<p><code>A closure is when a function 'remembers' its lexical scope even when that function is executed well outside it the lexical scope.<\/code><\/p>\n\n<p>I hope they make sense and I encourage you to read up more on <br>\n<a href=\"https:\/\/github.com\/getify\/You-Dont-Know-JS\/blob\/master\/scope%20%26%20closures\/ch5.md\">\"You Don't Know Js, Closures\"<\/a><br>\n<a href=\"https:\/\/medium.com\/javascript-scene\/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36\">Master the JavaScript Interview: What is a Closure?<\/a><\/p>\n\n","category":"javascript"},{"title":"Moxios or Nock To Mock","pubDate":"Mon, 11 Dec 2017 17:06:11 +0000","link":"https:\/\/dev.to\/hawicaesar\/moxios-or-nock-to-mock-che","guid":"https:\/\/dev.to\/hawicaesar\/moxios-or-nock-to-mock-che","description":"<p>I recently came across an interesting hurdle when testing async action creators. I was testing whether a delete action creator is called when the thunk runs. The code below shows a thunk and an action creator respectively.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"cm\">\/**\n * Delete user contribution thunk\n *\n * @param {string} contribution for the contribution to be deleted\n * @return {(dispatch) =&gt; Promise&lt;TResult2|TResult1}\n *\/<\/span>\n<span class=\"k\">export<\/span> <span class=\"kd\">const<\/span> <span class=\"nx\">deleteUserContribution<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"nx\">contribution<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n  <span class=\"k\">return<\/span> <span class=\"p\">((<\/span><span class=\"nx\">dispatch<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n    <span class=\"k\">return<\/span> <span class=\"nx\">http<\/span><span class=\"p\">.<\/span><span class=\"k\">delete<\/span><span class=\"p\">(<\/span><span class=\"s2\">`<\/span><span class=\"p\">${<\/span><span class=\"nx\">config<\/span><span class=\"p\">.<\/span><span class=\"nx\">API_BASE_URL<\/span><span class=\"p\">}<\/span><span class=\"s2\">\/contributions\/<\/span><span class=\"p\">${<\/span><span class=\"nx\">contribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span><span class=\"p\">}<\/span><span class=\"s2\">`<\/span><span class=\"p\">)<\/span>\n      <span class=\"p\">.<\/span><span class=\"nx\">then<\/span><span class=\"p\">((<\/span><span class=\"nx\">response<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n        <span class=\"nx\">dispatch<\/span><span class=\"p\">(<\/span><span class=\"nx\">deleteUserContributionSuccess<\/span><span class=\"p\">(<\/span><span class=\"nx\">contribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span><span class=\"p\">));<\/span>\n      <span class=\"p\">});<\/span>\n  <span class=\"p\">});<\/span>\n<span class=\"p\">};<\/span>\n\n<span class=\"cm\">\/**\n * Delete user contribution action creator\n *\n * @param {string} contributionId for the contribution to be deleted\n * @return {IDeleteUserContributionSuccess}\n *\/<\/span>\n<span class=\"k\">export<\/span> <span class=\"kd\">const<\/span> <span class=\"nx\">deleteUserContributionSuccess<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"nx\">contributionId<\/span><span class=\"p\">):<\/span> <span class=\"nx\">IDeleteUserContributionSuccess<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n  <span class=\"k\">return<\/span> <span class=\"p\">{<\/span> <span class=\"na\">type<\/span><span class=\"p\">:<\/span> <span class=\"nx\">DELETE_USER_CONTRIBUTION_SUCCESS<\/span><span class=\"p\">,<\/span> <span class=\"nx\">contributionId<\/span> <span class=\"p\">};<\/span>\n<span class=\"p\">};<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>I used nock at first to mock requests.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"c1\">\/\/ third party libraries<\/span>\n<span class=\"k\">import<\/span> <span class=\"nx\">configureMockStore<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">redux-mock-store<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">import<\/span> <span class=\"nx\">thunk<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">redux-thunk<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">expect<\/span> <span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">chai<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">import<\/span> <span class=\"o\">*<\/span> <span class=\"k\">as<\/span> <span class=\"nx\">moxios<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">moxios<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n\n<span class=\"c1\">\/\/ fixtures<\/span>\n<span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">sampleContribution<\/span> <span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">..\/fixtures\/contribution<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n\n<span class=\"c1\">\/\/ actions<\/span>\n<span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">deleteUserContribution<\/span> <span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">.\/ContributionActions<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n\n<span class=\"c1\">\/\/ types<\/span>\n<span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">DELETE_USER_CONTRIBUTION_SUCCESS<\/span> <span class=\"p\">}<\/span>  <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">..\/types<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\n\n<span class=\"kd\">const<\/span> <span class=\"nx\">middleware<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span><span class=\"nx\">thunk<\/span><span class=\"p\">];<\/span>\n<span class=\"kd\">const<\/span> <span class=\"nx\">mockStore<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">configureMockStore<\/span><span class=\"p\">(<\/span><span class=\"nx\">middleware<\/span><span class=\"p\">);<\/span>\n<span class=\"kd\">let<\/span> <span class=\"nx\">store<\/span><span class=\"p\">;<\/span>\n<span class=\"kd\">let<\/span> <span class=\"nx\">url<\/span><span class=\"p\">;<\/span>\n\n<span class=\"nx\">describe<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">Async Contribution Actions<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"p\">()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n <span class=\"nx\">it<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">creates DELETE_USER_CONTRIBUTION_SUCCESS when deleting a contribution<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"p\">()<\/span> <span class=\"p\">{<\/span>\n     <span class=\"nx\">nock<\/span><span class=\"p\">(<\/span><span class=\"s2\">`<\/span><span class=\"p\">${<\/span><span class=\"nx\">config<\/span><span class=\"p\">.<\/span><span class=\"nx\">API_BASE_URL<\/span><span class=\"p\">}<\/span><span class=\"s2\">`<\/span><span class=\"p\">)<\/span>\n      <span class=\"p\">.<\/span><span class=\"k\">delete<\/span><span class=\"p\">(<\/span><span class=\"s2\">`\/contributions\/<\/span><span class=\"p\">${<\/span><span class=\"nx\">contribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span><span class=\"p\">}<\/span><span class=\"s2\">`<\/span><span class=\"p\">)<\/span>\n      <span class=\"p\">.<\/span><span class=\"nx\">reply<\/span><span class=\"p\">(<\/span><span class=\"mi\">204<\/span><span class=\"p\">,<\/span><span class=\"dl\">''<\/span><span class=\"p\">)<\/span>\n\n     <span class=\"kd\">const<\/span> <span class=\"nx\">expectedActions<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\n     <span class=\"p\">{<\/span> <span class=\"na\">type<\/span><span class=\"p\">:<\/span> <span class=\"nx\">DELETE_USER_CONTRIBUTION_SUCCESS<\/span><span class=\"p\">,<\/span> <span class=\"na\">contributionId<\/span><span class=\"p\">:<\/span> <span class=\"nx\">sampleContribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span> <span class=\"p\">},<\/span>\n<span class=\"p\">];<\/span>\n\n    <span class=\"k\">return<\/span> <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">dispatch<\/span><span class=\"p\">(<\/span><span class=\"nx\">deleteUserContribution<\/span><span class=\"p\">(<\/span><span class=\"nx\">sampleContribution<\/span><span class=\"p\">)).<\/span><span class=\"nx\">then<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n      <span class=\"kd\">const<\/span> <span class=\"nx\">actualActions<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">getActions<\/span><span class=\"p\">();<\/span>\n      <span class=\"nx\">expect<\/span><span class=\"p\">(<\/span><span class=\"nx\">actualActions<\/span><span class=\"p\">).<\/span><span class=\"nx\">to<\/span><span class=\"p\">.<\/span><span class=\"nx\">eql<\/span><span class=\"p\">(<\/span><span class=\"nx\">expectedActions<\/span><span class=\"p\">);<\/span>\n    <span class=\"p\">});<\/span>\n  <span class=\"p\">});<\/span>\n<span class=\"p\">})<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>I ran the test and it passed. I then proceeded to make a PR for the delete feature and requested a review from my team. A team member who was also writing async action tests slacked me and pointed out that <em>package.json<\/em> already has Moxios and that I could leverage on that rather than install a new mock library. I decided to try it out. I followed the Moxios documentation and implemented it. However I got error below.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight console\"><code><span class=\"go\"> 1) Async Contribution Actions\n       creates DELETE_USER_CONTRIBUTION_SUCCESS when deleting a contribution:\n<\/span><span class=\"gp\">     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure \"done()\" is called;<\/span><span class=\"w\"> <\/span><span class=\"k\">if <\/span>returning a Promise, ensure it resolves.\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>I added the <em>done()<\/em> just after expect but the above error showed up.<br>\nI decided to slack the team member who encouraged me to use Moxios and before I even asked anything he had already sent me a message. The message detailed that he had pulled my branch and broke my test by changing the expect to be something like so<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"k\">return<\/span> <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">dispatch<\/span><span class=\"p\">(<\/span><span class=\"nx\">deleteUserContribution<\/span><span class=\"p\">(<\/span><span class=\"nx\">sampleContribution<\/span><span class=\"p\">)).<\/span><span class=\"nx\">then<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n      <span class=\"kd\">const<\/span> <span class=\"nx\">actualActions<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">getActions<\/span><span class=\"p\">();<\/span>\n      <span class=\"nx\">expect<\/span><span class=\"p\">(<\/span><span class=\"nx\">actualActions<\/span><span class=\"p\">).<\/span><span class=\"nx\">to<\/span><span class=\"p\">.<\/span><span class=\"nx\">eql<\/span><span class=\"p\">(<\/span><span class=\"mi\">1<\/span><span class=\"p\">);<\/span>\n    <span class=\"p\">});<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>and he told me the test was still passing. He also added that he had the same issue where nock seemed to not perform its work correctly therefore moved to Moxios. I was skeptical at first but I decided to investigate the matter. Lo and behold I found that nock was just resolving the promise and not returning the data I had told it to return. The only bit that still has me baffled was why the expect was still working. I implemented the test using Moxios and it worked as follows. The imports and middleware remained the same.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"nx\">describe<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">Async Contribution Actions<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"p\">()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n  <span class=\"nx\">beforeEach<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nx\">moxios<\/span><span class=\"p\">.<\/span><span class=\"nx\">install<\/span><span class=\"p\">();<\/span>\n    <span class=\"nx\">store<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">mockStore<\/span><span class=\"p\">({});<\/span>\n    <span class=\"nx\">url<\/span> <span class=\"o\">=<\/span> <span class=\"s2\">`<\/span><span class=\"p\">${<\/span><span class=\"nx\">config<\/span><span class=\"p\">.<\/span><span class=\"nx\">API_BASE_URL<\/span><span class=\"p\">}<\/span><span class=\"s2\">`<\/span><span class=\"p\">;<\/span>\n  <span class=\"p\">});<\/span>\n  <span class=\"nx\">afterEach<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nx\">moxios<\/span><span class=\"p\">.<\/span><span class=\"nx\">uninstall<\/span><span class=\"p\">();<\/span>\n  <span class=\"p\">});<\/span>\n\n  <span class=\"nx\">it<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">creates DELETE_USER_CONTRIBUTION_SUCCESS when deleting a contribution<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"nx\">done<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nx\">moxios<\/span><span class=\"p\">.<\/span><span class=\"nx\">stubRequest<\/span><span class=\"p\">(<\/span><span class=\"s2\">`<\/span><span class=\"p\">${<\/span><span class=\"nx\">url<\/span><span class=\"p\">}<\/span><span class=\"s2\">\/<\/span><span class=\"p\">${<\/span><span class=\"nx\">sampleContribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span><span class=\"p\">}<\/span><span class=\"s2\">`<\/span><span class=\"p\">,<\/span> <span class=\"p\">{<\/span>\n      <span class=\"na\">status<\/span><span class=\"p\">:<\/span> <span class=\"mi\">204<\/span><span class=\"p\">,<\/span>\n      <span class=\"na\">response<\/span><span class=\"p\">:<\/span> <span class=\"p\">{<\/span> <span class=\"na\">data<\/span><span class=\"p\">:<\/span> <span class=\"dl\">''<\/span> <span class=\"p\">},<\/span>\n    <span class=\"p\">});<\/span>\n\n    <span class=\"kd\">const<\/span> <span class=\"nx\">expectedActions<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span>\n      <span class=\"p\">{<\/span> <span class=\"na\">type<\/span><span class=\"p\">:<\/span> <span class=\"nx\">DELETE_USER_CONTRIBUTION_SUCCESS<\/span><span class=\"p\">,<\/span> <span class=\"na\">contributionId<\/span><span class=\"p\">:<\/span> <span class=\"nx\">sampleContribution<\/span><span class=\"p\">.<\/span><span class=\"nx\">id<\/span> <span class=\"p\">},<\/span>\n    <span class=\"p\">];<\/span>\n\n    <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">dispatch<\/span><span class=\"p\">(<\/span><span class=\"nx\">deleteUserContribution<\/span><span class=\"p\">(<\/span><span class=\"nx\">sampleContribution<\/span><span class=\"p\">)).<\/span><span class=\"nx\">then<\/span><span class=\"p\">(()<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n      <span class=\"kd\">const<\/span> <span class=\"nx\">actualActions<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">store<\/span><span class=\"p\">.<\/span><span class=\"nx\">getActions<\/span><span class=\"p\">();<\/span>\n      <span class=\"nx\">expect<\/span><span class=\"p\">(<\/span><span class=\"nx\">actualActions<\/span><span class=\"p\">).<\/span><span class=\"nx\">to<\/span><span class=\"p\">.<\/span><span class=\"nx\">eql<\/span><span class=\"p\">(<\/span><span class=\"nx\">expectedActions<\/span><span class=\"p\">);<\/span>\n      <span class=\"nx\">done<\/span><span class=\"p\">();<\/span>\n    <span class=\"p\">});<\/span>\n  <span class=\"p\">});<\/span>\n<span class=\"p\">});<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>I tried to break the test by adding a false actual value and it failed meaning  Moxios did a better job. I know the redux documentation uses fetch-mock but I suspect it was using nock before. <\/p>\n\n<p>The question I probably have now for you is what do you use to test async action creators ?<\/p>\n\n","category":["redux","testing"]},{"title":"My Squash vs That Squash","pubDate":"Thu, 12 Oct 2017 15:02:28 +0000","link":"https:\/\/dev.to\/hawicaesar\/my-squash-vs-that-squash-c26","guid":"https:\/\/dev.to\/hawicaesar\/my-squash-vs-that-squash-c26","description":"<p>Recently I moved up to higher stakes in my training to be a good junior developer. I was placed in a team that values conventions set and would comment and mark pull requests as critical (this meaning it has to be sorted immediately). One unwritten rule that is not found on our Wiki is squashing commits. Its funny though because the team lead mentioned that our commits should not pass 5 commits. A peer developer, JK, commented on my pull request and told me that I had violated the 3 <br>\ncommit limit. I therefore went to our old friend Google. After opening and closing several Stack Overflow tabs, scanning through the git help pages I was ready to try out something. I decide to play around with a project I had made before. I did not want to screw up in any way the project, branches and commits I had already.(Just being safe, Junior dev fears)<\/p>\n\n<p>I changed directory to a bucketlist app I had and then did a <code>git log<\/code> to see the last few commits I had. I then typed the following<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code># Reset the current branch to the commit just before the last 2:\ngit reset --hard HEAD~2\n\n# HEAD@{1} is where the branch was just before the previous command\n# This command sets the state of the index to be as it would just\n# after a merge from that commit:\ngit merge --squash HEAD@{1}\n\n# Now commit those squashed changes. The commit message will be helpfully\n# pre-populated with the commit messages of all the squashed commits:\ngit commit\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>This worked well for me.<\/p>\n\n<p>Another friend of mine, BT, who joined later, was tasked with configuring continuous deployment on our project, wanted to open a pull request. I was standing next to him as he explained the nightmare he had but managed to get things running. JK came from a meeting and sat next to BT and asked if he had any issues with making a pull request. BT mentioned he did not know how to squash. JK said its simple and opening his laptop JK typed the command below on this laptop. I decide to lay back as I was still new.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>git reset --soft HEAD~3\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>He then explained that the number represented the number of commits you want to squash. In the above case 3 represents the last 3 commits you want to squash.<\/p>\n\n<p>I was curious and I engaged JK about the above command and he explained his reasons.<\/p>\n\n<p>1) My question is which command is easier? <br>\n2) Or is this the wrong question to ask? <br>\n3) Are these commands dependent on the project<\/p>\n\n<p>I liked the command JK used despite having the satisfaction of finding a different answer to the same problem.<\/p>\n\n<p>What do you use when squashing commits?<\/p>\n\n<p>Thanks to Mark LongAir's <a href=\"https:\/\/stackoverflow.com\/a\/5190323\">answer on Stack Overflow<\/a><\/p>\n\n","category":"git"},{"title":"The Marvelous Misadventures Of My Career: Ep.1: Ghost Software Development","pubDate":"Wed, 16 Aug 2017 19:17:25 +0000","link":"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-ep1-ghost-software-development","guid":"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-ep1-ghost-software-development","description":"<p>There reached a point in my career when I was at work but I had no work. Literally. I was a mirage; a ghost. The company I was in had no clue on what to do with our R&amp;D department. This really frustrated us <strong>ALOT<\/strong>. Why? Because we approached them several times asking if we could be integrated with the core development team. We approached them asking how else we can help. To shed more light on this, I will take you back to the beginning when I joined the company. <\/p>\n\n<p>The first job I had was pretty good. However, they changed the structure and it did not favour my career path. A friend of mine linked me to an e-commerce company. I went for an interview and was hired as a software developer immediately. I was shocked. I did have some concern but I thought hey, here is an offer take it now! This was in November 2015. Things looked good and promising. A remote team handling the core platform and we the local team handling UI\/UX for the local market before being integrated into the company. We mostly built simple intuitive landing pages with products and categories which greatly improved the SEO of the platform. This went on for 3 months with promise of higher pay. I was in a team of 4 people in our R&amp;D department. Our R&amp;D manager, 1 designer and 2 backend developers. Though the other backend developer left, so 3 in a team. The e-commerce company was foreign and senior management was from a non-English speaking country. <\/p>\n\n<p>Right off the bat <em>Communication<\/em> became a huge barrier with some of the senior management. Simple words sounded so different; mispronounced words confused us entirely. But at least they knew some English. The remote development team knew nothing. We had to translate everything with our IT director. Our IT director in turn had a hard problem understanding the English we spoke. We really had to break down our own English for them to understand. It was difficult and very annoying. Explaining something as simple as why I should not use cookies in the browser or why we need an SSL certificate was like explaining to a 5 year old who already knew what you wanted to say but did not know how to say it. But I took it positively and we managed to fine-tune how to communicate with them. <\/p>\n\n<p>3 months came and we intended to ask about our rise in pay as we delivered most of the time and some of the management praised our work. We faced a back and forth of \u201clets meet tomorrow\u201d. Our R&amp;D manager went personally to a senior manager and asked. Excuses left right and center but ultimately nothing. We were also promised that we would integrate with the remote core development team. The most interesting response we got was from the global R&amp;D Director with some decent English. I will use full english to make it easier on you.<\/p>\n\n<p><strong>R&amp;D manager<\/strong>: <em>We have not been doing any programming. What are the plans for the local team? You told us we will integrate with the remote team?<\/em><\/p>\n\n<p><strong>Global R&amp;D Director<\/strong>: <em>Ahhh we had not thought that far...<\/em><\/p>\n\n<p><strong><em>WHAT??!?<\/em><\/strong><\/p>\n\n<p>We were then tasked with integrating a mobile payment system API with the e-commerce platform. This I felt was the only real growth challenge I had in the company. The integration took a while as the mobile payment system API had sketchy documentation. Though we managed to pull through. <\/p>\n\n<p>The remote team then developed a way to automatically make landing pages though it could have been made better. This meant we had a lot of free time from henceforth. <strong>A LOT<\/strong>. 3 months down road no programming at all for the company from the R&amp;D department. I decided to do my own side hustles and projects. It was nice of course because the paycheck kept coming but it started to suck. <\/p>\n\n<p>2 months of no work later, the IT director approached me and told me he wanted me to develop a platform. A friend of his, let\u2019s call him <strong><em>Mr.Outsider<\/em><\/strong>, was the project manager. I explained to my IT director that the project is a conflict of interest as per the contract given to me. <\/p>\n\n<p><em>\u201cI help Mr.Outsider, because he do for me favor and I do for him favor\u201d<\/em> <\/p>\n\n<p>He said with his broken English. We went back and forth but he did not seem to understand. I ended up doing the project and Mr.Outsider used to come to my desk and see my progress. His English too was not good. <\/p>\n\n<p>Sometime later our designer went for a CSS competition and ended up getting a job in Europe. We(R&amp;D manager and I) were happy for him and we encouraged him to pack his bags and get the hell out. The IT Director then went back to his home country as he felt homesick. This I took as a golden chance to tell the IT Director that the project was a conflict of interest and I would not continue. But it quickly backfired as he got one foreign manager within the company to follow up my progress and translate any requirements to English for me. This did not work so well so I just told them to allow me to communicate with Mr.Outsider directly. At this point in time, the R&amp;D manager left and I was left alone with an IT support guy. <\/p>\n\n<p>I never touched any e-commerce platform code nor did I do any testing. They tried to involve me by asking me to perform acceptance testing for their mobile and web platforms. This worked but they were slow in implementing any changes I requested. My role was developing <strong><em>Mr.Outsiders\u2019<\/em><\/strong> project that was completely unrelated to the company and helping IT support. This happened for 5 months. <strong><em>5 MONTHS<\/em><\/strong>. We did reach out to management several times to try and discuss why they did not include us into the core team but they kept saying<\/p>\n\n<p><em>We are dealing with a few technical issues you may find it difficult to understand but we will integrate soon<\/em><\/p>\n\n<p>In the last few months of 2016, many people had left the company.<\/p>\n\n<p>In December 2016, I got a call from a guy, <strong><em>LookFresh<\/em><\/strong> offering a job. It was still e-commerce but I jumped at it. In addition to e-commerce, they also dealt with e-wallets. Much like PayPal. We organized an interview and we had a long discussion on my skills, what he had to offer and expectations. At this time I was sort of rusty but I knew I would catch up quickly. He wanted an e-commerce built in Django. I was not too fluent in Django and I mentioned it to him but I confidently told him I was willing to learn. He later sent me a contract. I wrote a resignation letter, signed <strong><em>Mr.LookFresh\u2019s<\/em><\/strong> contract and I was out of the e-commerce company on December 31st 2016<\/p>\n\n<p>Tune in to the last bit of this series Ep.2: <a href=\"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-ep2-the-unapologetic-unforgiving-boss\"><strong><em>The Unapologetic, Unforgiving Boss<\/em><\/strong><\/a><\/p>\n\n","category":["career","downhill","ghostworking","conflictofinterest"]},{"title":"The Marvelous Misadventures Of My Career: Pilot","pubDate":"Wed, 16 Aug 2017 18:11:15 +0000","link":"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-pilot","guid":"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-pilot","description":"<p>Before I got the current job that I love, I faced many interesting trials, mishaps and failures. The journey was filled with undulations, existential crises and imposter syndrome experiences.<\/p>\n\n<p>While still back in university, a friend of mine sent me an SMS explaining an internship being offered at the university and it dealt with software development. At the time I was at home recovering from the cramming of exams. I read his text and rushed off to the place. It was a startup that built health solutions with a Health NGO. My friend and I were hired. It was fun, rigorous and engaging building IT health solutions that were actually being used on the ground in rural areas. I could see my tech skills building. The director of the NGO encouraged openness, hard work and growth. He always did his best to light up the place when he came to the office. This internship went on for a year and later it became a job after our final year. Just after graduation, the Health Solutions NGO decided to change things up a bit and offer us a paid master scholarship. Some of my friends jumped on the idea but I had none of it. I wanted to develop solutions not be in class. Plus I had already taken a diploma and degree in the same university. I needed a break. So I rejected the offer and one lecturer had a sit down with me explaining why taking a masters now is important and all that paraphernalia. I knew he was pushing the university\u2019s agenda to have as many people in the newly made masters programme. They way he presented the programme was like we should either take the masters or take the masters. I looked the other way, and a good job was dropped by my hand. But I was determined to get a new job.<\/p>\n\n<p>Tune in for Ep.1: <a href=\"https:\/\/dev.to\/hawicaesar\/the-marvelous-misadventures-of-my-career-ep1-ghost-software-development\">Ghost Software Development<\/a><\/p>\n\n","category":["life","career","somesmoothsailing"]},{"title":"Data Science: Data Visualization","pubDate":"Wed, 19 Apr 2017 13:16:39 +0000","link":"https:\/\/dev.to\/hawicaesar\/data-science-data-visualization","guid":"https:\/\/dev.to\/hawicaesar\/data-science-data-visualization","description":"<p>Im a software developer with a growing interest in data science. I have read a bit about data visualization but loving building graphs based on data. (Not that I do not like reading). I just have a few questions.<\/p>\n\n<p>Well for those who work in this space, what happens in this data visualization space?<\/p>\n\n<p>Is data visualization just another step that happens after collecting and analyzing results?<\/p>\n\n"},{"title":"Hi, I'm HawiCaesar","pubDate":"Wed, 12 Apr 2017 17:15:52 +0000","link":"https:\/\/dev.to\/hawicaesar\/hi-im-hawicaesar","guid":"https:\/\/dev.to\/hawicaesar\/hi-im-hawicaesar","description":"<p>I have been coding for 2 years.<\/p>\n\n<p>You can find me on GitHub as <a href=\"https:\/\/github.com\/HawiCaesar\" rel=\"noopener noreferrer\">HawiCaesar<\/a><\/p>\n\n<p>I live in Nairobi.<\/p>\n\n<p>I'm ready to learn and work hard<\/p>\n\n<p>I mostly program in these languages: Laravel5, Javascript, abit of Python &amp; Django].<\/p>\n\n<p>I am currently learning more about Big Data, Data Visualiztion, More Math Stuff.<\/p>\n\n<p>Nice to meet you.<\/p>\n\n","category":"introduction"}]}}