Skip to content

Instantly share code, notes, and snippets.

const BowlingGame = require('./bowling-game');
it('should return 0 for a game of all gutter balls', () => {
const game = new BowlingGame();
for (let i = 0; i < 20; i++) {
game.roll(0);
}
expect(game.score).toEqual(0);
@joerter
joerter / angular-component-class-test-with-stub.ts
Created September 2, 2018 18:02
An Angular component class test using a stub function to create typed dependencies
// Based on example from: https://angular.io/guide/component-interaction#parent-listens-for-child-event
@Component({
selector: 'app-voter'
})
export class VoterComponent {
@Output() voted = new EventEmitter<boolean>();
didVote = false;
constructor(private loggingService: LoggingService){}
@joerter
joerter / stub.ts
Last active January 20, 2023 04:33
A simple function that creates an object of the specified type and sets all properties to undefined. Useful for creating stubs in Typescript tests
export function stub<T>(partial?: Partial<T>): T {
return partial != null ? (partial as T) : ({} as T);
}
@joerter
joerter / angular-component-class-test.ts
Last active August 12, 2018 19:03
An example of how to write a component class test for an Angular component
// Based on example from: https://angular.io/guide/component-interaction#parent-listens-for-child-event
@Component({
selector: 'app-voter'
})
export class VoterComponent {
@Output() voted = new EventEmitter<boolean>();
didVote = false;
constructor(private loggingService: LoggingService){}
FROM node:5.5.0
EXPOSE 3000
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
docker run --name dockerized-container -d -p 3000:3000 dockerized node server.js
docker build -t dockerized .
FROM node:5.5.0
EXPOSE 3000
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
const http = require('http');
const port = 3000;
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Dockerized!\n');
}).listen(port, () => {
console.log(`Server running at http://0.0.0.0:${port}/`);
});