starting sample tests
diff --git a/test/sample_files/favicon.ico b/test/sample_files/favicon.ico
new file mode 100644
index 0000000..e605972
--- /dev/null
+++ b/test/sample_files/favicon.ico
Binary files differ
diff --git a/test/sample_files/index.html b/test/sample_files/index.html
new file mode 100644
index 0000000..ab4df2c
--- /dev/null
+++ b/test/sample_files/index.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <meta charset="utf-8">
+ </head>
+
+ <body>
+ </body>
+</html>
diff --git a/test/sample_test.dart b/test/sample_test.dart
new file mode 100644
index 0000000..3c3abf1
--- /dev/null
+++ b/test/sample_test.dart
@@ -0,0 +1,62 @@
+library shelf_static.basic_file_test;
+
+import 'dart:async';
+import 'dart:io';
+import 'package:path/path.dart' as p;
+import 'package:scheduled_test/scheduled_test.dart';
+
+import 'package:shelf/shelf.dart';
+import 'package:shelf_static/shelf_static.dart';
+import 'package:shelf_static/src/util.dart';
+
+void main() {
+ group('/index.html', () {
+ test('body is correct', () {
+ var uri = Uri.parse('http://localhost/index.html');
+ var filePath = p.join(_samplePath, 'index.html');
+ var fileContents = new File(filePath).readAsStringSync();
+
+ return _request(new Request('GET', uri)).then((response) {
+ expect(response.readAsString(), completion(fileContents));
+ });
+ });
+
+ // Content-Type:text/html
+ // Date:Fri, 02 May 2014 22:29:02 GMT
+ });
+
+ group('/favicon.ico', () {
+ test('body is correct', () {
+ var uri = Uri.parse('http://localhost/favicon.ico');
+ var filePath = p.join(_samplePath, 'favicon.ico');
+ var fileContents = new File(filePath).readAsBytesSync();
+
+ return _request(new Request('GET', uri)).then((response) {
+ return _expectCompletesWithBytes(response, fileContents);
+ });
+ });
+
+ // Content-Type: ???
+ // Date:Fri, 02 May 2014 22:29:02 GMT
+ });
+}
+
+Future _expectCompletesWithBytes(Response response, List<int> expectedBytes) {
+ return response.read().toList().then((List<List<int>> bytes) {
+ var flatBytes = bytes.expand((e) => e);
+ expect(flatBytes, orderedEquals(expectedBytes));
+ });
+}
+
+Future<Response> _request(Request request) {
+ var handler = getHandler(_samplePath);
+
+ return syncFuture(() => handler(request));
+}
+
+String get _samplePath {
+ var scriptDir = p.dirname(p.fromUri(Platform.script));
+ var sampleDir = p.join(scriptDir, 'sample_files');
+ assert(FileSystemEntity.isDirectorySync(sampleDir));
+ return sampleDir;
+}