Skip to content

Commit

Permalink
fix(lint): fix linting and add group to demo components
Browse files Browse the repository at this point in the history
  • Loading branch information
nivekcode committed Apr 28, 2019
1 parent 4758650 commit d8aa7d4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h2 class="card-text">{{ sortOrder }}</h2>
</div>
<ngsg-card *ngFor="let item of item$ | async"
ngSortgridItem
ngSortGridGroup="async-items"
[ngSortGridItems]="item$ | async"
[item]="item"
(sorted)="applyOrder($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ <h5 style="margin-bottom: 20px">3. Drag the items around - hold CMD or Control a
<div class="example-container">
<ngsg-card *ngFor="let item of items"
ngSortgridItem
ngSortGridGroup="getting-started"
[ngSortGridItems]="items"
[item]="item"
class="example-box">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ <h2 class="card-text">{{ sortOrder }}</h2>
<div class="example-container">
<ngsg-card *ngFor="let item of items"
ngSortgridItem
ngSortGridGroup="react-on-changes"
[item]="item"
[ngSortGridItems]="items"
(sorted)="applyOrder($event)"
Expand Down
31 changes: 22 additions & 9 deletions projects/ng-sortgrid/src/lib/ngsg-item.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,34 @@ import createSpy = jasmine.createSpy;
import {NgsgElementsHelper} from './ngsg-elements.helper';

describe('NgsgItemDirective', () => {

let sut: NgsgItemDirective;

const elementRef = {nativeElement: {}};
const ngsgSortService = createSpyObj<NgsgSortService>('ngsgSortService', ['initSort', 'sort', 'endSort']);
const ngsgSelectionService = createSpyObj<NgsgSelectionService>('ngsgSelectionService',
['selectElementIfNoSelection', 'updateSelectedDragItem']);
const ngsgSelectionService = createSpyObj<NgsgSelectionService>('ngsgSelectionService', [
'selectElementIfNoSelection',
'updateSelectedDragItem'
]);
const ngsgReflectService = createSpyObj<NgsgReflectService>('ngsgReflectService', ['reflectChanges']);
const ngsgStore = createSpyObj<NgsgStoreService>('ngsgStore',
['initState', 'hasSelectedItems', 'resetSelectedItems', 'hasGroup', 'hasItems', 'setItems']);
const ngsgStore = createSpyObj<NgsgStoreService>('ngsgStore', [
'initState',
'hasSelectedItems',
'resetSelectedItems',
'hasGroup',
'hasItems',
'setItems'
]);
const ngsgEventService = new NgsgEventsService();

beforeEach(() => {
sut = new NgsgItemDirective(elementRef, ngsgSortService, ngsgSelectionService,
ngsgReflectService, ngsgStore, ngsgEventService);
sut = new NgsgItemDirective(
elementRef,
ngsgSortService,
ngsgSelectionService,
ngsgReflectService,
ngsgStore,
ngsgEventService
);
});

it('should set the draggable attribute on the elment', () => {
Expand Down Expand Up @@ -241,13 +254,13 @@ describe('NgsgItemDirective', () => {
});

it('should log a warning message if you drop and you did not provide any items', () => {
const expectedWarniningMessage = `Ng-sortgrid: No items provided - please use [sortGridItems] to pass in an array of items -
const expectedWarniningMessage =
`Ng-sortgrid: No items provided - please use [sortGridItems] to pass in an array of items -
otherwhise the ordered items can not be emitted in the (sorted) event`;
const consoleWarnSpy = spyOn(console, 'warn');
ngsgStore.hasItems.and.returnValue(false);

sut.drop(event);
expect(consoleWarnSpy).toHaveBeenCalledWith(expectedWarniningMessage);
});

});

0 comments on commit d8aa7d4

Please sign in to comment.