-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use streamingApiUrl to resolve streaming api
- Loading branch information
Showing
6 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
import { SerializerNodejsImpl } from '../serializers'; | ||
import { BaseHttp } from './base-http'; | ||
|
||
class Test extends BaseHttp { | ||
config = { | ||
url: 'https://mastodon.social', | ||
accessToken: 'token', | ||
}; | ||
request = jest.fn(); | ||
serializer = new SerializerNodejsImpl(); | ||
} | ||
|
||
describe('BaseHttp', () => { | ||
it('creates header', () => { | ||
const test = new Test(); | ||
expect(test.createHeader({ extra: 'header' })).toEqual({ | ||
Authorization: 'Bearer token', | ||
'Content-Type': 'application/json', | ||
extra: 'header', | ||
}); | ||
}); | ||
|
||
it('override content-type header', () => { | ||
const test = new Test(); | ||
expect( | ||
test.createHeader({ 'Content-Type': 'multipart/form-data' }), | ||
).toEqual({ | ||
Authorization: 'Bearer token', | ||
'Content-Type': 'multipart/form-data', | ||
}); | ||
}); | ||
|
||
it('resolves url', () => { | ||
const test = new Test(); | ||
expect(test.resolveUrl('/api/v1/yay')).toEqual( | ||
'https://mastodon.social/api/v1/yay', | ||
); | ||
}); | ||
|
||
it('resolves url with params', () => { | ||
const test = new Test(); | ||
expect(test.resolveUrl('/api/v1/yay', { query: true })).toEqual( | ||
'https://mastodon.social/api/v1/yay?query=true', | ||
); | ||
}); | ||
}); |
This file contains 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 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,34 @@ | ||
import { SerializerNodejsImpl } from '../serializers'; | ||
import { BaseWs } from './base-ws'; | ||
|
||
class Test extends BaseWs { | ||
baseUrl = 'wss://mastodon.social'; | ||
config = { | ||
url: 'https://mastodon.social', | ||
accessToken: 'token', | ||
}; | ||
serializer = new SerializerNodejsImpl(); | ||
version = '99.99.9'; | ||
stream = jest.fn(); | ||
} | ||
|
||
describe('BaseWs', () => { | ||
it('resolves url', () => { | ||
const test = new Test(); | ||
expect(test.resolveUrl('/api/v1/streaming/public')).toBe( | ||
'wss://mastodon.social/api/v1/streaming/public', | ||
); | ||
}); | ||
|
||
it('resolves url with params', () => { | ||
const test = new Test(); | ||
expect(test.resolveUrl('/api/v1/streaming/public', { public: true })).toBe( | ||
'wss://mastodon.social/api/v1/streaming/public?public=true', | ||
); | ||
}); | ||
|
||
it('resolves protocols', () => { | ||
const test = new Test(); | ||
expect(test.createProtocols()).toEqual(['token']); | ||
}); | ||
}); |
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './ws'; | ||
export * from './ws-impl'; | ||
export * from './ws-nodejs-impl'; | ||
export * from './ws-native-impl'; |
File renamed without changes.