feat(llc): Add enrichUrl endpoint.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -3,10 +3,6 @@ import 'dart:convert';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat/src/core/api/general_api.dart';
|
||||
import 'package:stream_chat/src/core/api/requests.dart';
|
||||
import 'package:stream_chat/src/core/models/channel_model.dart';
|
||||
import 'package:stream_chat/src/core/models/event.dart';
|
||||
import 'package:stream_chat/src/core/models/filter.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -281,4 +277,39 @@ void main() {
|
||||
verifyNoMoreInteractions(client);
|
||||
});
|
||||
});
|
||||
|
||||
test('enrichUrl', () async {
|
||||
const path = '/og';
|
||||
const url =
|
||||
'https://www.techyourchance.com/finite-state-machine-with-unit-tests-real-world-example';
|
||||
|
||||
when(() => client.get(
|
||||
path,
|
||||
queryParameters: {'url': url},
|
||||
)).thenAnswer((_) async => successResponse(path, data: {
|
||||
'type': 'image',
|
||||
'og_scrape_url': url,
|
||||
'author_name': 'TechYourChance',
|
||||
'title': 'Finite State Machine with Unit Tests: Real World Example',
|
||||
}));
|
||||
|
||||
final res = await generalApi.enrichUrl(url);
|
||||
|
||||
expect(res, isNotNull);
|
||||
expect(res.type, 'image');
|
||||
expect(res.ogScrapeUrl, url);
|
||||
expect(res.authorName, 'TechYourChance');
|
||||
expect(
|
||||
res.title,
|
||||
'Finite State Machine with Unit Tests: Real World Example',
|
||||
);
|
||||
|
||||
verify(
|
||||
() => client.get(
|
||||
path,
|
||||
queryParameters: {'url': url},
|
||||
),
|
||||
).called(1);
|
||||
verifyNoMoreInteractions(client);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user