Skip to content

Commit

Permalink
added tests for convertToBase64 function
Browse files Browse the repository at this point in the history
  • Loading branch information
vaidic-dodwani committed Nov 21, 2023
1 parent f226d76 commit 49c6213
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.17.2"
connectivity_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1049,10 +1049,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.9.1"
mime:
dependency: transitive
description:
Expand All @@ -1065,7 +1065,7 @@ packages:
dependency: "direct main"
description:
name: mockito
ha256: "4b693867cee1853c9d1d7ecc1871f27f39b2ef2c13c0d8d8507dfe5bebd8aaf1"
sha256: "4b693867cee1853c9d1d7ecc1871f27f39b2ef2c13c0d8d8507dfe5bebd8aaf1"
url: "https://pub.dev"
source: hosted
version: "5.4.3"
Expand Down Expand Up @@ -1510,18 +1510,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.1"
stream_transform:
dependency: transitive
description:
Expand Down Expand Up @@ -1589,10 +1589,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.6.0"
timelines:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1773,10 +1773,10 @@ packages:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.1.4-beta"
web_socket_channel:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ void main() {
// );
verify(notifyListenerCallback());
});
test('convertToBase64 converts file to base64 string', () async {
final notifyListenerCallback = MockCallbackFunction();
final model = AddPostViewModel()..addListener(notifyListenerCallback);
model.initialise();
//using this asset as the test asset
final file = File('assets/images/Group 8948.png');
final fileString = await model.convertToBase64(file);
expect(model.imageInBase64, fileString);
verifyNever(notifyListenerCallback());
});

test(
'Check if convertToBase64 is working even if wrong file path is provided',
() async {
final notifyListenerCallback = MockCallbackFunction();
final model = AddPostViewModel()..addListener(notifyListenerCallback);
model.initialise();
final file = File('fakePath');
final fileString = await model.convertToBase64(file);
expect('', fileString);
verifyNever(notifyListenerCallback());
});

test("Check if remove_image method works correctly", () async {
final notifyListenerCallback = MockCallbackFunction();
final model = AddPostViewModel()..addListener(notifyListenerCallback);
Expand Down

0 comments on commit 49c6213

Please sign in to comment.