This repository was archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Cleaner code #17
Merged
Merged
Cleaner code #17
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
8a59985
FrequencyObservable as a function returning a observable
amaury1093 f113991
Fix tests
amaury1093 5e613d4
Test a new api
amaury1093 9ecae21
Make frequency observables work
amaury1093 660c5ef
Fix tests
amaury1093 6e99b67
Remove overview
amaury1093 e4298fa
Don't cover index.ts
amaury1093 bb5509c
Fix a lot of stuff
amaury1093 1008d5a
Remove useless import
amaury1093 3aa360b
Change testRegex for jest
amaury1093 ea75324
Add ambient for packages with no typigns
amaury1093 7c03c5c
Generate docs
amaury1093 80b283f
Remove NullProvider
amaury1093 a46b19a
Remove NullProvider
amaury1093 3447e95
Regenerate docs
amaury1093 1f0c25a
Silent jest on CI
amaury1093 b4404e2
Fix makeContract and post
amaury1093 165df16
Regen docs
amaury1093 9b8edd8
Update summary
amaury1093 fb89a94
Update ambient
amaury1093 439d3bd
Export post$ too
amaury1093 18e640f
Fix makeContract
amaury1093 431fe51
Fix memoization for frequency observables
amaury1093 44dde4a
Don't lint lib
amaury1093 15caa62
Fix bugs with rpc$
amaury1093 0cbe22a
Remove useless packages
amaury1093 85f8fb9
Generate docs
amaury1093 c5e0c56
Update withoutLoading syntax
amaury1093 82fca45
Use json.stringify for normalizer
amaury1093 4893e97
Fix bug normalizer
amaury1093 e449a57
Remove withApi in docs
amaury1093 3a885fe
Fix bug memoization
amaury1093 c6ee32e
Remove onEvery2Blocks
amaury1093 041441b
Options then args
amaury1093 8a066db
CreateRpc in makeContract fix
amaury1093 d2bb3c7
Fix getContract memoization
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix a lot of stuff
- Loading branch information
commit bb5509c623919087dd21c4fc296135c6271091c5
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2015-2018 Parity Technologies (UK) Ltd. | ||
| // This file is part of Parity. | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| import isObservable from '../utils/isObservable'; | ||
| import { resolveApi } from '../utils/testHelpers/mockApi'; | ||
| import rpc from './rpc'; | ||
| import { RpcKey, RpcMap, RpcObservable } from '../types'; | ||
| import { RPC_LOADING } from '../utils/isLoading'; | ||
| import { setApi } from '../api'; | ||
|
|
||
| /** | ||
| * Helper function to make basic tests for RpcObservables. | ||
| * | ||
| * @ignore | ||
| */ | ||
| const testRpc = (name: string, rpc$: RpcObservable<any, any>) => | ||
| describe(`${name} rpc`, () => { | ||
| beforeAll(() => { | ||
| setApi(resolveApi()); | ||
| }); | ||
|
|
||
| it('should be a function', () => { | ||
| expect(typeof rpc$).toBe('function'); | ||
| }); | ||
|
|
||
| it('function should return an Observable', () => { | ||
| expect(isObservable(rpc$())).toBe(true); | ||
| }); | ||
|
|
||
| it('function result Observable should be subscribable', () => { | ||
| expect(() => rpc$().subscribe()).not.toThrow(); | ||
| }); | ||
|
|
||
| it('function result Observable should return values', done => { | ||
| rpc$().subscribe(data => { | ||
| // The first value is either 'foo' (defined in mockApi), or the | ||
| // RPC_LOADING symbole. | ||
| // In the case of defaultAccount$ (which is accounts$[0]), the returned | ||
| // value is 'f'. TODO not clean. | ||
| expect(['foo', 'f', RPC_LOADING]).toContain(data); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| it('function should return the same Observable upon re-running (memoization)', () => { | ||
| const initial$ = rpc$(); | ||
| expect(rpc$()).toBe(initial$); | ||
| }); | ||
|
|
||
| it('function should not return the same Observable if options are passed', () => { | ||
| const initial$ = rpc$(); | ||
| expect(rpc$({ withoutLoading: true })).not.toBe(initial$); | ||
| }); | ||
|
|
||
| it('function should return the same Observable if same options are passed', () => { | ||
| const initial$ = rpc$({ withoutLoading: true }); | ||
| expect(rpc$({ withoutLoading: true })).toBe(initial$); | ||
| }); | ||
| }); | ||
|
|
||
| Object.keys(rpc).forEach(key => testRpc(key, (rpc as RpcMap)[key as RpcKey])); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 memoization here (see previous comments)