Skip to content

Instantly share code, notes, and snippets.

View wescopeland's full-sized avatar

Wes Copeland wescopeland

View GitHub Profile
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@wescopeland
wescopeland / wallaby.js
Last active June 12, 2019 22:15
Sample Wallaby config for Angular+Jest
const ngxWallabyJest = require('ngx-wallaby-jest');
module.exports = function(wallaby) {
return {
files: [
'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
'tsconfig.json',
'jest.config.js',
'tsconfig.spec.json',
'!src/**/*.spec.ts'
@wescopeland
wescopeland / awesome-entity.model.ts
Last active June 13, 2019 21:41
entity-data.service
export interface AwesomeEntity {
id: number;
}
@wescopeland
wescopeland / presentational-button.component.spec.ts
Last active June 15, 2019 19:51
Presentational Button Component Spectator Test
import { Spectator, createTestComponentFactory } from '@netbasal/spectator/jest';
import { PresentationalButtonComponent as PBComponent } from './presentational-button.component';
describe('Component: PresentationalButtonComponent', () => {
let spectator: Spectator<PBComponent>;
const createComponent = createTestComponentFactory<PBComponent>({
component: PBComponent
});
@wescopeland
wescopeland / entity.service.spec.ts
Last active June 15, 2019 19:52
entity service unit testing example
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest';
import { of } from 'rxjs';
import { AwesomeEntityStore } from './entity.store';
import { EntityDataService } from './entity-data.service';
import { EntityService } from './entity.service';
describe('Service: EntityService', () => {
let dataService: SpyObject<EntityDataService>;
let store: SpyObject<AwesomeEntityStore>;
@wescopeland
wescopeland / notification.service.spec.ts
Last active June 15, 2019 19:53
Notification service with Spectator
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest';
import { MatSnackBar } from '@angular/material/snack-bar';
import { NotificationService } from './notification.service';
describe('Service: NotificationService', () => {
let snackBar: SpyObject<MatSnackBar>;
let spectator: SpectatorService<NotificationService> = createService({
service: NotificationService,
@wescopeland
wescopeland / stateful.component.spec.ts
Created June 15, 2019 19:59
Stateful Component Testing w/ Spectator
import { Spectator, SpyObject, createTestComponentFactory } from '@netbasal/spectator/jest';
import { of } from 'rxjs';
import { StatefulComponent } from './stateful.component';
import { AwesomeEntitiesQuery } from './+state';
describe('Component: StatefulComponent', () => {
let query: SpyObject<AwesomeEntitiesQuery>;
let spectator: Spectator<StatefulComponent>;
@wescopeland
wescopeland / notification.service.ts
Created June 16, 2019 13:03
notification service
import { Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
@Injectable({ providedIn: 'root' })
export class NotificationService {
constructor(private _snackBar: MatSnackBar) {}
notify(message: string, duration = 7000): void {
this._snackBar.open(message, 'CLOSE', { duration });
}
@wescopeland
wescopeland / notification.service.spec.ts
Created June 16, 2019 13:05
notification service spec
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest';
import { MatSnackBar } from '@angular/material/snack-bar';
import { NotificationService } from './notification.service';
describe('Service: NotificationService', () => {
let snackBar: SpyObject<MatSnackBar>;
let spectator: SpectatorService<NotificationService> = createService({
service: NotificationService,
@wescopeland
wescopeland / awesome-entity.model.ts
Created June 16, 2019 13:10
awesome-entity.model.ts
export interface AwesomeEntity {
id: number;
}