Skip to content

Commit

Permalink
test: add test for template_cache_generator css rewriting
Browse files Browse the repository at this point in the history
It use simple sed script to showcase integration is working.

Test runs only if sed is present on the running system.  The test
uses css with simple rules that are getting traslated for RTL locales.

Closes dart-archive#1052
  • Loading branch information
rkj authored and chirayuk committed Aug 7, 2014
1 parent 34e2259 commit da5b2b0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/io/template_cache_generator_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,45 @@ void main() {
});
});

if (new File("/bin/sed").existsSync()) {
it('should correctly use simple sed rewritter to fake css mirroring', () {
var tmpDir = Directory.systemTemp.createTempSync();
Future flush;
try {
flush = generator.main([
'--out=${tmpDir.path}/generated.dart',
'--url-rewrites=/test/io/test_files,rewritten',
'--css-rewriter=test/io/test_files/rewritter.sh',
'test/io/test_files/cssUrls/main.dart',
'generated']);
} catch(_) {
tmpDir.deleteSync(recursive: true);
rethrow;
}
return flush.then((_) {
expect(new File('${tmpDir.path}/generated.dart').readAsStringSync(),
'''// GENERATED, DO NOT EDIT!
library generated;
import 'package:angular/angular.dart';
primeTemplateCache(TemplateCache tc) {
tc.put("rewritten/cssUrls/four.css", new HttpResponse(200, r""".float-right {
float: right;
}
.right-margin {
margin-right: 20px;
}
"""));
tc.put("rewritten/cssUrls/one.css", new HttpResponse(200, r"""body {}"""));
tc.put("rewritten/cssUrls/three.css", new HttpResponse(200, r"""body {}"""));
tc.put("rewritten/cssUrls/two.css", new HttpResponse(200, r"""body {}"""));
}''');
}).whenComplete(() {
tmpDir.deleteSync(recursive: true);
});
});
}
});
}
7 changes: 7 additions & 0 deletions test/io/test_files/cssUrls/four.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.float-left {
float: left;
}
.left-margin {
margin-left: 20px;
}

3 changes: 3 additions & 0 deletions test/io/test_files/rewritter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/bin/sed 's/left/right/g'

0 comments on commit da5b2b0

Please sign in to comment.