This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add pre generation tests (#138)
- Loading branch information
Showing
2 changed files
with
176 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
import 'package:mason/mason.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../pre_gen.dart' as pre_gen; | ||
|
||
class _MockHookContext extends Mock implements HookContext {} | ||
|
||
void main() { | ||
group('pre_gen', () { | ||
late HookContext context; | ||
|
||
setUp(() { | ||
context = _MockHookContext(); | ||
}); | ||
|
||
group('android variable', () { | ||
const androidVariable = 'android'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [androidVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[androidVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[androidVariable], isFalse); | ||
}); | ||
}); | ||
|
||
group('ios variable', () { | ||
const iosVariable = 'ios'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [iosVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[iosVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[iosVariable], isFalse); | ||
}); | ||
}); | ||
|
||
group('macos variable', () { | ||
const macOsVariable = 'macos'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [macOsVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[macOsVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[macOsVariable], isFalse); | ||
}); | ||
}); | ||
|
||
group('linux variable', () { | ||
const linuxVariable = 'linux'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [linuxVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[linuxVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[linuxVariable], isFalse); | ||
}); | ||
}); | ||
|
||
group('web variable', () { | ||
const webVariable = 'web'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [webVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[webVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[webVariable], isFalse); | ||
}); | ||
}); | ||
|
||
group('windows variable', () { | ||
const windowsVariable = 'windows'; | ||
|
||
test('is set to true if it is in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': [windowsVariable], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[windowsVariable], isTrue); | ||
}); | ||
|
||
test('is set to false if it is not in `platforms` variable', () { | ||
final vars = <String, dynamic>{ | ||
'platforms': <String>[], | ||
}; | ||
when(() => context.vars).thenReturn(vars); | ||
|
||
pre_gen.run(context); | ||
|
||
expect(vars[windowsVariable], isFalse); | ||
}); | ||
}); | ||
}); | ||
} |