Skip to content

Commit

Permalink
add some basic unit tests to the examples app
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Jun 19, 2018
1 parent 1c531ef commit d2556be
Show file tree
Hide file tree
Showing 28 changed files with 783 additions and 591 deletions.
3 changes: 2 additions & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"angular-skyhook": "^1.0.5",
"angular-skyhook-card-list": "^0.0.4",
"angular-skyhook-multi-backend": "^1.0.5",
"react-dnd-test-backend": "^4.0.0",
"core-js": "^2.5.4",
"faker": "^4.1.0",
"immutability-helper": "^2.7.0",
Expand Down Expand Up @@ -58,4 +59,4 @@
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
}
27 changes: 0 additions & 27 deletions packages/examples/src/app/app.component.spec.ts

This file was deleted.

80 changes: 39 additions & 41 deletions packages/examples/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { AppComponent } from "./app.component";
import { SkyhookDndModule, DRAG_DROP_BACKEND } from "angular-skyhook";
import { DragDropManager } from "dnd-core";
import { AppComponent } from './app.component';
import { SkyhookDndModule, DRAG_DROP_BACKEND } from 'angular-skyhook';

/* Note:
* Angular in AOT mode isn't capable of doing plain `import XXX from 'package-xxx'` imports.
Expand All @@ -22,60 +21,59 @@ import { DragDropManager } from "dnd-core";
// import { default as MultiBackend } from 'react-dnd-multi-backend';
// import { default as HTML5toTouch } from 'react-dnd-multi-backend/lib/HTML5toTouch';

import { PreloadAllModules } from "@angular/router";
import { PreloadAllModules } from '@angular/router';
// this is our own adaptation of dnd-multi-backend. will be published eventually
import { createDefaultMultiBackend } from "angular-skyhook-multi-backend";
import { ExampleLink } from "./example-link.component";
import { UtilityModule } from "./utility.module";
import { createDefaultMultiBackend } from 'angular-skyhook-multi-backend';
import { UtilityModule } from './utility.module';

let routes: Routes = [
{ path: "", pathMatch: "full", redirectTo: "bins" },
{ path: "bins", pathMatch: "full", loadChildren: "./bins/index#Module" },
{ path: '', pathMatch: 'full', redirectTo: 'bins' },
{ path: 'bins', pathMatch: 'full', loadChildren: './bins/index#Module' },
{
path: "sortable",
pathMatch: "full",
loadChildren: "./sortable/index#Module"
path: 'sortable',
pathMatch: 'full',
loadChildren: './sortable/index#Module'
},
{
path: "chessboard",
pathMatch: "full",
loadChildren: "./chessboard/index#Module"
path: 'chessboard',
pathMatch: 'full',
loadChildren: './chessboard/index#Module'
},
{
path: "drag-layer/simple",
pathMatch: "full",
loadChildren: "./drag-layer/index#Module"
path: 'drag-layer/simple',
pathMatch: 'full',
loadChildren: './drag-layer/index#Module'
},
{
path: "drag-layer/xy-pad",
pathMatch: "full",
loadChildren: "./xy-pad/index#Module"
path: 'drag-layer/xy-pad',
pathMatch: 'full',
loadChildren: './xy-pad/index#Module'
},
{ path: "touch", pathMatch: "full", loadChildren: "./touch/index#Module" },
{ path: 'touch', pathMatch: 'full', loadChildren: './touch/index#Module' },
{
path: "drilldown",
pathMatch: "full",
loadChildren: "./drilldown/index#Module"
path: 'drilldown',
pathMatch: 'full',
loadChildren: './drilldown/index#Module'
},
{
path: "nested/sources",
pathMatch: "full",
loadChildren: "./nested/sources/index#Module"
path: 'nested/sources',
pathMatch: 'full',
loadChildren: './nested/sources/index#Module'
},
{
path: "nested/targets",
pathMatch: "full",
loadChildren: "./nested/targets/index#Module"
path: 'nested/targets',
pathMatch: 'full',
loadChildren: './nested/targets/index#Module'
},
{
path: "customize/handles-previews",
pathMatch: "full",
loadChildren: "./customize/handles-previews/index#HandlesPreviewsModule"
path: 'customize/handles-previews',
pathMatch: 'full',
loadChildren: './customize/handles-previews/index#HandlesPreviewsModule'
},
{
path: "kanban",
pathMatch: "full",
loadChildren: "./kanban/index#KanbanModule"
path: 'kanban',
pathMatch: 'full',
loadChildren: './kanban/index#KanbanModule'
}
];

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
default as TestBackendImpl,
TestBackend
} from 'react-dnd-test-backend';
import { SkyhookDndModule, DRAG_DROP_MANAGER } from 'angular-skyhook';

import { CustomDragLayerComponent } from './custom-drag-layer.component';
import { BoxDragPreviewComponent } from '../box-drag-preview/box-drag-preview.component';
import { BoxComponent } from '../box.component';

describe('CustomDragLayerComponent', () => {
let component: CustomDragLayerComponent;
let fixture: ComponentFixture<CustomDragLayerComponent>;
describe('DragLayer => CustomDragLayerComponent', () => {
let component: CustomDragLayerComponent;
let fixture: ComponentFixture<CustomDragLayerComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CustomDragLayerComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SkyhookDndModule.forRoot({ backend: TestBackendImpl })],
declarations: [
CustomDragLayerComponent,
BoxDragPreviewComponent,
BoxComponent
]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CustomDragLayerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(CustomDragLayerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
default as TestBackendImpl,
TestBackend
} from 'react-dnd-test-backend';
import { SkyhookDndModule, DRAG_DROP_MANAGER } from 'angular-skyhook';

import { DragContainerComponent } from './drag-container.component';
import { DraggableBoxComponent } from '../draggable-box/draggable-box.component';
import { BoxComponent } from '../box.component';
import { CustomDragLayerComponent } from '../custom-drag-layer/custom-drag-layer.component';
import { BoxDragPreviewComponent } from '../box-drag-preview/box-drag-preview.component';

describe('DragContainerComponent', () => {
let component: DragContainerComponent;
let fixture: ComponentFixture<DragContainerComponent>;
describe('DragLayer => DragContainerComponent', () => {
let component: DragContainerComponent;
let fixture: ComponentFixture<DragContainerComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DragContainerComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SkyhookDndModule.forRoot({ backend: TestBackendImpl })],
declarations: [
DragContainerComponent,
DraggableBoxComponent,
BoxComponent,
CustomDragLayerComponent,
BoxDragPreviewComponent
]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DragContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(DragContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
default as TestBackendImpl,
TestBackend
} from 'react-dnd-test-backend';
import { SkyhookDndModule, DRAG_DROP_MANAGER } from 'angular-skyhook';

import { DraggableBoxComponent } from './draggable-box.component';
import { BoxComponent } from '../box.component';

describe('DraggableBoxComponent', () => {
let component: DraggableBoxComponent;
let fixture: ComponentFixture<DraggableBoxComponent>;
describe('DragLayer => DraggableBoxComponent', () => {
let component: DraggableBoxComponent;
let fixture: ComponentFixture<DraggableBoxComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DraggableBoxComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SkyhookDndModule.forRoot({ backend: TestBackendImpl })],
declarations: [DraggableBoxComponent, BoxComponent]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DraggableBoxComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(DraggableBoxComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Empty file.
15 changes: 15 additions & 0 deletions packages/examples/src/app/test/SkyhookDndServiceMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
SkyhookDndService,
DropTargetSpec,
AddSubscription,
DropTarget,
DragSource,
DragSourceSpec,
DragLayer
} from 'angular-skyhook';
import { NgModule } from '@angular/core';

@NgModule({
providers: [SkyhookDndService]
})
export class SkyhookTestingModule {}
Loading

0 comments on commit d2556be

Please sign in to comment.