Aurelia Testing With Jest

Setting up Jest to test your Aurelia components is pretty easy. The Aurelia team has a great collection of starter kits that can get you setup using Aurelia. I started with the esnext-webpack version and stripped out some dependencies.

The Aurelia team also has a aurelia-testing which I haven’t used. For this example I only used Jest.

Full source code for this example aurelia-testing-jest

Let’s start!

Directory structure

1
2
3
4
5
6
7
8
9
10
11
12
.
|__src
| |__app.js
| |__app.html
| |__main.js
|
|__test
| |__jest-pretest.js
| |__unit
| |__app.spec.js
|
|__package.json

All tests are in test/unit directory and end in .spec.js. For this example I’ll be testing the src/app.js component.

Read More

Default export value in Babel 6.x

In ECMAScript 6 creating a module whose default export is a class would look like the following:

1
2
3
4
5
export default class MyClass {
getMessage() {
return 'hello';
}
}

Using Babel 6.x to transpile this would look like the following:

1
2
3
4
5
6
7
8
9
10
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
// More transpilation stuff goes here.
// This is the important line!
exports.default = MyClass;

Read More

Find Stored Procedure Dependencies

Recently working in Microsoft SQL Server I needed to find all the dependencires for a specific stored procedure. I ended up with the following:

1
2
3
4
5
6
use MY_DB
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%myStoredProcedure%'
AND ROUTINE_TYPE='PROCEDURE'

This query looks through all the stored procedure definitions, in the MY_DB database, for the words myStoredProcedure. The results will display all the stored procedures including the myStoredProcedure.

Angular2 With Typescript And Webpack

I’m just starting to get into angular2 with TypeScript. I decided to give the angular2 quickstart application a try. At first glance I wanted to use webpack instead of systemjs for module loading.

To begin here is my package.json file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"name": "angular2-typescript-webpack",
"version": "1.3.0",
"scripts": {
"postinstall": "typings install",
"build": "webpack",
"start": "webpack-dev-server"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.23"
},
"devDependencies": {
"ts-loader": "0.8.2",
"typescript": "1.8.10",
"typings": "1.3.0",
"webpack": "1.13.0",
"webpack-dev-server": "1.14.1"
}
}

I have typescript and typings installed globally npm install typescript typings -g but included them in the devDependencies section just in case some people don’t want to install those globally.

You’ll need a file named typings.json to install a es6-shim

1
2
3
4
5
{
"globalDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"
}
}

You can now run typings install

I included webpack and webpack-dev-server. There are two npm scripts, build and start, that use webpack and webpack-dev-server respectively.

Read More

Asp.net Dropdownlist Control Datasource Expression

I’m fairly new to .NET and I’m finding it a challenge locating solutions for some problems I was having. I decided to start writing down the solutions I found or created. There might be better ways to solve the problems. If you find a better way please let me know.

Now on the problem. To start off the application is written in VB.NET 2.0. There is a form with a asp dropdown control that I needed to set the datasource. This dropdown control lives inside a asp repeater control. I wanted to set the datasource inside an expression like the following:

1
<asp:DropDownList runat="server" DataSource='<%# CreateDataSource() #%>' />

Read More