This repository has been archived by the owner on May 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from devoncarew/devoncarew_add_web_tests
Add web tests
- Loading branch information
Showing
6 changed files
with
88 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details. | ||
All rights reserved. Use of this source code is governed by a BSD-style | ||
license that can be found in the LICENSE file. --> | ||
|
||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Stagehand Tests</title> | ||
</head> | ||
|
||
<body> | ||
<script src="packages/unittest/test_controller.js"></script> | ||
<script type="application/dart" src="web_test.dart"></script> | ||
<script src="packages/browser/dart.js"></script> | ||
</body> | ||
</html> |
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,63 @@ | ||
// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
library stagehand.web_test; | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:stagehand/stagehand.dart'; | ||
import 'package:unittest/html_config.dart'; | ||
import 'package:unittest/unittest.dart'; | ||
|
||
import 'common_test.dart' as common_test; | ||
import 'generators_test.dart' as generators_test; | ||
|
||
// TODO: get the tests running in content_shell | ||
|
||
void main() { | ||
// Set up the test environment. | ||
useHtmlConfiguration(); | ||
|
||
// Define the tests. | ||
common_test.defineTests(); | ||
generators_test.defineTests(); | ||
defineIntegrationTests(); | ||
} | ||
|
||
void defineIntegrationTests() { | ||
group('integration', () { | ||
generators.forEach((generator) { | ||
test(generator.id, () => testGenerator(getGenerator(generator.id))); | ||
}); | ||
}); | ||
} | ||
|
||
Future testGenerator(Generator generator) { | ||
expect(generator.id, isNotNull); | ||
|
||
MockTarget target = new MockTarget(); | ||
|
||
// Assert that we can generate the template. | ||
return generator.generate('foo', target).then((_) { | ||
// Run some basic validation on the generated results. | ||
expect(target.getFileContentsAsString('.gitignore'), isNotNull); | ||
expect(target.getFileContentsAsString('pubspec.yaml'), isNotNull); | ||
}); | ||
} | ||
|
||
class MockTarget extends GeneratorTarget { | ||
Map<String, List<int>> files = {}; | ||
|
||
Future createFile(String path, List<int> contents) { | ||
files[path] = contents; | ||
return new Future.value(); | ||
} | ||
|
||
bool hasFile(String path) => files.containsKey(path); | ||
|
||
String getFileContentsAsString(String path) { | ||
if (!hasFile(path)) return null; | ||
return new String.fromCharCodes(files[path]); | ||
} | ||
} |