Просмотр исходного кода

Add typescript integration test.

Renée Kooi 6 лет назад
Родитель
Сommit
5699e5962b

+ 6 - 0
bin/endtoend-build-tests

@@ -28,3 +28,9 @@ pushd "${__root}/test/endtoend/create-react-app"
   npm install
   npm run build
 popd
+pushd "${__root}/test/endtoend/typescript"
+  mkdir -p dist
+  cp "${__root}/packages/uppy/dist/uppy.min.css" dist/
+  cp index.html dist/
+  browserify main.ts -p tsify -o dist/bundle.js
+popd

Разница между файлами не показана из-за своего большого размера
+ 500 - 112
package-lock.json


+ 1 - 0
package.json

@@ -69,6 +69,7 @@
     "replace-x": "^1.5.0",
     "temp-write": "^3.4.0",
     "tinyify": "^2.4.3",
+    "tsify": "^4.0.1",
     "typescript": "^2.9.2",
     "verdaccio": "^3.8.5",
     "watchify": "^3.11.0",

+ 26 - 0
test/endtoend/typescript/index.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <title>Uppy test page</title>
+</head>
+
+<body>
+  <style>
+    main {
+      max-width: 700px;
+      margin: auto;
+    }
+  </style>
+  <main>
+    <h2>Compiled Typescript</h2>
+    <button id="pick-files">Open modal</button>
+  </main>
+
+  <link href="uppy.min.css" rel="stylesheet">
+  <script src="bundle.js"></script>
+</body>
+
+</html>

+ 52 - 0
test/endtoend/typescript/main.ts

@@ -0,0 +1,52 @@
+import Uppy = require('@uppy/core')
+import Dashboard = require('@uppy/dashboard')
+import Instagram = require('@uppy/instagram')
+import Dropbox = require('@uppy/dropbox')
+import GoogleDrive = require('@uppy/google-drive')
+import Url = require('@uppy/url')
+import Webcam = require('@uppy/webcam')
+import Tus = require('@uppy/tus')
+import Form = require('@uppy/form')
+
+const TUS_ENDPOINT = 'https://master.tus.io/files/'
+
+const uppy = Uppy({
+  debug: true,
+  meta: {
+    username: 'John',
+    license: 'Creative Commons'
+  }
+})
+  .use(Dashboard, {
+    trigger: '#pick-files',
+    // inline: true,
+    // target: 'body',
+    metaFields: [
+      { id: 'license', name: 'License', placeholder: 'specify license' },
+      { id: 'caption', name: 'Caption', placeholder: 'add caption' }
+    ],
+    showProgressDetails: true,
+    proudlyDisplayPoweredByUppy: true,
+    note: '2 files, images and video only'
+  })
+  .use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(Dropbox, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(Url, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(Webcam, { target: Dashboard })
+  .use(Tus, { endpoint: TUS_ENDPOINT })
+  .use(Form, { target: '#upload-form' })
+  // .use(GoldenRetriever, {serviceWorker: true})
+
+uppy.on('complete', (result) => {
+  if (result.failed.length === 0) {
+    console.log('Upload successful 😀')
+  } else {
+    console.warn('Upload failed 😞')
+  }
+  console.log('successful files:', result.successful)
+  console.log('failed files:', result.failed)
+})
+
+var modalTrigger = document.querySelector('#pick-files')
+if (modalTrigger) (modalTrigger as HTMLButtonElement).click()

+ 17 - 0
test/endtoend/typescript/test.js

@@ -0,0 +1,17 @@
+/* global browser, expect  */
+describe('Project compiled with Uppy\'s TypeScript typings', () => {
+  it('Should have correct imports (thus not crash)', () => {
+    browser.url('http://localhost:4567/typescript')
+
+    browser.waitForExist('.uppy-Root')
+
+    const typeofUppy = browser.execute(function () {
+      return typeof window.uppy
+    })
+    // It was initialized correctly
+    expect(typeofUppy.value).to.equal('object')
+
+    // The dashboard is shown
+    expect(browser.isVisible(`.uppy-Dashboard`)).to.equal(true)
+  })
+})

+ 2 - 2
test/endtoend/wdio.base.conf.js

@@ -17,8 +17,7 @@ exports.config = {
   // directory is where your package.json resides, so `wdio` will be called from there.
   //
   specs: [
-    // 'test/endtoend/*/test.js',
-    'test/endtoend/transloadit/test.js'
+    'test/endtoend/*/test.js'
   ],
 
   // Patterns to exclude.
@@ -95,6 +94,7 @@ exports.config = {
     { mount: '/providers', path: './test/endtoend/providers/dist' },
     { mount: '/thumbnails', path: './test/endtoend/thumbnails/dist' },
     { mount: '/transloadit', path: './test/endtoend/transloadit/dist' },
+    { mount: '/typescript', path: './test/endtoend/typescript/dist' },
     { mount: '/url-plugin', path: './test/endtoend/url-plugin/dist' },
     { mount: '/create-react-app', path: './test/endtoend/create-react-app/build' }
   ],

Некоторые файлы не были показаны из-за большого количества измененных файлов