-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test/add specs #85
Test/add specs #85
Conversation
- Add watch:tests for simpler dev / test - Store utils spec
Hey there! First off, congrats on 4.0.0! Second, I resolved conflicts! |
modules/store/spec/store.spec.ts
Outdated
const result = store.select('counter1'); | ||
|
||
expect(result instanceof Store).toBe(true); | ||
expect(result).toEqual(any(Store)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using instanceof
seems like a better check than any(Store)
modules/store/spec/store.spec.ts
Outdated
@@ -183,7 +177,7 @@ describe('ngRx Store', () => { | |||
}); | |||
|
|||
// TODO: Investigate why this is no longer working | |||
xit('should complete if the dispatcher is destroyed', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let this test remain excluded
modules/store/spec/utils.spec.ts
Outdated
@@ -0,0 +1,81 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove header text
modules/store/src/store_module.ts
Outdated
@@ -51,7 +51,13 @@ export class StoreFeatureModule implements OnDestroy { | |||
@Inject(STORE_FEATURES) private features: StoreFeature<any, any>[], | |||
private reducerManager: ReducerManager | |||
) { | |||
features.forEach(feature => reducerManager.addFeature(feature)); | |||
for (let feature of features) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functional approach is preferred over the for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got it!
modules/store/src/utils.ts
Outdated
return Object.keys(object) | ||
.filter(key => key !== keyToRemove) | ||
.reduce((result, key) => Object.assign(result, { [key]: object[key] }), {}); | ||
const ret: Partial<T> = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to refactor this.
modules/store/src/state.ts
Outdated
import { withLatestFrom } from 'rxjs/operator/withLatestFrom'; | ||
import { scan } from 'rxjs/operator/scan'; | ||
import { ActionsSubject } from './actions_subject'; | ||
import { Action, ActionReducer } from './models'; | ||
import { INITIAL_STATE } from './tokens'; | ||
import { ReducerObservable } from './reducer_manager'; | ||
import { ScannedActionsSubject } from './scanned_actions_subject'; | ||
import { INIT } from './'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add INIT
to existing imports from ./actions_subject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I don't know what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 9, add INIT to the existing object
import { ActionsSubject, INIT } from './actions_subject';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, got it. It took me an embarrassingly long time to figure out what you were referring to.
modules/store/spec/utils.spec.ts
Outdated
describe(`combineReducers()`, () => { | ||
const s1 = { x: '' }; | ||
const s2 = { y: '' }; | ||
const r1 = (s = s1, a: any): typeof s1 => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a preference, but make the variable names more descriptive than s
and a
so they are more readable at glance
Not sure why Circle failed. Everything runs fine here. |
- (BREAKING) OpaqueToken -> InjectionToken - Stronger types for core actions (INIT, UPDATE) - Add more tests
LGTM |
A few things to note about this PR:
initialState
function for features. This was only implemented for root previously, but I added it to features as well. Unfortunately, the implementation is a bit different b/c features aren't using a token to provide initial state.Removed
OpaqueToken
. The deps for this project are clear, and we're already usingInjectionToken
elsewhere, so it doesn't make sense to continue using a deprecated symbol.Stronger types on core actions
INIT
,UPDATE
, etc. I don't think this actually affects anything currently, but it does make certain inspections nicer.Watch mode using chokidar. This should make writing development a bit nicer (
yarn run watch:tests
). This also outputs an html coverage report if that's your cup.Some of these tests are a bit obtuse. I'm still getting used to writing ng2+ tests, so feedback is welcome if you see something that could be improved. I'll write some more tests in the future, but I wanted to get this out there.
ps: Crossing my fingers that the
xit
test passes. Last time it failed in CI, and I have zero clue why. If it fails I'll xit back again