Skip to content

Commit

Permalink
Merge pull request #57 from schubergphilis/filterable-actions
Browse files Browse the repository at this point in the history
Renamed searchableActions to filterableActions, added changeFilter and clearFilter to it
  • Loading branch information
tommyminds committed Nov 6, 2015
2 parents 0fd1086 + 8b918a5 commit af4c178
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 72 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anglue",
"version": "1.3.4",
"version": "1.3.5",
"authors": [
"Tommy Maintz <tommy.maintz@gmail.com>"
],
Expand Down
6 changes: 3 additions & 3 deletions dist/amd/behaviors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/amd/behaviors/filterable-actions.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/amd/behaviors/searchable-actions.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion src/behaviors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from './behaviors/behavior';
export * from './behaviors/event-emitter';
export * from './behaviors/entity-store';
export * from './behaviors/filterable-actions';
export * from './behaviors/filterable-store';
export * from './behaviors/searchable-actions';
export * from './behaviors/searchable-component';
export * from './behaviors/sortable-actions';
export * from './behaviors/sortable-component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {Action as actionDecorator} from '../actions';

export function SearchableActions() {
export function FilterableActions() {
return cls => {
actionDecorator()(cls.prototype, 'changeSearch');
actionDecorator()(cls.prototype, 'clearSearch');
actionDecorator()(cls.prototype, 'changeFilter');
actionDecorator()(cls.prototype, 'clearFilter');
};
}
72 changes: 72 additions & 0 deletions src/behaviors/filterable-actions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*eslint-env node, jasmine*//*global module inject*/
/*eslint-disable max-statements, max-params*/
import angular from 'angular';
import 'angular-mocks';
import 'luxyflux/ng-luxyflux';

import {
Annotations,
Actions,
FilterableActions
} from 'anglue/anglue';

describe('FilterableActions', () => {
// Clear the AnnotationCache for unit tests to ensure we create new annotations for each class.
beforeEach(() => {
Annotations.clear();
});

describe('@FilterableActions() decorator', () => {
@Actions()
@FilterableActions()
class FilterableTestActions {}

let testActions;
let appDispatcher;

class MockApplicationDispatcher {
dispatch() {}
}

angular
.module('filterableActionsApp', [
'luxyflux',
FilterableTestActions.annotation.module.name
])
.service('ApplicationDispatcher', [
function () {
return new MockApplicationDispatcher();
}
]);

beforeEach(module('filterableActionsApp'));
beforeEach(inject((_FilterableTestActions_, _ApplicationDispatcher_) => {
testActions = _FilterableTestActions_;
appDispatcher = _ApplicationDispatcher_;

spyOn(appDispatcher, 'dispatch');
}));


it('should dispatch an FILTERABLE_TEST_CHANGE_SEARCH action', () => {
testActions.changeSearch('FOOBAR');
expect(appDispatcher.dispatch).toHaveBeenCalledWith('FILTERABLE_TEST_CHANGE_SEARCH', 'FOOBAR');
});

it('should dispatch an FILTERABLE_TEST_CLEAR_SEARCH action', () => {
testActions.clearSearch();
expect(appDispatcher.dispatch).toHaveBeenCalledWith('FILTERABLE_TEST_CLEAR_SEARCH');
});

it('should dispatch an FILTERABLE_TEST_CHANGE_FILTER action', () => {
testActions.changeFilter('FOOBAR');
expect(appDispatcher.dispatch).toHaveBeenCalledWith('FILTERABLE_TEST_CHANGE_FILTER', 'FOOBAR');
});

it('should dispatch an FILTERABLE_TEST_CLEAR_SEARCH action', () => {
testActions.clearFilter('FOOBAR');
expect(appDispatcher.dispatch).toHaveBeenCalledWith('FILTERABLE_TEST_CLEAR_FILTER', 'FOOBAR');
});

});
});
62 changes: 0 additions & 62 deletions src/behaviors/searchable-actions.spec.js

This file was deleted.

0 comments on commit af4c178

Please sign in to comment.