From 485696c0db2a2e694501eb0764afb568411b6fac Mon Sep 17 00:00:00 2001 From: Paul Shannon Date: Thu, 15 Jun 2017 21:13:34 -0700 Subject: [PATCH] making requested changes --- types/aframe/README.md | 28 -------------- types/aframe/UNUSED_FILES.txt | 1 - types/aframe/aframe-tests.ts | 5 +++ types/aframe/index.d.ts | 10 +++-- types/aframe/tests/aframe.ts | 37 ------------------ types/aframe/tests/component.ts | 45 ---------------------- types/aframe/tests/entity.ts | 66 -------------------------------- types/aframe/tests/intern.ts | 26 ------------- types/aframe/tests/package.json | 19 --------- types/aframe/tests/tests.html | 8 ---- types/aframe/tests/tsconfig.json | 22 ----------- types/aframe/tsconfig.json | 1 - types/aframe/tslint.json | 4 +- 13 files changed, 13 insertions(+), 259 deletions(-) delete mode 100644 types/aframe/README.md delete mode 100644 types/aframe/UNUSED_FILES.txt delete mode 100644 types/aframe/tests/aframe.ts delete mode 100644 types/aframe/tests/component.ts delete mode 100644 types/aframe/tests/entity.ts delete mode 100755 types/aframe/tests/intern.ts delete mode 100755 types/aframe/tests/package.json delete mode 100644 types/aframe/tests/tests.html delete mode 100644 types/aframe/tests/tsconfig.json diff --git a/types/aframe/README.md b/types/aframe/README.md deleted file mode 100644 index 0bceeb7487..0000000000 --- a/types/aframe/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# aframe typings - -### build - -From the `tests` directory run: - -* `npm i` -* `npm run build` - -This will build the both `aframe-tests.ts` and the `tests` directory using the provided typings. - -Note: If you do not want to install node modules then a basic test can be ran by compiling `aframe-tests.ts` -by typing `tsc`. - -### test - -* build using the instructions above -* open `tests/tests.html` in a browser - -The testing framework uses [intern](https://theintern.github.io/) to run tests. The tests ensure that typings are -actually written against real aframe constructs by exercising the code and validating assertions. Intern also supports -local execution using Selenium by running `npm run test`. - - -## Contributing - -These typings cover much of the core of A-Frame. Help is welcomed to provide typings for A-Frame bundled components and -additional intern tests <3 diff --git a/types/aframe/UNUSED_FILES.txt b/types/aframe/UNUSED_FILES.txt deleted file mode 100644 index 3598c3003f..0000000000 --- a/types/aframe/UNUSED_FILES.txt +++ /dev/null @@ -1 +0,0 @@ -tests \ No newline at end of file diff --git a/types/aframe/aframe-tests.ts b/types/aframe/aframe-tests.ts index 190489b346..439d314f4a 100644 --- a/types/aframe/aframe-tests.ts +++ b/types/aframe/aframe-tests.ts @@ -1,3 +1,8 @@ +// Global + +const threeCamera = new AFRAME.THREE.Camera(); +AFRAME.TWEEN.Easing; + // Entity const entity = document.createElement('a-entity'); entity.emit('rotate'); diff --git a/types/aframe/index.d.ts b/types/aframe/index.d.ts index b1a763e7dd..f1f5cd7a20 100644 --- a/types/aframe/index.d.ts +++ b/types/aframe/index.d.ts @@ -4,8 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +/** + * Extended tests available at https://github.com/devpaul/aframe-typings.git + */ + /// -/// +/// // Globals declare var AFRAME: AFrame.AFrameGlobal; @@ -43,8 +47,8 @@ declare namespace AFrame { schema: SchemaUtils; shaders: { [ key: string ]: ShaderDescriptor }; systems: { [key: string]: System }; - THREE: any; // TODO THREE - TWEEN: any; // TODO TWEEN + THREE: typeof THREE; + TWEEN: typeof TWEEN; utils: Utils; version: string; } diff --git a/types/aframe/tests/aframe.ts b/types/aframe/tests/aframe.ts deleted file mode 100644 index 37d839e4df..0000000000 --- a/types/aframe/tests/aframe.ts +++ /dev/null @@ -1,37 +0,0 @@ -import 'aframe'; -import { describe, it } from 'intern!bdd'; -import * as expect from 'intern/chai!expect'; - -/** - * A-Frame exposes its public interface through the window.AFRAME browser global. - */ -describe('aframe global', () => { - describe('AFRAME', () => { - it('has the expected shape', () => { - expect(AFRAME).to.exist; - - expect(AFRAME.components).to.exist; - expect(AFRAME.geometries).to.exist; - expect(AFRAME.primitives).to.exist; - expect(AFRAME.schema).to.exist; - expect(AFRAME.shaders).to.exist; - expect(AFRAME.systems).to.exist; - expect(AFRAME.THREE).to.exist; - expect(AFRAME.TWEEN).to.exist; - expect(AFRAME.utils).to.exist; - expect(AFRAME.version).to.exist; - - expect(AFRAME.AEntity).to.be.a('function'); - expect(AFRAME.ANode).to.be.a('function'); - expect(AFRAME.AScene).to.be.a('function'); - expect(AFRAME.registerComponent).to.be.a('function'); - expect(AFRAME.registerElement).to.be.a('function'); - expect(AFRAME.registerGeometry).to.be.a('function'); - expect(AFRAME.registerPrimitive).to.be.a('function'); - }); - }); - - it('hasNativeWebVRImplementation', () => { - expect(window).to.have.property('hasNativeWebVRImplementation'); - }); -}); diff --git a/types/aframe/tests/component.ts b/types/aframe/tests/component.ts deleted file mode 100644 index 0c7390e0c7..0000000000 --- a/types/aframe/tests/component.ts +++ /dev/null @@ -1,45 +0,0 @@ -import 'aframe'; -import { describe, beforeEach, afterEach, it } from 'intern!bdd'; -import * as expect from 'intern/chai!expect'; - -describe('components', () => { - let Component: AFrame.ComponentConstructor; - - afterEach(() => { - if (Component) { - delete AFRAME.components[Component.prototype.name]; - } - }); - - describe('basic component', () => { - beforeEach(() => { - Component = AFRAME.registerComponent('test', {}); - }); - - it('has the expected shape', () => { - expect(Component).to.exist; - const entity: AFrame.Entity = document.createElement('a-entity'); - const component = new Component(entity, 'test', 'test'); - - expect(component.attrName).to.exist; - expect(component.el).to.exist; - expect(component.id).to.exist; - expect(component.name).to.exist; - expect(component.schema).to.exist; - - expect(component.data).to.not.exist; - expect(component.dependencies).to.not.exist; - expect(component.multiple).to.not.exist; - expect(component.tick).to.not.exist; - - expect(component.init).to.be.a('function'); - expect(component.update).to.be.a('function'); - expect(component.remove).to.be.a('function'); - expect(component.play).to.be.a('function'); - expect(component.pause).to.be.a('function'); - expect(component.remove).to.be.a('function'); - expect(component.flushToDOM).to.be.a('function'); - expect(component.extendSchema).to.be.a('function'); - }); - }); -}); diff --git a/types/aframe/tests/entity.ts b/types/aframe/tests/entity.ts deleted file mode 100644 index 68cf591633..0000000000 --- a/types/aframe/tests/entity.ts +++ /dev/null @@ -1,66 +0,0 @@ -import 'aframe'; -import { describe, beforeEach, afterEach, it } from 'intern!bdd'; -import * as expect from 'intern/chai!expect'; - -function assertStaticShape(entity: AFrame.Entity) { - expect(entity).to.exist; - - expect(entity.components).to.exist; - expect(entity.object3D).to.exist; - expect(entity.object3DMap).to.exist; - - expect(entity.addState).to.be.a('function'); - expect(entity.emit).to.be.a('function'); - expect(entity.flushToDOM).to.be.a('function'); - expect(entity.getAttribute).to.be.a('function'); - expect(entity.getComputedAttribute).to.be.a('function'); - expect(entity.getObject3D).to.be.a('function'); - expect(entity.getOrCreateObject3D).to.be.a('function'); - expect(entity.is).to.be.a('function'); - expect(entity.pause).to.be.a('function'); - expect(entity.play).to.be.a('function'); - expect(entity.setAttribute).to.be.a('function'); - expect(entity.setObject3D).to.be.a('function'); - expect(entity.removeAttribute).to.be.a('function'); - expect(entity.removeObject3D).to.be.a('function'); - expect(entity.removeState).to.be.a('function'); -} - -describe('entity', () => { - let entity: AFrame.Entity; - - beforeEach(() => { - entity = document.createElement('a-entity'); - }); - - describe('entity is not attached to a scene', () => { - it('has the expected shape', () => { - assertStaticShape(entity); - expect(entity.sceneEl).to.not.exist; - }); - }); - - describe('entity is part of a scene', () => { - let scene: AFrame.Scene; - - beforeEach(() => { - return new Promise(function (resolve) { - scene = document.createElement('a-scene'); - scene.addEventListener('renderstart', function () { - resolve(); - }); - document.body.appendChild(scene); - scene.appendChild(entity); - }); - }); - - afterEach(() => { - document.body.innerHTML = ''; - }); - - it('has the expected shape', () => { - assertStaticShape(entity); - expect(entity.sceneEl).to.exist; - }); - }); -}); diff --git a/types/aframe/tests/intern.ts b/types/aframe/tests/intern.ts deleted file mode 100755 index f81395f8ec..0000000000 --- a/types/aframe/tests/intern.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const loaders = { - 'host-browser': 'node_modules/@dojo/loader/loader.js' -}; - -export const environments = [ - { browserName: 'chrome' } -]; - -// Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader -// can be used here -export const loaderOptions = { - // Packages that should be registered with the loader in each testing environment - packages: [ - { name: 'tests', location: '.' }, - { name: 'aframe', location: `./node_modules/aframe/dist`, main: 'aframe-master.js' } - ] -}; - -export const suites = [ - 'tests/aframe', - 'tests/component', - 'tests/entity' -]; - -// A regular expression matching URLs to files that should not be included in code coverage analysis -export const excludeInstrumentation = /(?:node_modules|tests)[\/\\]/; diff --git a/types/aframe/tests/package.json b/types/aframe/tests/package.json deleted file mode 100755 index 8d50073828..0000000000 --- a/types/aframe/tests/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "scripts": { - "build": "tsc && tsc -p ../tsconfig.json", - "dev": "npm run build && npm run test", - "test": "intern-runner --config=./intern" - }, - "dependencies": { - "@types/three": "^0.84.8", - "@types/tweenjs": "^0.6.27" - }, - "devDependencies": { - "@dojo/loader": "^2.0.0-beta1.1", - "aframe": "^0.5.0", - "intern": "^3.3.1", - "ts-node": "^3.0.4", - "tslint": "^3.15.1", - "typescript": "^2.3.4" - } -} diff --git a/types/aframe/tests/tests.html b/types/aframe/tests/tests.html deleted file mode 100644 index 113631453e..0000000000 --- a/types/aframe/tests/tests.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - Unit Tests - - diff --git a/types/aframe/tests/tsconfig.json b/types/aframe/tests/tsconfig.json deleted file mode 100644 index 92f9994342..0000000000 --- a/types/aframe/tests/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "version": "2.3.2", - "extends": "../tsconfig.json", - "compilerOptions": { - "module": "umd", - "moduleResolution": "node", - "removeComments": false, - "sourceMap": true, - "types": [ "intern" ], - "noEmit": false, - "paths": { - "aframe": [ ".." ] - } - }, - "files": [ - "aframe.ts", - "component.ts", - "entity.ts", - "intern.ts", - "../index.d.ts" - ] -} diff --git a/types/aframe/tsconfig.json b/types/aframe/tsconfig.json index 82e7e6792b..9488fe8297 100755 --- a/types/aframe/tsconfig.json +++ b/types/aframe/tsconfig.json @@ -1,5 +1,4 @@ { - "version": "2.3.2", "compilerOptions": { "baseUrl": "..", "lib": [ diff --git a/types/aframe/tslint.json b/types/aframe/tslint.json index 724f3870ca..d88586e5bd 100644 --- a/types/aframe/tslint.json +++ b/types/aframe/tslint.json @@ -1,5 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - } + "extends": "dtslint/dt.json" }