chore: integrate misskey-js as a workspace item
This commit is contained in:
		
							
								
								
									
										45
									
								
								packages/misskey-js/test-d/api.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								packages/misskey-js/test-d/api.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
import { expectType } from 'tsd';
 | 
			
		||||
import * as Misskey from '../src';
 | 
			
		||||
 | 
			
		||||
describe('API', () => {
 | 
			
		||||
	test('success', async () => {
 | 
			
		||||
		const cli = new Misskey.api.APIClient({
 | 
			
		||||
			origin: 'https://misskey.test',
 | 
			
		||||
			credential: 'TOKEN'
 | 
			
		||||
		});
 | 
			
		||||
		const res = await cli.request('meta', { detail: true });
 | 
			
		||||
		expectType<Misskey.entities.DetailedInstanceMetadata>(res);
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	test('conditional respose type (meta)', async () => {
 | 
			
		||||
		const cli = new Misskey.api.APIClient({
 | 
			
		||||
			origin: 'https://misskey.test',
 | 
			
		||||
			credential: 'TOKEN'
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		const res = await cli.request('meta', { detail: true });
 | 
			
		||||
		expectType<Misskey.entities.DetailedInstanceMetadata>(res);
 | 
			
		||||
 | 
			
		||||
		const res2 = await cli.request('meta', { detail: false });
 | 
			
		||||
		expectType<Misskey.entities.LiteInstanceMetadata>(res2);
 | 
			
		||||
 | 
			
		||||
		const res3 = await cli.request('meta', { });
 | 
			
		||||
		expectType<Misskey.entities.LiteInstanceMetadata>(res3);
 | 
			
		||||
 | 
			
		||||
		const res4 = await cli.request('meta', { detail: true as boolean });
 | 
			
		||||
		expectType<Misskey.entities.LiteInstanceMetadata | Misskey.entities.DetailedInstanceMetadata>(res4);
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	test('conditional respose type (users/show)', async () => {
 | 
			
		||||
		const cli = new Misskey.api.APIClient({
 | 
			
		||||
			origin: 'https://misskey.test',
 | 
			
		||||
			credential: 'TOKEN'
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		const res = await cli.request('users/show', { userId: 'xxxxxxxx' });
 | 
			
		||||
		expectType<Misskey.entities.UserDetailed>(res);
 | 
			
		||||
 | 
			
		||||
		const res2 = await cli.request('users/show', { userIds: ['xxxxxxxx'] });
 | 
			
		||||
		expectType<Misskey.entities.UserDetailed[]>(res2);
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										26
									
								
								packages/misskey-js/test-d/streaming.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/misskey-js/test-d/streaming.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import { expectType } from 'tsd';
 | 
			
		||||
import * as Misskey from '../src';
 | 
			
		||||
 | 
			
		||||
describe('Streaming', () => {
 | 
			
		||||
	test('emit type', async () => {
 | 
			
		||||
		const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
 | 
			
		||||
		const mainChannel = stream.useChannel('main');
 | 
			
		||||
		mainChannel.on('notification', notification => {
 | 
			
		||||
			expectType<Misskey.entities.Notification>(notification);
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	test('params type', async () => {
 | 
			
		||||
		const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
 | 
			
		||||
		// TODO: 「stream.useChannel の第二引数として受け入れる型が
 | 
			
		||||
		// {
 | 
			
		||||
		//   otherparty?: User['id'] | null;
 | 
			
		||||
		//   group?: UserGroup['id'] | null;
 | 
			
		||||
		// } 
 | 
			
		||||
		// になっている」というテストを行いたいけどtsdでの書き方がわからない
 | 
			
		||||
		const messagingChannel = stream.useChannel('messaging', { otherparty: 'aaa' });
 | 
			
		||||
		messagingChannel.on('message', message => {
 | 
			
		||||
			expectType<Misskey.entities.MessagingMessage>(message);
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user