-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the package name is now created correctly even when no
--path
…
…flag is passed (#151) * test: added test that works with figmage.yaml * fix: the package name is now created correctly even when no `--path` flag is passed * ci: also run full_integration_test in CI
- Loading branch information
1 parent
094b71f
commit fed21d7
Showing
8 changed files
with
106 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ jobs: | |
if: contains(github.event.head_commit.message, 'chore(release)') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: dart-lang/[email protected] | ||
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | ||
with: | ||
|
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
fetch-depth: 0 | ||
- uses: dart-lang/[email protected] | ||
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa | ||
with: | ||
|
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,86 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('Full integration test', () { | ||
setUp(() {}); | ||
|
||
test('prints help to console', () async { | ||
final process = await Process.start( | ||
'dart', | ||
['run', 'bin/figmage.dart', 'forge', '--help'], | ||
); | ||
final exitCode = await process.exitCode; | ||
expect(exitCode, 0); | ||
|
||
const helpText = ''' | ||
This command forges a new package from your figma file. | ||
Usage: figmage forge [arguments] | ||
-h, --help Print this usage information. | ||
-t, --token (mandatory) Your figma API token | ||
-p, --path The ouptut path for the generated package, if not provided, the current directory will be used. | ||
-f, --fileId Your figma file ID, needs to be either given here, or in the figmage.yaml | ||
Run "figmage help" to see global options. | ||
'''; | ||
|
||
await expectLater( | ||
process.stdout.transform(const Utf8Decoder()), | ||
emits(equalsIgnoringWhitespace(helpText)), | ||
); | ||
}); | ||
|
||
test('generates default package from command', () async { | ||
final dir = Directory('./full_test_package')..createSync(); | ||
addTearDown(() => dir.deleteSync(recursive: true)); | ||
final process = await Process.start( | ||
'dart', | ||
[ | ||
'run', | ||
'../bin/figmage.dart', | ||
'forge', | ||
'-f', | ||
'HHUVTJ7lsjhG24SQB5h0zX', | ||
'-t', | ||
Platform.environment['FIGMA_FREE_TOKEN']!, | ||
], | ||
workingDirectory: dir.path, | ||
); | ||
final exitCode = await process.exitCode; | ||
expect(exitCode, 0); | ||
|
||
final pubspec = File("${dir.path}/pubspec.yaml"); | ||
final pubspecContent = pubspec.readAsStringSync(); | ||
expect( | ||
pubspecContent, | ||
contains("name: full_test_package"), | ||
reason: 'Package name was not generated from directory', | ||
); | ||
|
||
final files = [ | ||
File("${dir.path}/lib/src/colors.dart"), | ||
File("${dir.path}/lib/src/typography.dart"), | ||
]; | ||
expect( | ||
files.every((f) => f.existsSync()), | ||
true, | ||
reason: 'Token files were not generated', | ||
); | ||
|
||
final analyzeProcess = await Process.start( | ||
'dart', | ||
['analyze', '--fatal-infos', '--fatal-warnings'], | ||
workingDirectory: dir.path, | ||
); | ||
final analyzeExitCode = await analyzeProcess.exitCode; | ||
expect( | ||
analyzeExitCode, | ||
0, | ||
reason: 'Generated package has analysis issues', | ||
); | ||
}); | ||
}); | ||
} |
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