mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
making requested changes
This commit is contained in:
@@ -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
|
||||
@@ -1 +0,0 @@
|
||||
tests
|
||||
@@ -1,3 +1,8 @@
|
||||
// Global
|
||||
|
||||
const threeCamera = new AFRAME.THREE.Camera();
|
||||
AFRAME.TWEEN.Easing;
|
||||
|
||||
// Entity
|
||||
const entity = document.createElement('a-entity');
|
||||
entity.emit('rotate');
|
||||
|
||||
Vendored
+7
-3
@@ -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
|
||||
*/
|
||||
|
||||
/// <reference types="three" />
|
||||
/// <reference types="tweenjs" />
|
||||
/// <reference types="tween.js" />
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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 = <any> 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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 = <any> 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 = <any> 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;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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)[\/\\]/;
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="1;url=./node_modules/intern/client.html?config=intern" />
|
||||
<title>Unit Tests</title>
|
||||
</head>
|
||||
</html>
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"version": "2.3.2",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"lib": [
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user