Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- 'android/**'
jobs:
buildios:
name: Build iOS
name: iOS build
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -27,7 +27,7 @@ jobs:
working-directory: ./
- run: flutter build ios --no-codesign
buildandroid:
name: Build Android
name: Android build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@

# Web related
lib/generated_plugin_registrant.dart

coverage/
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ before_script:
- chmod +x generate-apks.sh
script:
- ./flutter/bin/flutter build apk
- ./flutter/bin/flutter test --coverage
- bash <(curl -s https://codecov.io/bash)

after_success:
- ./generate-apks.sh
cache:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Cross-platform client for Mentorship System

| Branch | [Travis](https://travis-ci.org/) |
| :----------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------: |
| [develop](https://github.com/anitab-org/mentorship-flutter/tree/develop) | [![Build Status](https://travis-ci.com/anitab-org/mentorship-flutter.svg?branch=develop)](https://travis-ci.com/anitab-org/mentorship-flutter) |

| Branch | [Travis](https://travis-ci.org/) | Codecov |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [develop](https://github.com/anitab-org/mentorship-flutter/tree/develop) | [![Build Status](https://travis-ci.com/anitab-org/mentorship-flutter.svg?branch=develop)](https://travis-ci.com/anitab-org/mentorship-flutter) | [![codecov](https://codecov.io/gh/anitab-org/mentorship-flutter/branch/develop/graph/badge.svg)](https://codecov.io/gh/anitab-org/mentorship-flutter) |


Mentorship System is an application that allows women in tech to mentor each other, on career development topics, through 1:1 relations for a certain period of time.

Expand Down
12 changes: 12 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
comment:
layout: "diff, files"
behavior: new
require_changes: false # if true: only post the comment if coverage changes

coverage:
status:
project:
default:
target: auto # will use the coverage from the base commit
threshold: 0%
base: auto
3 changes: 1 addition & 2 deletions lib/screens/login/bloc/login_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:bloc/bloc.dart';
import 'package:mentorship_client/auth/auth_bloc.dart';
import 'package:mentorship_client/auth/bloc.dart';
import 'package:mentorship_client/failure.dart';
import 'package:mentorship_client/remote/repositories/auth_repository.dart';
import 'package:mentorship_client/screens/login/bloc/login_event.dart';
import 'package:mentorship_client/screens/login/bloc/login_state.dart';
Expand All @@ -23,7 +22,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
final token = await authRepository.login(event.login);
yield LoginSuccess();
authBloc.add(JustLoggedIn(token.token));
} on Failure catch (failure) {
} catch (failure) {
yield LoginFailure(failure.message);
Comment thread
techno-disaster marked this conversation as resolved.
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/login/bloc/login_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class LoginFailure extends LoginState {

@override
List<Object> get props => [message];
@override
String toString() => 'LoginFailure { error: $message }';
}
93 changes: 92 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
bloc_test:
dependency: "direct main"
description:
name: bloc_test
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -176,6 +183,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
coverage:
dependency: transitive
description:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -373,6 +387,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+3"
mockito:
dependency: transitive
description:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.1"
multi_server_socket:
dependency: transitive
description:
name: multi_server_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
nested:
dependency: transitive
description:
Expand All @@ -393,7 +421,14 @@ packages:
name: node_io
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1+2"
version: "1.1.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.12"
package_config:
dependency: transitive
description:
Expand Down Expand Up @@ -485,6 +520,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.5"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shelf_static:
dependency: transitive
description:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.8"
shelf_web_socket:
dependency: transitive
description:
Expand All @@ -504,6 +553,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.5"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
source_maps:
dependency: transitive
description:
name: source_maps
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.9"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -546,13 +609,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
test:
dependency: transitive
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.7"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.16"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.7"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -609,6 +686,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
vm_service:
dependency: transitive
description:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
watcher:
dependency: transitive
description:
Expand All @@ -623,6 +707,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.3"
xml:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies:
bloc: ^4.0.0
flutter_bloc: ^4.0.0
chopper: ^3.0.2

bloc_test: ^5.1.0
# plugins not needed in app
dev_dependencies:
build_runner: ^1.9.0
Expand Down
87 changes: 87 additions & 0 deletions test/auth_tests/authentication_bloc_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:mockito/mockito.dart';
import 'package:mentorship_client/remote/repositories/auth_repository.dart';
import 'package:mentorship_client/auth/bloc.dart';

class MockUserRepository extends Mock implements AuthRepository {}

void main() {
AuthBloc authenticationBloc;
MockUserRepository userRepository;

setUp(() {
userRepository = MockUserRepository();
authenticationBloc = AuthBloc(userRepository);
});

tearDown(() {
authenticationBloc?.close();
});

test('initial state is correct', () {
expect(authenticationBloc.initialState, AuthUninitialized());
});

test('close does not emit new states', () {
expectLater(
authenticationBloc,
emitsInOrder([AuthUninitialized(), emitsDone]),
);
authenticationBloc.close();
});

group('AppStarted', () {
test('emits [uninitialized, unauthenticated] for invalid token', () {
final expectedResponse = [
AuthUninitialized(),
AuthUnauthenticated(),
];

when(userRepository.getToken()).thenAnswer((_) => Future.value(null));

expectLater(
authenticationBloc,
emitsInOrder(expectedResponse),
);

authenticationBloc.add(AppStarted());
});
});
group('LoggedIn', () {
test('emits [uninitialized, loading, authenticated] when token is persisted', () {
final expectedResponse = [
AuthUninitialized(),
AuthInProgress(),
AuthAuthenticated(),
];

expectLater(
authenticationBloc,
emitsInOrder(expectedResponse),
);

authenticationBloc.add(JustLoggedIn(
'instance.token',
));
});
});
group('LoggedOut', () {
test('emits [uninitialized, loading, unauthenticated] when token is deleted', () {
final expectedResponse = [
AuthUninitialized(),
AuthInProgress(),
AuthUnauthenticated(
justLoggedOut: true,
),
];

expectLater(
authenticationBloc,
emitsInOrder(expectedResponse),
);

authenticationBloc.add(JustLoggedOut());
});
});
}
39 changes: 39 additions & 0 deletions test/auth_tests/authentication_event_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:mentorship_client/auth/bloc.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('AppStarted', () {
group('AppStarted', () {
test('props are []', () {
expect(AppStarted().props, []);
});

test('toString is "AppStarted"', () {
expect(AppStarted().toString(), 'AppStarted');
});
});

group('JustLoggedIn', () {
test('props are [token]', () {
expect(JustLoggedIn('token').props, ['token']);
});

test('toString is "LoggedIn { token: token }"', () {
expect(
JustLoggedIn('token').toString(),
'LoggedIn { token: token }',
);
});
});

group('JustLoggedOut', () {
test('props are []', () {
expect(JustLoggedOut().props, []);
});

test('toString is "AuthenticationLoggedOut"', () {
expect(JustLoggedOut().toString(), 'JustLoggedOut');
});
});
});
}
Loading