Unit testing React components with Jest

Jest is a unit test framework for testing React apps. The Getting Started guide is pretty much all you need to get started. If you’ve created your project using create-react-app then you’re already setup, just run ‘npm test’ and a runner will test up that repeatedly runs your tests as you make code or test changes.

create-react-app also creates a sample test for the sample App.js component. This is a good starting point to follow for other tests:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App/>, div);
});

To test the results of rendering a component, the enzyme library allows you to easily capture the output from a render, and then query the results. For example:

import React from 'react';
import ReactDOM from 'react-dom';
import {shallow, mount} from 'enzyme';
import Calculator from '../Components/CalculatorComponent';
it('renders with result 3', () => {
    const result = mount(<Calculator value1="1" value2="2" />);
    result.find('button').simulate('click');
    const buttonResult = result.find("#result").first();
    expect(buttonResult.text()).toEqual("3");
});

The CalculatorComponent I’m testing here is the one from my previous React post.

Remember the Motorola Atrix in 2011 with its Webtop mode?

One of the rumors about Samsung’s upcoming S8 is that they are going to introduce a desktop mode supporting an external monitor and keyboard/mouse.

Not so long ago Microsoft were trying to convince us about Continuum and how we’d all be plugging our phones into desktop monitors and keyboards.

Let’s not forget that Microsoft was not the first to try this – several years before Continuum, Motorola tried out something similar on their Atrix phone back in 2011 (and a number of Motorola phones that followed?) where it supported a dual boot mode that could be booted into a Ubuntu Linux based desktop mode when connected to a monitor, keyboard and mouse.

Motorola apparently discontinued the feature because base features in Android starting supporting HDMI and attaching USB devices such as USB external drives, keyboards, mice etc to your phone via a USB OTG connector. Not many people are aware that your Android phone may already support connecting to a monitor, keyboard and mouse, if you so want to. Take a look on the box or in your manual for the ‘USB on-the-go’ logo and you might have these features already.

Packet Radio: Checking in to the Central California Sunday Packet Net using Linpac and Direwolf

I didn’t think it was year ago that I last checked to the Central California Packet Sunday night net, but looking for notes on how to send packet unproto frames from Linpac, this post was today exactly last year. Apparently January 15th is my favorite day for doing some packet radio.

This is using ax25, Direwolf and Linpac setup on Debian that I posted about a few days back. I did a screen recording of the net checkins so you can see what a packet net looks like. It’s not exactly fast paced, and in the middle there’s some WinLink email inbox checking going on, but you can see Ben KG6BNL running Net Control, and then check-ins that follow.

In the screencapture I’m ssh’d from my Mac into my desktop upstairs which has a Rigblaster Plug n Play connected to my Icom 880h. The top session is Direwolf, so you can see it’s decoding all the packets it hears. The bottom session is Linpac, where I’m using :unproto to send my check-in.

Are foldable/flexible phones coming in 2017?

Apple has been criticized in the press from several points of view (for example) that their recent product releases have not been innovative enough, and they’re no longer pushing the boundaries of what’s currently possible. I came across a comment somewhere (I forgot to bookmark it), that the mobile phone industry in general has reached it’s peak of what’s possible, and to continue growth there needs to be a new revolution to innovate beyond the current form factor of the smartphone as we know it today.

I’ve said many times before that each device form factor has unique benefits and limitations according to its size and user interface. For example, a phone that fits in your pocket it a poor replacement for a desktop computer with a large LCD monitor, full size keyboard and mouse, and the reverse holds true too, a desktop computer is hardly a portable computing device.

The recent rumors and articles (in 2015, in 2016 and Lenovo’s concept phone here and here, and more recently: here, here, and here) about new phones from Samsung and LG possibly coming with folding screens starts to blur what’s possible. What if you have a phone that’s small enough and portable to be a phone (as we know it in the current form factor), but it has a screen that unfolds into something larger, say with a 7″ or larger screen that can be used in place of a tablet? That would certainly shake things up, allowing you to carry a device with a large enough screen to sit down and use it at a desk, but still carry it around in your pocket. I’m really curious and hope these come to market soon.