forked from luiscib3r/todo
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luis Ciber
committed
Aug 21, 2021
1 parent
6ca1357
commit f35b984
Showing
10 changed files
with
326 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
on: [push, pull_request, workflow_dispatch] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Action | ||
uses: actions/checkout@v2 | ||
- name: Setup Java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: '12.x' | ||
- name: Setup Flutter | ||
uses: subosito/flutter-action@v1 | ||
with: | ||
channel: 'stable' | ||
- name: Run Tests | ||
run: | | ||
flutter pub get | ||
flutter test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:todo/app/app.dart'; | ||
|
||
String fixture(String name) => File('test/fixtures/$name').readAsStringSync(); | ||
|
||
String fixtureUssdCodes() => File('config/ussd_codes.json').readAsStringSync(); | ||
|
||
List<UssdItem> fixtureUssdCodesAsListUssdItem() { | ||
final jsonString = File('config/ussd_codes.json').readAsStringSync(); | ||
final parsedJson = json.decode(jsonString) as Map<String, dynamic>; | ||
|
||
parsedJson['name'] = ''; | ||
parsedJson['description'] = ''; | ||
parsedJson['icon'] = ''; | ||
parsedJson['type'] = 'category'; | ||
|
||
return UssdCategory.fromJson(parsedJson).items; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "Adelantar Saldo", | ||
"description": "Recarga con un adelanto de saldo", | ||
"icon": "monetization_on", | ||
"type": "category", | ||
"items": [ | ||
{ | ||
"name": "25 CUP", | ||
"description": "Adelanta con $1.00 CUC de saldo", | ||
"icon": "monetization_on", | ||
"type": "code", | ||
"fields": [], | ||
"code": "*234*3*1*1#" | ||
}, | ||
{ | ||
"name": "50 CUP", | ||
"description": "Adelanta con $2.00 CUC de saldo", | ||
"icon": "monetization_on", | ||
"type": "code", | ||
"fields": [], | ||
"code": "*234*3*1*2#" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Transferir Saldo", | ||
"description": "Transfiere tu saldo", | ||
"icon": "mobile_screen_share", | ||
"type": "code", | ||
"fields": [ | ||
{ | ||
"name": "telefono", | ||
"type": "phone_number" | ||
}, | ||
{ | ||
"name": "cantidad", | ||
"type": "money" | ||
}, | ||
{ | ||
"name": "clave", | ||
"type": "key_number" | ||
} | ||
], | ||
"code": "*234*1*{telefono}*{clave}*{cantidad}#" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "telefono", | ||
"type": "phone_number" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:todo/app/app.dart'; | ||
|
||
import '../../fixtures/fixture_reader.dart'; | ||
|
||
void main() { | ||
final tUssdCategoryModel = UssdCategory( | ||
name: 'Adelantar Saldo', | ||
description: 'Recarga con un adelanto de saldo', | ||
icon: 'monetization_on', | ||
type: 'category', | ||
items: [ | ||
UssdCode.fromJson(const { | ||
'name': '25 CUP', | ||
'description': r'Adelanta con $1.00 CUC de saldo', | ||
'icon': 'monetization_on', | ||
'type': 'code', | ||
'fields': [], | ||
'code': '*234*3*1*1#' | ||
}), | ||
UssdCode.fromJson(const { | ||
'name': '50 CUP', | ||
'description': r'Adelanta con $2.00 CUC de saldo', | ||
'icon': 'monetization_on', | ||
'type': 'code', | ||
'fields': [], | ||
'code': '*234*3*1*2#' | ||
}) | ||
], | ||
); | ||
|
||
group( | ||
'+ fromJson"\n ', | ||
() { | ||
test( | ||
'- Should return a valid model from JSON', | ||
() { | ||
// arrange | ||
final jsonMap = json.decode(fixture('ussd_category.json')) | ||
as Map<String, dynamic>; | ||
|
||
// act | ||
final result = UssdCategory.fromJson(jsonMap); | ||
|
||
// assert | ||
expect(result, tUssdCategoryModel); | ||
}, | ||
); | ||
}, | ||
); | ||
|
||
group( | ||
'toJson', | ||
() { | ||
test( | ||
'Should return a JSON map containing the poper data', | ||
() { | ||
// act | ||
final result = tUssdCategoryModel.toJson(); | ||
|
||
final expectedMap = { | ||
'name': 'Adelantar Saldo', | ||
'description': 'Recarga con un adelanto de saldo', | ||
'icon': 'monetization_on', | ||
'type': 'category', | ||
'items': [ | ||
{ | ||
'name': '25 CUP', | ||
'description': r'Adelanta con $1.00 CUC de saldo', | ||
'icon': 'monetization_on', | ||
'type': 'code', | ||
'fields': [], | ||
'code': '*234*3*1*1#' | ||
}, | ||
{ | ||
'name': '50 CUP', | ||
'description': r'Adelanta con $2.00 CUC de saldo', | ||
'icon': 'monetization_on', | ||
'type': 'code', | ||
'fields': [], | ||
'code': '*234*3*1*2#' | ||
} | ||
] | ||
}; | ||
|
||
// assert | ||
expect(result, expectedMap); | ||
}, | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:todo/app/app.dart'; | ||
|
||
import '../../fixtures/fixture_reader.dart'; | ||
|
||
void main() { | ||
const tUssdCodeFieldModel = UssdCodeField( | ||
name: 'telefono', | ||
type: 'phone_number', | ||
); | ||
|
||
group( | ||
'+ fromJson"\n ', | ||
() { | ||
test( | ||
'- Should return a valid model from JSON', | ||
() { | ||
// arrange | ||
final jsonMap = json.decode( | ||
fixture('ussd_code_field.json'), | ||
) as Map<String, dynamic>; | ||
|
||
// act | ||
final result = UssdCodeField.fromJson(jsonMap); | ||
|
||
// assert | ||
expect(result, tUssdCodeFieldModel); | ||
}, | ||
); | ||
}, | ||
); | ||
|
||
group( | ||
'toJson', | ||
() { | ||
test( | ||
'Should return a JSON map containing the poper data', | ||
() { | ||
// act | ||
final result = tUssdCodeFieldModel.toJson(); | ||
|
||
final expectedMap = { | ||
'name': 'telefono', | ||
'type': 'phone_number', | ||
}; | ||
|
||
// assert | ||
expect(result, expectedMap); | ||
}, | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:todo/app/app.dart'; | ||
|
||
import '../../fixtures/fixture_reader.dart'; | ||
|
||
void main() { | ||
const tUssdCodeModel = UssdCode( | ||
name: 'Transferir Saldo', | ||
description: 'Transfiere tu saldo', | ||
icon: 'mobile_screen_share', | ||
type: 'code', | ||
code: '*234*1*{telefono}*{clave}*{cantidad}#', | ||
fields: [ | ||
UssdCodeField( | ||
name: 'telefono', | ||
type: 'phone_number', | ||
), | ||
UssdCodeField( | ||
name: 'cantidad', | ||
type: 'money', | ||
), | ||
UssdCodeField( | ||
name: 'clave', | ||
type: 'key_number', | ||
) | ||
], | ||
); | ||
|
||
group( | ||
'+ fromJson"\n ', | ||
() { | ||
test( | ||
'- Should return a valid model from JSON', | ||
() { | ||
// arrange | ||
final jsonMap = json.decode( | ||
fixture('ussd_code.json'), | ||
) as Map<String, dynamic>; | ||
|
||
// act | ||
final result = UssdCode.fromJson(jsonMap); | ||
|
||
// assert | ||
expect(result, tUssdCodeModel); | ||
}, | ||
); | ||
}, | ||
); | ||
|
||
group( | ||
'toJson', | ||
() { | ||
test( | ||
'Should return a JSON map containing the poper data', | ||
() { | ||
// act | ||
final result = tUssdCodeModel.toJson(); | ||
|
||
final expectedMap = { | ||
'name': 'Transferir Saldo', | ||
'description': 'Transfiere tu saldo', | ||
'icon': 'mobile_screen_share', | ||
'type': 'code', | ||
'fields': [ | ||
{'name': 'telefono', 'type': 'phone_number'}, | ||
{'name': 'cantidad', 'type': 'money'}, | ||
{'name': 'clave', 'type': 'key_number'} | ||
], | ||
'code': '*234*1*{telefono}*{clave}*{cantidad}#' | ||
}; | ||
|
||
// assert | ||
expect(result, expectedMap); | ||
}, | ||
); | ||
}, | ||
); | ||
} |