Skip to content

Instantly share code, notes, and snippets.

describe("Foo", (): void => {
todo("Test #bar");
});
let myFoo = new Foo();
describe("Foo.divide()", (): void => {
it("should throw when dividing by zero", (): void => {
expectFn((): void => { myFoo.divide(42, 0); })
.toThrow("Dividing by zero should throw an error.");
});
});
let myFoo = new Foo();
describe("Foo.divide()", (): void => {
throws("when dividing by zero", (): void => {
myFoo.divide(42, 0);
}, "Dividing by zero should throw an error.");
});
let myFoo: Foo = new Foo();
describe("Foo", (): void => {
describe("#add()", (): void => {
// Reads like: Foo#add() should add two integers togehter
it("should add two integers together", (): void => {
expect<i32>(myFoo.add(19, 23)).toBe(42, "19 + 23 should be 42");
});
});
});
describe("Foo class", (): void => {
describe("#.bar()", (): void => {
// put the `#.bar()` tests here!
});
describe("#.baz()", (): void => {
// put the `#.baz()` tests here!
});
});
describe("example", (): void => {
it("should be meaninful", (): void => {
expect<i32>(19 + 23).toBe(42, "42 is the meaning of life.");
});
});
Folder: assembly/__tests__/
File: assembly/__tests__/as-pect.d.ts
File: assembly/__tests__/example.spec.ts
File: as-pect.config.js
@jtenner
jtenner / init.sh
Last active November 20, 2019 15:40
npm install --save-dev assemblyscript @as-pect/cli
npx asinit .
npx asp --init
# To run your test suite
npx asp
@jtenner
jtenner / index.js
Last active November 14, 2017 22:40
requirebin sketch
const rbush = require( "rbush" );
const ctx = document.createElement( "canvas" ).getContext( "2d" );
const width = ctx.canvas.width = 800;
const height = ctx.canvas.height = 600;
const e2d = require( "e2d" );
document.body.appendChild( ctx.canvas );
const tree = rbush();
const rects = [];
@jtenner
jtenner / index.js
Last active August 28, 2017 16:53
requirebin sketch
const repatch = require('repatch');
const e2d = require('e2d');
const components = [];
const app = { pointer: false, mouseData: null, activeRegions: null };
const ctx = document.createElement('canvas').getContext('2d');
ctx.canvas.width = 400;
ctx.canvas.height = 300;
document.body.appendChild(ctx.canvas);
e2d.raf(() => {