Karma karma infinite impact

Ohm Beads Karma Collection – Infinite Time

Karma karma infinite impact This week brings the fourth release in the ongoing Karma by Ohm Beads collection and is the first dangle in the series to be unveiled. The Karma collection has been released one at a time on Thursdays since the first charm was on May 8th, with each bead representing a specific Chakra in Hindu and tantric teachings. I have been enjoying this special incremental release and the unique designs that come out so far!

This charm, called Infinite Time, signifies the 3rd Chakra which is responsible for one’s sense of self esteem and confidence. This Chakra is sometimes called the Solar Plexus Chakra and is located on your spine near your belly button. Blockages and obstruction of this vital energy point is thought to manifest as feelings of embarrassment, shame, and self consciousness.

Infinite Time combines two symbols which tie back to this Chakra, the first being the spiraling nautilus shell on the dangle. The nautilus shell is referenced in Hindu myth and is considered a symbol for life and inner beauty, with it’s spiraling form representing the infinite cycle of existence. Being in tune with your 3rd Chakra means understanding who you are and where you belong on the spiraling path of life. The back of the shell is engraved with clock face numbers, reinforcing the metaphor and adding a nice detail to the backside of the charm.

The second symbol is the rosary bead base of the charm – Ohm has noted that this is designed to look like the mala beads that are used in Buddhism and Hinduism. Real-life jap mala prayer beads have 108 beads (108 is a special number in both religions) but it would be a bit tough to fit all of those on this little charm! I really like this additional design element and enjoy how it ties back to the original Chakra idea. The detailing on Infinite Time is well done and typical of Ohm’s style, with deep crisp engravings on the front and back of the shell and a nicely sculpted base.

Infinite Time, as well as the earlier releases from the Karma by Ohm collection, are available online both at Perlen and direct from the Ohm Beads website. Ohm Beads are fully compatible with all major bracelet brands including Pandora. I’m looking forward to seeing how Ohm rounds out this collection and represents the remaining Chakras in the upcoming weeks; what do you ladies think?

Unit testing infinite scroll in ui-grid with Karma and Jasmine

My mandate was to create some common Angular components for use across the entire organization. One of these components was a grid. This grid needs to hold 100’s of thousands of items and must support infinite scroll. I chose to abstract away the true grid implementation (ui-grid) and place it behind my own custom directive (my-grid).

I wanted to use Karma and Jasmine to write some unit tests for the grid. It turns out that it wasn’t entirely intuitive. This post will highlight some of the challenges I encountered and how I overcame them.

Software used at the time of this writing

  • angular 1.4.1
  • ui-grid 3.0.1
  • karma 0.13.3
  • jasmine 2.3.4

The markup is quite simple, but there are a couple things to note:

  • The refresh flag. This is to combat this issue: https://github.com/angular-ui/ng-grid/issues/3770
  • The inner div is for showing a special message when there are no items to display.

I’m only showing a tiny fraction of the grid configuration. The key thing here is that getItems is called inside of onRegisterApi. Also notice that to get the grid items, we are fetching them asynchronously from a generic service that gets injected. I am not showing how columns are configured or anything else like that, just the key things I need to get a unit test working.

There are comments in the code that point out the trouble spots. Namely, when fetching data asynchronously, I was having issues with grid.rows always being empty. It turns out that I needed to wrap the promise’s resolve method in a timeout. This allows the underlying ui-grid instance to do whatever it needs to do in order to add our data to the grid.

If you’ve ever written an Angular test with a timeout before, then you’ll notice the use of $timeout.flush() which is required in order to flush the queue of deferred functions.

The first issue I ran into with infinite scroll was how to simulate the scrolling. The trick here isn’t to force the view port to scroll or anything fancy like that. Really, all you need to do is force the infinite scroll API to fetch data. Here’s an example:

Note: You must set grid.infiniteScroll.direction to the direction you are planning on scrolling before you raise the scroll events. If you don’t do this, the infinite scroll API’s adjustScroll method won’t correctly resolve promises and any code you have that relies on the gridApi.infiniteScroll.dataLoaded promise getting resolve (i.e., to manage the internal data structure) won’t get called. This will cause the grid to behave differently in tests than in a real life situation which isn’t good.

This is especially useful if you are controlling the amount of items that can be retained in memory on the client side. Using this simple pattern will allow you to create complex tests that simulate user scrolling. Read above for why I have to do a $timeout.flush() after each fetch. Essentially, without flushing the deferreds, my data never actually makes it back to the grid API, so that essentially commits my data to the grid.

It would be wise to encapsulate some of this duplicate code in a couple functions to increase the readability. For example:

Note: Some of the testing around infinite scroll is highly dependent upon the implementation within the infinite scroll API. Hopefully what I’ve outlined above continues to work, but it will be important that you ensure your tests are working as expected should you use a different version of the ui-grid.

Like this post? Please share to your friends: