-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes specific errors like "too short" or "too long". Also, removes any error message when the token field is cleared. This change also streamlines some of the tests so we test multiple cases of different kinds of invalid tokens, but now each results in the same error. --- UDENG-5285
- Loading branch information
Showing
9 changed files
with
64 additions
and
81 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
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
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
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 |
---|---|---|
@@ -1,27 +1,21 @@ | ||
import 'package:dart_either/dart_either.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:ubuntupro/core/pro_token.dart'; | ||
import '../utils/token_samples.dart' as tks; | ||
|
||
void main() { | ||
test('token errors', () async { | ||
var token = ProToken.create(''); | ||
expect(token, const Left(TokenError.empty)); | ||
final proToken = ProToken.create(''); | ||
expect(proToken, const Left(TokenError.empty)); | ||
|
||
token = ProToken.create('ZmNb8uQn5zv'); | ||
expect(token, const Left(TokenError.tooShort)); | ||
|
||
token = ProToken.create('K2RYDcKfupxwXdWhSAxQPCeiULntKm63UXyx5MvEH2'); | ||
expect(token, const Left(TokenError.tooLong)); | ||
|
||
token = ProToken.create('K2RYDcKfupxwXdWhSAxQPCeiULntKm'); | ||
expect(token, const Left(TokenError.invalidPrefix)); | ||
|
||
token = ProToken.create('CK2RYDcKfupxwXdWhSAxQPCeiULntK'); | ||
expect(token, const Left(TokenError.invalidEncoding)); | ||
for (final token in tks.invalidTokens) { | ||
final proToken = ProToken.create(token); | ||
expect(proToken, const Left(TokenError.invalid)); | ||
} | ||
}); | ||
|
||
test('simulates a valid token', () async { | ||
final token = ProToken.create('CJd8MMN8wXSWsv7wJT8c8dDK'); | ||
expect(token.isRight, isTrue); | ||
final proToken = ProToken.create(tks.good); | ||
expect(proToken.isRight, isTrue); | ||
}); | ||
} |
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
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
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
5 changes: 0 additions & 5 deletions
5
gui/packages/ubuntupro/test/pages/subcribe_now/token_samples.dart
This file was deleted.
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,7 @@ | ||
const good = 'CJd8MMN8wXSWsv7wJT8c8dDK'; | ||
const invalidTokens = [ | ||
'CK2RYDcKfup', // too short | ||
'CK2RYDcKfupxwXdWhSAxQPCeiULntK63UXyx5MvEH2', // too long | ||
'K2RYDcKfupxwXdWhSAxQPCeiULntKm', // invalid prefix | ||
'CK2RYDcKfupxwXdWhSAxQPCeiULntK', // invalid encoding | ||
]; |