-
Notifications
You must be signed in to change notification settings - Fork 199
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 #6 from Polymer/gen-tests
Add integration tests for some representative Polymer libraries.
- Loading branch information
Showing
11 changed files
with
408 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
lib/ | ||
lib | ||
src/test/fixtures |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
https://github.com/PolymerElements/paper-button.git v2.0.0 paper-button | ||
https://github.com/PolymerElements/paper-behaviors.git v2.0.1 paper-behaviors | ||
https://github.com/Polymer/polymer.git v2.1.1 polymer |
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,39 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* @license | ||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found | ||
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may | ||
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by | ||
* Google as part of the polymer project is also subject to an additional IP | ||
* rights grant found at http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
/** | ||
* This script should be run from `npm run test:make-goldens`. It runs the | ||
* TypeScript declarations generator across all repos in the | ||
* `test/src/fixtures` directory, and writes the output to | ||
* `test/src/goldens/<fixture>/expected.d.ts`. The results of this script | ||
* *should* be checked in. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const rimraf = require('rimraf'); | ||
const {generateDeclarations} = require('../lib/gen-ts'); | ||
|
||
const fixturesDir = path.join(__dirname, '..', 'src', 'test', 'fixtures'); | ||
const goldensDir = path.join(__dirname, '..', 'src', 'test', 'goldens'); | ||
|
||
rimraf.sync(goldensDir); | ||
fs.mkdirSync(goldensDir); | ||
|
||
for (const dir of fs.readdirSync(fixturesDir)) { | ||
generateDeclarations(path.join(fixturesDir, dir)).then((declarations) => { | ||
const outDir = path.join(goldensDir, dir); | ||
fs.mkdirSync(outDir); | ||
fs.writeFileSync(path.join(outDir, 'expected.d.ts'), declarations); | ||
}); | ||
} |
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,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright (c) 2017 The Polymer Project Authors. All rights reserved. | ||
# This code may only be used under the BSD style license found at | ||
# http://polymer.github.io/LICENSE.txt The complete set of authors may be found | ||
# at http://polymer.github.io/AUTHORS.txt The complete set of contributors may | ||
# be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by | ||
# Google as part of the polymer project is also subject to an additional IP | ||
# rights grant found at http://polymer.github.io/PATENTS.txt | ||
|
||
# This script should be run from `npm run test:setup`. It reads a list of repos | ||
# from `fixtures.txt`, clones them into the `src/test/fixtures` directory, and | ||
# installs them for testing. | ||
# | ||
# To add a new repo for testing, add it to `fixtures.txt`, run `npm run | ||
# test:setup && npm run test:make-goldens`. | ||
|
||
set -e | ||
|
||
cd src/test | ||
rm -rf fixtures | ||
mkdir fixtures | ||
cd fixtures | ||
|
||
while read -r repo tag dir; do | ||
git clone $repo --branch $tag --single-branch --depth 1 $dir | ||
cd $dir | ||
bower install | ||
cd - | ||
done < ../../../scripts/fixtures.txt |
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,31 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found | ||
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may | ||
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by | ||
* Google as part of the polymer project is also subject to an additional IP | ||
* rights grant found at http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
import {assert} from 'chai'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
import {generateDeclarations} from '../gen-ts'; | ||
|
||
const fixtures = path.join(__dirname, '..', '..', 'src', 'test', 'fixtures'); | ||
const goldens = path.join(__dirname, '..', '..', 'src', 'test', 'goldens'); | ||
|
||
suite('generateDeclarations', () => { | ||
for (const fixture of fs.readdirSync(goldens)) { | ||
test(fixture, async () => { | ||
const golden = | ||
fs.readFileSync(path.join(goldens, fixture, 'expected.d.ts')); | ||
const declarations = | ||
await generateDeclarations(path.join(fixtures, fixture)); | ||
assert.equal(declarations, golden.toString()); | ||
}).timeout(30000); // These tests can take a long time. | ||
} | ||
}); |
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,4 @@ | ||
declare namespace Polymer { | ||
type Constructor<T> = new(...args: any[]) => T; | ||
|
||
} |
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,4 @@ | ||
declare namespace Polymer { | ||
type Constructor<T> = new(...args: any[]) => T; | ||
|
||
} |
Oops, something went wrong.