Skip to content

Commit 526f069

Browse files
authored
test(router): add export contract tests (#97)
Also refactors the main package module into it's own file
1 parent 958b82b commit 526f069

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

packages/router/src/exports.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
NgReduxRouter,
3+
NgReduxRouterModule,
4+
routerReducer,
5+
UPDATE_LOCATION,
6+
} from './index';
7+
8+
describe('The @angular-redux/router package exports', () => {
9+
it('should contain the NgReduxRouter class', () => {
10+
expect(NgReduxRouter).toBeDefined();
11+
});
12+
13+
it('should contain the NgReduxRouterModule class', () => {
14+
expect(NgReduxRouterModule).toBeDefined();
15+
});
16+
17+
it('should contain the routerReducer function', () => {
18+
expect(routerReducer).toBeDefined();
19+
});
20+
21+
it('should contain the UPDATE_LOCATION const', () => {
22+
expect(UPDATE_LOCATION).toBeDefined();
23+
});
24+
});

packages/router/src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { ModuleWithProviders, NgModule } from '@angular/core';
21
import { UPDATE_LOCATION } from './actions';
2+
import { NgReduxRouterModule } from './module';
33
import { RouterAction, routerReducer } from './reducer';
44
import { NgReduxRouter } from './router';
55

6-
@NgModule()
7-
export class NgReduxRouterModule {
8-
static forRoot(): ModuleWithProviders {
9-
return {
10-
ngModule: NgReduxRouterModule,
11-
providers: [NgReduxRouter],
12-
};
13-
}
14-
}
15-
16-
export { NgReduxRouter, RouterAction, routerReducer, UPDATE_LOCATION };
6+
// Warning: don't do this:
7+
// export * from './foo'
8+
// ... because it breaks rollup. See
9+
// https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
10+
export {
11+
NgReduxRouter,
12+
NgReduxRouterModule,
13+
RouterAction,
14+
routerReducer,
15+
UPDATE_LOCATION,
16+
};

packages/router/src/module.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ModuleWithProviders, NgModule } from '@angular/core';
2+
import { NgReduxRouter } from './router';
3+
4+
@NgModule()
5+
export class NgReduxRouterModule {
6+
static forRoot(): ModuleWithProviders {
7+
return {
8+
ngModule: NgReduxRouterModule,
9+
providers: [NgReduxRouter],
10+
};
11+
}
12+
}

0 commit comments

Comments
 (0)