Posts

Showing posts from November, 2017

How to Mock JSNLog in Jasmine Unit Tests of Angular Code

One of the development teams at work implemented JSNLog to log from JavaScript in an Angular application we're working on, but even though the documentation to get this set up and running was very clear, the way to get it mocked for unit testing was not . Fortunately, it's not too difficult. The key in getting this to work was to spy on the JL function and have it return a mock with spy methods for the different logging methods (debug(), trace(), etc). Then set it up in your providers declaration. Here's the mock object: export   class   JLMock  {     trace = jasmine.createSpy( 'trace' );     debug = jasmine.createSpy( 'debug' );     info = jasmine.createSpy( 'info' );     warn = jasmine.createSpy( 'warn' );     error = jasmine.createSpy( 'error' );     fatal = jasmine.createSpy( 'fatal' )...

W. T. Grant’s A Very Merry Christmas

Image
I didn’t have a very happy childhood, but some of my fondest memories from when I was young, memories which I cherish, are of baking Christmas cookies with my mother. I was in my early school days, starting around kindergarten or maybe before. I remember rolling out the dough on a round table in our kitchen and using cutouts to make the cookies we would then decorate. Thinking about it now, these are probably my happiest childhood memories. While we’d be making the cookies, my mother would play Christmas music from some old records. They were compilation albums from the 1960s featuring artists of the day performing traditional Christmas songs. To this day it remains my favorite kind of Christmas music. In the years since then, I remembered two album covers specifically: one was a white cover featuring round Christmas tree ornaments with pictures of contemporary stars like Jim Nabors and Johnny Mathis, who appeared on the album, inside the ornaments; the other, which I was sure was ...