diff --git a/templates/typescript_gapic/package.json.njk b/templates/typescript_gapic/package.json.njk index 3c4429a80..846f6d0b0 100644 --- a/templates/typescript_gapic/package.json.njk +++ b/templates/typescript_gapic/package.json.njk @@ -57,6 +57,7 @@ limitations under the License. "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "pack-n-play": "^1.0.0-2", "null-loader": "^3.0.0", "tmp": "^0.1.0", "ts-loader": "^6.2.1", diff --git a/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk b/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk deleted file mode 100644 index 255a2320c..000000000 --- a/templates/typescript_gapic/system-test/fixtures/sample/package.json.njk +++ /dev/null @@ -1,40 +0,0 @@ -{#- - -Copyright 2019 Google LLC - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - --#} -{ - "name": "{{ api.naming.productName.toKebabCase() }}-sample-fixture", - "description": "An app we're using to test the {{ api.naming.productName }} library.", - "scripts": { - "check": "gts check", - "clean": "gts clean", - "compile": "tsc -p .", - "fix": "gts fix", - "prepare": "npm run compile", - "pretest": "npm run compile", - "posttest": "npm run check", - "start": "node build/src/index.js" - }, - "license": "Apache-2.0", - "dependencies": { - "{{ api.naming.productName.toKebabCase() }}": "file:./{{ api.naming.productName.toKebabCase() }}.tgz" - }, - "devDependencies": { - "@types/node": "^12.0.0", - "typescript": "^3.0.0", - "gts": "^1.0.0" - } -} diff --git a/templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk b/templates/typescript_gapic/system-test/fixtures/sample/src/index.js.njk similarity index 51% rename from templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk rename to templates/typescript_gapic/system-test/fixtures/sample/src/index.js.njk index 7c8bc7157..d0c928885 100644 --- a/templates/typescript_gapic/system-test/fixtures/sample/tsconfig.json.njk +++ b/templates/typescript_gapic/system-test/fixtures/sample/src/index.js.njk @@ -15,15 +15,17 @@ See the License for the specific language governing permissions and limitations under the License. -#} -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "types": ["node"], - "skipLibCheck": false - }, - "include": [ - "src/*.ts" - ] +{% import "../../../../_license.njk" as license -%} +{{license.license()}} +{%- for service in api.services %} +const {{ api.naming.productName.toKebabCase()}} = require('{{ api.naming.productName.toKebabCase() }}'); +{%- endfor %} + +function main() { +{%- for service in api.services %} + const {{ service.name.toCamelCase() -}}Client = new {{ api.naming.productName.toKebabCase() }}.{{ service.name.toPascalCase() + 'Client' }}(); + console.log("{{- service.name.toCamelCase() -}}Client was created!"); +{%- endfor %} } + +main(); diff --git a/templates/typescript_gapic/system-test/install.ts.njk b/templates/typescript_gapic/system-test/install.ts.njk index 0e7aec78b..d474741ba 100644 --- a/templates/typescript_gapic/system-test/install.ts.njk +++ b/templates/typescript_gapic/system-test/install.ts.njk @@ -17,40 +17,33 @@ limitations under the License. -#} {% import "../_license.njk" as license -%} {{license.license()}} -import * as execa from 'execa'; -import * as mv from 'mv'; -import {ncp} from 'ncp'; -import * as tmp from 'tmp'; -import {promisify} from 'util'; - -const keep = false; -const mvp = promisify(mv); -const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -const pkg = require('../../package.json'); - -describe('📦 pack and install', () => { - it('should be able use the library from a TypeScript application', async function() { +import {packNTest} from 'pack-n-play'; +import { readFileSync } from 'fs'; + +describe('typescript consumer tests', () => { + + it('should have correct type signature for typescript users', async function() { this.timeout(300000); - await execa('npm', ['pack', '--unsafe-perm']); - const packageName = pkg.name.replace('@', '').replace('/', '-'); - const tarball = `${packageName}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/{{ api.naming.productName.toKebabCase() }}.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install', '--unsafe-perm'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. }); - after('cleanup staging', () => { - if (!keep) { - stagingDir.removeCallback(); - } + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. }); + }); diff --git a/typescript/test/testdata/keymanager/package.json.baseline b/typescript/test/testdata/keymanager/package.json.baseline index 2d42bc441..950fe4610 100644 --- a/typescript/test/testdata/keymanager/package.json.baseline +++ b/typescript/test/testdata/keymanager/package.json.baseline @@ -40,6 +40,7 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "pack-n-play": "^1.0.0-2", "null-loader": "^3.0.0", "tmp": "^0.1.0", "ts-loader": "^6.2.1", diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline deleted file mode 100644 index 4a4e1febb..000000000 --- a/typescript/test/testdata/keymanager/system-test/fixtures/sample/package.json.baseline +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "kms-sample-fixture", - "description": "An app we're using to test the Kms library.", - "scripts": { - "check": "gts check", - "clean": "gts clean", - "compile": "tsc -p .", - "fix": "gts fix", - "prepare": "npm run compile", - "pretest": "npm run compile", - "posttest": "npm run check", - "start": "node build/src/index.js" - }, - "license": "Apache-2.0", - "dependencies": { - "kms": "file:./kms.tgz" - }, - "devDependencies": { - "@types/node": "^12.0.0", - "typescript": "^3.0.0", - "gts": "^1.0.0" - } -} diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..532f7ddd0 --- /dev/null +++ b/typescript/test/testdata/keymanager/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,26 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const kms = require('kms'); + +function main() { + const keyManagementServiceClient = new kms.KeyManagementServiceClient(); + console.log("keyManagementServiceClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline deleted file mode 100644 index e5f760d87..000000000 --- a/typescript/test/testdata/keymanager/system-test/fixtures/sample/tsconfig.json.baseline +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "types": [ - "node" - ], - "skipLibCheck": false - }, - "include": [ - "src/*.ts" - ] -} diff --git a/typescript/test/testdata/keymanager/system-test/install.ts.baseline b/typescript/test/testdata/keymanager/system-test/install.ts.baseline index 2aabe52d9..faa7e02aa 100644 --- a/typescript/test/testdata/keymanager/system-test/install.ts.baseline +++ b/typescript/test/testdata/keymanager/system-test/install.ts.baseline @@ -16,40 +16,33 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import * as execa from 'execa'; -import * as mv from 'mv'; -import {ncp} from 'ncp'; -import * as tmp from 'tmp'; -import {promisify} from 'util'; +import {packNTest} from 'pack-n-play'; +import { readFileSync } from 'fs'; -const keep = false; -const mvp = promisify(mv); -const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -const pkg = require('../../package.json'); +describe('typescript consumer tests', () => { -describe('📦 pack and install', () => { - it('should be able use the library from a TypeScript application', async function() { + it('should have correct type signature for typescript users', async function() { this.timeout(300000); - await execa('npm', ['pack', '--unsafe-perm']); - const packageName = pkg.name.replace('@', '').replace('/', '-'); - const tarball = `${packageName}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/kms.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install', '--unsafe-perm'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. }); - after('cleanup staging', () => { - if (!keep) { - stagingDir.removeCallback(); - } + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. }); + }); diff --git a/typescript/test/testdata/showcase/package.json.baseline b/typescript/test/testdata/showcase/package.json.baseline index ff92b5970..8c6a5e5c7 100644 --- a/typescript/test/testdata/showcase/package.json.baseline +++ b/typescript/test/testdata/showcase/package.json.baseline @@ -40,6 +40,7 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "pack-n-play": "^1.0.0-2", "null-loader": "^3.0.0", "tmp": "^0.1.0", "ts-loader": "^6.2.1", diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline deleted file mode 100644 index e4325fb93..000000000 --- a/typescript/test/testdata/showcase/system-test/fixtures/sample/package.json.baseline +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "showcase-sample-fixture", - "description": "An app we're using to test the Showcase library.", - "scripts": { - "check": "gts check", - "clean": "gts clean", - "compile": "tsc -p .", - "fix": "gts fix", - "prepare": "npm run compile", - "pretest": "npm run compile", - "posttest": "npm run check", - "start": "node build/src/index.js" - }, - "license": "Apache-2.0", - "dependencies": { - "showcase": "file:./showcase.tgz" - }, - "devDependencies": { - "@types/node": "^12.0.0", - "typescript": "^3.0.0", - "gts": "^1.0.0" - } -} diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..3c71a80e0 --- /dev/null +++ b/typescript/test/testdata/showcase/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,26 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const showcase = require('showcase'); + +function main() { + const echoClient = new showcase.EchoClient(); + console.log("echoClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline deleted file mode 100644 index e5f760d87..000000000 --- a/typescript/test/testdata/showcase/system-test/fixtures/sample/tsconfig.json.baseline +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "types": [ - "node" - ], - "skipLibCheck": false - }, - "include": [ - "src/*.ts" - ] -} diff --git a/typescript/test/testdata/showcase/system-test/install.ts.baseline b/typescript/test/testdata/showcase/system-test/install.ts.baseline index d063d561b..faa7e02aa 100644 --- a/typescript/test/testdata/showcase/system-test/install.ts.baseline +++ b/typescript/test/testdata/showcase/system-test/install.ts.baseline @@ -16,40 +16,33 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import * as execa from 'execa'; -import * as mv from 'mv'; -import {ncp} from 'ncp'; -import * as tmp from 'tmp'; -import {promisify} from 'util'; +import {packNTest} from 'pack-n-play'; +import { readFileSync } from 'fs'; -const keep = false; -const mvp = promisify(mv); -const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -const pkg = require('../../package.json'); +describe('typescript consumer tests', () => { -describe('📦 pack and install', () => { - it('should be able use the library from a TypeScript application', async function() { + it('should have correct type signature for typescript users', async function() { this.timeout(300000); - await execa('npm', ['pack', '--unsafe-perm']); - const packageName = pkg.name.replace('@', '').replace('/', '-'); - const tarball = `${packageName}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/showcase.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install', '--unsafe-perm'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. }); - after('cleanup staging', () => { - if (!keep) { - stagingDir.removeCallback(); - } + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. }); + }); diff --git a/typescript/test/testdata/texttospeech/package.json.baseline b/typescript/test/testdata/texttospeech/package.json.baseline index a5c823829..8e46fd096 100644 --- a/typescript/test/testdata/texttospeech/package.json.baseline +++ b/typescript/test/testdata/texttospeech/package.json.baseline @@ -40,6 +40,7 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "pack-n-play": "^1.0.0-2", "null-loader": "^3.0.0", "tmp": "^0.1.0", "ts-loader": "^6.2.1", diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline deleted file mode 100644 index 71b238658..000000000 --- a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/package.json.baseline +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "texttospeech-sample-fixture", - "description": "An app we're using to test the Texttospeech library.", - "scripts": { - "check": "gts check", - "clean": "gts clean", - "compile": "tsc -p .", - "fix": "gts fix", - "prepare": "npm run compile", - "pretest": "npm run compile", - "posttest": "npm run check", - "start": "node build/src/index.js" - }, - "license": "Apache-2.0", - "dependencies": { - "texttospeech": "file:./texttospeech.tgz" - }, - "devDependencies": { - "@types/node": "^12.0.0", - "typescript": "^3.0.0", - "gts": "^1.0.0" - } -} diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..443142bb6 --- /dev/null +++ b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,26 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const texttospeech = require('texttospeech'); + +function main() { + const textToSpeechClient = new texttospeech.TextToSpeechClient(); + console.log("textToSpeechClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline deleted file mode 100644 index e5f760d87..000000000 --- a/typescript/test/testdata/texttospeech/system-test/fixtures/sample/tsconfig.json.baseline +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "types": [ - "node" - ], - "skipLibCheck": false - }, - "include": [ - "src/*.ts" - ] -} diff --git a/typescript/test/testdata/texttospeech/system-test/install.ts.baseline b/typescript/test/testdata/texttospeech/system-test/install.ts.baseline index d826a9473..faa7e02aa 100644 --- a/typescript/test/testdata/texttospeech/system-test/install.ts.baseline +++ b/typescript/test/testdata/texttospeech/system-test/install.ts.baseline @@ -16,40 +16,33 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import * as execa from 'execa'; -import * as mv from 'mv'; -import {ncp} from 'ncp'; -import * as tmp from 'tmp'; -import {promisify} from 'util'; +import {packNTest} from 'pack-n-play'; +import { readFileSync } from 'fs'; -const keep = false; -const mvp = promisify(mv); -const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -const pkg = require('../../package.json'); +describe('typescript consumer tests', () => { -describe('📦 pack and install', () => { - it('should be able use the library from a TypeScript application', async function() { + it('should have correct type signature for typescript users', async function() { this.timeout(300000); - await execa('npm', ['pack', '--unsafe-perm']); - const packageName = pkg.name.replace('@', '').replace('/', '-'); - const tarball = `${packageName}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/texttospeech.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install', '--unsafe-perm'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. }); - after('cleanup staging', () => { - if (!keep) { - stagingDir.removeCallback(); - } + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. }); + }); diff --git a/typescript/test/testdata/translate/package.json.baseline b/typescript/test/testdata/translate/package.json.baseline index 3aeea6255..476ac7610 100644 --- a/typescript/test/testdata/translate/package.json.baseline +++ b/typescript/test/testdata/translate/package.json.baseline @@ -40,6 +40,7 @@ "mocha": "^6.0.0", "mv": "^2.1.1", "ncp": "^2.0.0", + "pack-n-play": "^1.0.0-2", "null-loader": "^3.0.0", "tmp": "^0.1.0", "ts-loader": "^6.2.1", diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline deleted file mode 100644 index f4c9f96d7..000000000 --- a/typescript/test/testdata/translate/system-test/fixtures/sample/package.json.baseline +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "translation-sample-fixture", - "description": "An app we're using to test the Translation library.", - "scripts": { - "check": "gts check", - "clean": "gts clean", - "compile": "tsc -p .", - "fix": "gts fix", - "prepare": "npm run compile", - "pretest": "npm run compile", - "posttest": "npm run check", - "start": "node build/src/index.js" - }, - "license": "Apache-2.0", - "dependencies": { - "translation": "file:./translation.tgz" - }, - "devDependencies": { - "@types/node": "^12.0.0", - "typescript": "^3.0.0", - "gts": "^1.0.0" - } -} diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..87f33996e --- /dev/null +++ b/typescript/test/testdata/translate/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,26 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const translation = require('translation'); + +function main() { + const translationServiceClient = new translation.TranslationServiceClient(); + console.log("translationServiceClient was created!"); +} + +main(); diff --git a/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline b/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline deleted file mode 100644 index e5f760d87..000000000 --- a/typescript/test/testdata/translate/system-test/fixtures/sample/tsconfig.json.baseline +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "types": [ - "node" - ], - "skipLibCheck": false - }, - "include": [ - "src/*.ts" - ] -} diff --git a/typescript/test/testdata/translate/system-test/install.ts.baseline b/typescript/test/testdata/translate/system-test/install.ts.baseline index bb31db672..faa7e02aa 100644 --- a/typescript/test/testdata/translate/system-test/install.ts.baseline +++ b/typescript/test/testdata/translate/system-test/install.ts.baseline @@ -16,40 +16,33 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import * as execa from 'execa'; -import * as mv from 'mv'; -import {ncp} from 'ncp'; -import * as tmp from 'tmp'; -import {promisify} from 'util'; +import {packNTest} from 'pack-n-play'; +import { readFileSync } from 'fs'; -const keep = false; -const mvp = promisify(mv); -const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -const pkg = require('../../package.json'); +describe('typescript consumer tests', () => { -describe('📦 pack and install', () => { - it('should be able use the library from a TypeScript application', async function() { + it('should have correct type signature for typescript users', async function() { this.timeout(300000); - await execa('npm', ['pack', '--unsafe-perm']); - const packageName = pkg.name.replace('@', '').replace('/', '-'); - const tarball = `${packageName}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/translation.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install', '--unsafe-perm'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. }); - after('cleanup staging', () => { - if (!keep) { - stagingDir.removeCallback(); - } + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. }); + });