forked from eatvio/eatvio_app
fix: issue-372, issue-227, issue-406
This commit is contained in:
36
test/core/utils/inline_svg_css_test.dart
Normal file
36
test/core/utils/inline_svg_css_test.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:eatvio_app/core/utils/inline_svg_css.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('inlineSvgCss', () {
|
||||
test(
|
||||
'inlines class fills from a style block so flutter_svg can paint colors',
|
||||
() {
|
||||
const svg = '''
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFD200;}
|
||||
.st1{fill:#FFFFFF;}
|
||||
</style>
|
||||
<circle class="st0" cx="20" cy="20" r="18"/>
|
||||
<path class="st1" d="M10 20h20"/>
|
||||
</svg>
|
||||
''';
|
||||
|
||||
final result = inlineSvgCss(svg);
|
||||
|
||||
expect(result, isNot(contains('<style')));
|
||||
expect(result, contains('fill="#FFD200"'));
|
||||
expect(result, contains('fill="#FFFFFF"'));
|
||||
expect(result, isNot(contains('class="st0"')));
|
||||
},
|
||||
);
|
||||
|
||||
test('keeps SVG without style blocks unchanged', () {
|
||||
const svg =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg"><circle fill="#00AA00" cx="10" cy="10" r="5"/></svg>';
|
||||
|
||||
expect(inlineSvgCss(svg), svg);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user