Jonatas

split tests

Showing 31 changed files with 302 additions and 149 deletions
@@ -4,12 +4,12 @@ name: build @@ -4,12 +4,12 @@ name: build
4 on: 4 on:
5 push: 5 push:
6 paths: 6 paths:
7 - - "getx/**" 7 + - "/**"
8 - ".github/workflows/main.yaml" 8 - ".github/workflows/main.yaml"
9 9
10 pull_request: 10 pull_request:
11 paths: 11 paths:
12 - - "getx/**" 12 + - "/**"
13 - ".github/workflows/main.yaml" 13 - ".github/workflows/main.yaml"
14 #A workflow run is made up of one or more jobs. Jobs run in parallel by default. 14 #A workflow run is made up of one or more jobs. Jobs run in parallel by default.
15 jobs: 15 jobs:
@@ -4,19 +4,22 @@ name: build @@ -4,19 +4,22 @@ name: build
4 on: 4 on:
5 push: 5 push:
6 paths: 6 paths:
7 - - "packages/get_core/**"  
8 - - ".github/workflows/packages.yaml" 7 + - "/**"
  8 + - ".github/workflows/get_instance.yaml"
9 9
10 pull_request: 10 pull_request:
11 paths: 11 paths:
12 - - "packages/get_core/**"  
13 - - ".github/workflows/packages.yaml" 12 + - "/**"
  13 + - ".github/workflows/get_instance.yaml"
14 #A workflow run is made up of one or more jobs. Jobs run in parallel by default. 14 #A workflow run is made up of one or more jobs. Jobs run in parallel by default.
15 jobs: 15 jobs:
16 16
17 test: 17 test:
18 #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted] 18 #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
19 - runs-on: macos-latest 19 + defaults:
  20 + run:
  21 + working-directory: packages/get_instance
  22 + runs-on: ubuntu-latest
20 #sequence of tasks called 23 #sequence of tasks called
21 steps: 24 steps:
22 # The branch or tag ref that triggered the workflow will be checked out. 25 # The branch or tag ref that triggered the workflow will be checked out.
  1 +#The name of your workflow.
  2 +name: build
  3 +# Trigger the workflow on push or pull request
  4 +on:
  5 + push:
  6 + paths:
  7 + - "/**"
  8 + - ".github/workflows/get_navigation.yaml"
  9 +
  10 + pull_request:
  11 + paths:
  12 + - "/**"
  13 + - ".github/workflows/get_navigation.yaml"
  14 +#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
  15 +jobs:
  16 +
  17 + test:
  18 + #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
  19 + defaults:
  20 + run:
  21 + working-directory: packages/get_navigation
  22 + runs-on: ubuntu-latest
  23 + #sequence of tasks called
  24 + steps:
  25 + # The branch or tag ref that triggered the workflow will be checked out.
  26 + # https://github.com/actions/checkout
  27 + - uses: actions/checkout@v1
  28 + # Setup a flutter environment.
  29 + # https://github.com/marketplace/actions/flutter-action
  30 + - uses: subosito/flutter-action@v1
  31 + with:
  32 + flutter-version: '1.20.4'
  33 + channel: 'stable'
  34 + - run: flutter pub get
  35 + #- run: flutter analyze
  36 + # run flutter widgets tests and unit tests
  37 + - run: flutter test --coverage
  38 + # Upload coverage reports to Codecov
  39 + # https://github.com/marketplace/actions/codecov
  40 + - uses: codecov/codecov-action@v1.0.7
  41 +
  1 +#The name of your workflow.
  2 +name: build
  3 +# Trigger the workflow on push or pull request
  4 +on:
  5 + push:
  6 + paths:
  7 + - "/**"
  8 + - ".github/workflows/get_rx.yaml"
  9 +
  10 + pull_request:
  11 + paths:
  12 + - "/**"
  13 + - ".github/workflows/get_rx.yaml"
  14 +#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
  15 +jobs:
  16 +
  17 + test:
  18 + #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
  19 + defaults:
  20 + run:
  21 + working-directory: packages/get_rx
  22 + runs-on: ubuntu-latest
  23 + #sequence of tasks called
  24 + steps:
  25 + # The branch or tag ref that triggered the workflow will be checked out.
  26 + # https://github.com/actions/checkout
  27 + - uses: actions/checkout@v1
  28 + # Setup a flutter environment.
  29 + # https://github.com/marketplace/actions/flutter-action
  30 + - uses: subosito/flutter-action@v1
  31 + with:
  32 + flutter-version: '1.20.4'
  33 + channel: 'stable'
  34 + - run: flutter pub get
  35 + #- run: flutter analyze
  36 + # run flutter widgets tests and unit tests
  37 + - run: flutter test --coverage
  38 + # Upload coverage reports to Codecov
  39 + # https://github.com/marketplace/actions/codecov
  40 + - uses: codecov/codecov-action@v1.0.7
  41 +
  1 +#The name of your workflow.
  2 +name: build
  3 +# Trigger the workflow on push or pull request
  4 +on:
  5 + push:
  6 + paths:
  7 + - "/**"
  8 + - ".github/workflows/get_state_manager.yaml"
  9 +
  10 + pull_request:
  11 + paths:
  12 + - "/**"
  13 + - ".github/workflows/get_state_manager.yaml"
  14 +#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
  15 +jobs:
  16 +
  17 + test:
  18 + #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
  19 + defaults:
  20 + run:
  21 + working-directory: packages/get_state_manager
  22 + runs-on: ubuntu-latest
  23 + #sequence of tasks called
  24 + steps:
  25 + # The branch or tag ref that triggered the workflow will be checked out.
  26 + # https://github.com/actions/checkout
  27 + - uses: actions/checkout@v1
  28 + # Setup a flutter environment.
  29 + # https://github.com/marketplace/actions/flutter-action
  30 + - uses: subosito/flutter-action@v1
  31 + with:
  32 + flutter-version: '1.20.4'
  33 + channel: 'stable'
  34 + - run: flutter pub get
  35 + #- run: flutter analyze
  36 + # run flutter widgets tests and unit tests
  37 + - run: flutter test --coverage
  38 + # Upload coverage reports to Codecov
  39 + # https://github.com/marketplace/actions/codecov
  40 + - uses: codecov/codecov-action@v1.0.7
  41 +
  1 +#The name of your workflow.
  2 +name: build
  3 +# Trigger the workflow on push or pull request
  4 +on:
  5 + push:
  6 + paths:
  7 + - "/**"
  8 + - ".github/workflows/get_utils.yaml"
  9 +
  10 + pull_request:
  11 + paths:
  12 + - "/**"
  13 + - ".github/workflows/get_utils.yaml"
  14 +#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
  15 +jobs:
  16 +
  17 + test:
  18 + #The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
  19 + defaults:
  20 + run:
  21 + working-directory: packages/get_utils
  22 + runs-on: ubuntu-latest
  23 + #sequence of tasks called
  24 + steps:
  25 + # The branch or tag ref that triggered the workflow will be checked out.
  26 + # https://github.com/actions/checkout
  27 + - uses: actions/checkout@v1
  28 + # Setup a flutter environment.
  29 + # https://github.com/marketplace/actions/flutter-action
  30 + - uses: subosito/flutter-action@v1
  31 + with:
  32 + flutter-version: '1.20.4'
  33 + channel: 'stable'
  34 + - run: flutter pub get
  35 + #- run: flutter analyze
  36 + # run flutter widgets tests and unit tests
  37 + - run: flutter test --coverage
  38 + # Upload coverage reports to Codecov
  39 + # https://github.com/marketplace/actions/codecov
  40 + - uses: codecov/codecov-action@v1.0.7
  41 +
1 -import 'package:flutter_test/flutter_test.dart';  
2 -import 'package:get/get.dart';  
3 -  
4 -import 'util/matcher.dart';  
5 -  
6 -class Mock {  
7 - static Future<String> test() async {  
8 - await Future.delayed(Duration.zero);  
9 - return 'test';  
10 - }  
11 -}  
12 -  
13 -class Controller {}  
14 -  
15 -class DisposableController extends DisposableInterface {  
16 - bool initialized = false;  
17 -  
18 - void onInit() async {  
19 - initialized = true;  
20 - }  
21 -}  
22 -  
23 -// ignore: one_member_abstracts  
24 -abstract class Service {  
25 - String post();  
26 -}  
27 -  
28 -class Api implements Service {  
29 - @override  
30 - String post() {  
31 - return 'test';  
32 - }  
33 -}  
34 -  
35 -void main() {  
36 - test('Get.putAsync test', () async {  
37 - await Get.putAsync<String>(Mock.test);  
38 - expect('test', Get.find<String>());  
39 - Get.reset();  
40 - });  
41 -  
42 - test('Get.put test', () async {  
43 - final instance = Get.put<Controller>(Controller());  
44 - expect(instance, Get.find<Controller>());  
45 - Get.reset();  
46 - });  
47 -  
48 - test('Get.lazyPut test', () async {  
49 - final controller = Controller();  
50 - Get.lazyPut<Controller>(() => controller);  
51 - final ct1 = Get.find<Controller>();  
52 - expect(ct1, controller);  
53 - Get.reset();  
54 - });  
55 -  
56 - test('Get.lazyPut with abstract class test', () async {  
57 - final api = Api();  
58 - Get.lazyPut<Service>(() => api);  
59 - final ct1 = Get.find<Service>();  
60 - expect(ct1, api);  
61 - Get.reset();  
62 - });  
63 -  
64 - test('Get.create with abstract class test', () async {  
65 - Get.create<Service>(() => Api());  
66 - final ct1 = Get.find<Service>();  
67 - final ct2 = Get.find<Service>();  
68 - expect(ct1 is Service, true);  
69 - expect(ct2 is Service, true);  
70 - expect(ct1 == ct2, false);  
71 - Get.reset();  
72 - });  
73 -  
74 - group('test put, delete and check onInit execution', () {  
75 - tearDownAll(Get.reset);  
76 -  
77 - test('Get.put test with init check', () async {  
78 - final instance = Get.put<DisposableController>(DisposableController());  
79 - expect(instance, Get.find<DisposableController>());  
80 - expect(instance.initialized, true);  
81 - });  
82 -  
83 - test('Get.delete test with disposable controller', () async {  
84 - expect(await Get.delete<DisposableController>(), true);  
85 - expect(() => Get.find<DisposableController>(),  
86 - throwsA(TypeMatcher<String>()));  
87 - });  
88 -  
89 - test('Get.put test after delete with disposable controller and init check',  
90 - () async {  
91 - final instance = Get.put<DisposableController>(DisposableController());  
92 - expect(instance, Get.find<DisposableController>());  
93 - expect(instance.initialized, true);  
94 - });  
95 - });  
96 -}  
1 -void main() {  
2 - // testWidgets("Get.dialog close test", (tester) async {  
3 - // await tester.pumpWidget(  
4 - // Wrapper(child: Container()),  
5 - // );  
6 -  
7 - // expect(Get.isDarkMode, false);  
8 - // Get.changeTheme(ThemeData.dark());  
9 - // await Future.delayed(Duration.zero);  
10 - // expect(Get.isDarkMode, true);  
11 - // await tester.pumpAndSettle();  
12 - // });  
13 -}  
@@ -12,7 +12,9 @@ dependencies: @@ -12,7 +12,9 @@ dependencies:
12 get_core: 12 get_core:
13 path: ../get_core 13 path: ../get_core
14 14
  15 +
15 dev_dependencies: 16 dev_dependencies:
  17 + test: ">=1.0.0 <2.0.0"
16 18
17 19
18 # For information on the generic Dart part of this file, see the 20 # For information on the generic Dart part of this file, see the
1 -void main() {} 1 +import 'package:get_instance/get_instance.dart';
  2 +import 'package:test/test.dart';
  3 +import 'package:get_core/get_core.dart';
  4 +import 'util/matcher.dart' as m;
  5 +
  6 +class Mock {
  7 + static Future<String> test() async {
  8 + await Future.delayed(Duration.zero);
  9 + return 'test';
  10 + }
  11 +}
  12 +
  13 +class Controller {}
  14 +
  15 +class DisposableController extends GetLifeCycle {
  16 + bool initialized = false;
  17 +
  18 + void onInit() async {
  19 + initialized = true;
  20 + }
  21 +}
  22 +
  23 +// ignore: one_member_abstracts
  24 +abstract class Service {
  25 + String post();
  26 +}
  27 +
  28 +class Api implements Service {
  29 + @override
  30 + String post() {
  31 + return 'test';
  32 + }
  33 +}
  34 +
  35 +void main() {
  36 + test('Get.putAsync test', () async {
  37 + await Get.putAsync<String>(Mock.test);
  38 + expect('test', Get.find<String>());
  39 + Get.reset();
  40 + });
  41 +
  42 + test('Get.put test', () async {
  43 + final instance = Get.put<Controller>(Controller());
  44 + expect(instance, Get.find<Controller>());
  45 + Get.reset();
  46 + });
  47 +
  48 + test('Get.lazyPut test', () async {
  49 + final controller = Controller();
  50 + Get.lazyPut<Controller>(() => controller);
  51 + final ct1 = Get.find<Controller>();
  52 + expect(ct1, controller);
  53 + Get.reset();
  54 + });
  55 +
  56 + test('Get.lazyPut with abstract class test', () async {
  57 + final api = Api();
  58 + Get.lazyPut<Service>(() => api);
  59 + final ct1 = Get.find<Service>();
  60 + expect(ct1, api);
  61 + Get.reset();
  62 + });
  63 +
  64 + test('Get.create with abstract class test', () async {
  65 + Get.create<Service>(() => Api());
  66 + final ct1 = Get.find<Service>();
  67 + final ct2 = Get.find<Service>();
  68 + expect(ct1 is Service, true);
  69 + expect(ct2 is Service, true);
  70 + expect(ct1 == ct2, false);
  71 + Get.reset();
  72 + });
  73 +
  74 + group('test put, delete and check onInit execution', () {
  75 + tearDownAll(Get.reset);
  76 +
  77 + test('Get.put test with init check', () async {
  78 + final instance = Get.put<DisposableController>(DisposableController());
  79 + expect(instance, Get.find<DisposableController>());
  80 + expect(instance.initialized, true);
  81 + });
  82 +
  83 + test('Get.delete test with disposable controller', () async {
  84 + expect(await Get.delete<DisposableController>(), true);
  85 + expect(() => Get.find<DisposableController>(),
  86 + throwsA(m.TypeMatcher<String>()));
  87 + });
  88 +
  89 + test('Get.put test after delete with disposable controller and init check',
  90 + () async {
  91 + final instance = Get.put<DisposableController>(DisposableController());
  92 + expect(instance, Get.find<DisposableController>());
  93 + expect(instance.initialized, true);
  94 + });
  95 + });
  96 +}
1 -import 'package:flutter_test/flutter_test.dart'; 1 +import 'package:test/test.dart';
2 2
3 // Copyright 2014, the Dart project authors. All rights reserved. 3 // Copyright 2014, the Dart project authors. All rights reserved.
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
1 library get_navigation; 1 library get_navigation;
2 2
  3 +export 'package:get_core/get_core.dart';
3 export 'src/bottomsheet/bottomsheet.dart'; 4 export 'src/bottomsheet/bottomsheet.dart';
4 export 'src/extension_navigation.dart'; 5 export 'src/extension_navigation.dart';
5 export 'src/root/root_widget.dart'; 6 export 'src/root/root_widget.dart';
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart';  
4 -  
5 -import 'util/wrapper.dart'; 3 +import 'package:get_navigation/get_navigation.dart';
  4 +import 'utils/wrapper.dart';
6 5
7 void main() { 6 void main() {
8 testWidgets("Get.bottomSheet smoke test", (tester) async { 7 testWidgets("Get.bottomSheet smoke test", (tester) async {
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart';  
4 -  
5 -import 'util/wrapper.dart'; 3 +import 'package:get_navigation/get_navigation.dart';
  4 +import 'utils/wrapper.dart';
6 5
7 void main() { 6 void main() {
8 testWidgets("Get.defaultDialog smoke test", (tester) async { 7 testWidgets("Get.defaultDialog smoke test", (tester) async {
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_core/get_core.dart';
  4 +import 'package:get_navigation/get_navigation.dart';
4 5
5 -import 'util/wrapper.dart'; 6 +import 'utils/wrapper.dart';
6 7
7 class SizeTransitions extends CustomTransition { 8 class SizeTransitions extends CustomTransition {
8 @override 9 @override
1 -import 'package:flutter_test/flutter_test.dart';  
2 -  
3 -void main() {  
4 - test('adds one to input values', () {});  
5 -}  
1 import 'package:flutter_test/flutter_test.dart'; 1 import 'package:flutter_test/flutter_test.dart';
2 -import 'package:get/get.dart'; 2 +import 'package:get_navigation/get_navigation.dart';
3 3
4 void main() { 4 void main() {
5 testWidgets( 5 testWidgets(
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_navigation/get_navigation.dart';
4 4
5 void main() { 5 void main() {
6 testWidgets( 6 testWidgets(
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 -import 'package:get/get.dart'; 2 +import 'package:get_navigation/get_navigation.dart';
3 3
4 class Wrapper extends StatelessWidget { 4 class Wrapper extends StatelessWidget {
5 final Widget child; 5 final Widget child;
@@ -17,4 +17,5 @@ dependencies: @@ -17,4 +17,5 @@ dependencies:
17 17
18 18
19 dev_dependencies: 19 dev_dependencies:
  20 + test: ">=1.0.0 <2.0.0"
20   21  
1 -import 'package:flutter_test/flutter_test.dart';  
2 -import 'package:get/get.dart'; 1 +import 'package:get_rx/get_rx.dart';
  2 +import 'package:test/test.dart';
3 3
4 void main() { 4 void main() {
5 test('once', () async { 5 test('once', () async {
1 library get_state_manager; 1 library get_state_manager;
2 2
3 export 'package:get_instance/get_instance.dart'; 3 export 'package:get_instance/get_instance.dart';
  4 +export 'package:get_rx/get_rx.dart';
4 export 'src/rx_flutter/rx_disposable.dart'; 5 export 'src/rx_flutter/rx_disposable.dart';
5 export 'src/rx_flutter/rx_getx_widget.dart'; 6 export 'src/rx_flutter/rx_getx_widget.dart';
6 export 'src/rx_flutter/rx_obx_widget.dart'; 7 export 'src/rx_flutter/rx_obx_widget.dart';
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_core/get_core.dart';
  4 +import 'package:get_instance/get_instance.dart';
  5 +import 'package:get_state_manager/get_state_manager.dart';
4 6
5 void main() { 7 void main() {
6 testWidgets("MixinBuilder smoke test", (tester) async { 8 testWidgets("MixinBuilder smoke test", (tester) async {
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_core/get_core.dart';
  4 +import 'package:get_instance/get_instance.dart';
  5 +import 'package:get_state_manager/get_state_manager.dart';
4 6
5 void main() { 7 void main() {
6 final controller = Get.put(Controller()); 8 final controller = Get.put(Controller());
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_core/get_core.dart';
  4 +import 'package:get_instance/get_instance.dart';
  5 +import 'package:get_state_manager/get_state_manager.dart';
4 6
5 void main() { 7 void main() {
6 Get.lazyPut<Controller2>(() => Controller2()); 8 Get.lazyPut<Controller2>(() => Controller2());
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart'; 2 import 'package:flutter_test/flutter_test.dart';
3 -import 'package:get/get.dart'; 3 +import 'package:get_core/get_core.dart';
  4 +import 'package:get_instance/get_instance.dart';
  5 +import 'package:get_state_manager/get_state_manager.dart';
4 6
5 void main() { 7 void main() {
6 Get.lazyPut<Controller2>(() => Controller2()); 8 Get.lazyPut<Controller2>(() => Controller2());
1 -import 'package:flutter_test/flutter_test.dart';  
2 -  
3 -void main() {  
4 - test('adds one to input values', () {});  
5 -}  
1 @TestOn('vm') 1 @TestOn('vm')
2 import 'dart:io'; 2 import 'dart:io';
3 import 'package:flutter_test/flutter_test.dart'; 3 import 'package:flutter_test/flutter_test.dart';
4 -import 'package:get/get.dart'; 4 +import 'package:get_utils/get_utils.dart';
5 5
6 void main() { 6 void main() {
7 test('Platform test', () { 7 test('Platform test', () {
1 @TestOn('browser') 1 @TestOn('browser')
2 import 'dart:io'; 2 import 'dart:io';
3 import 'package:flutter_test/flutter_test.dart'; 3 import 'package:flutter_test/flutter_test.dart';
4 -import 'package:get/get.dart'; 4 +import 'package:get_utils/get_utils.dart';
5 5
6 void main() { 6 void main() {
7 test('Platform test', () { 7 test('Platform test', () {