From 5492239ff4451b51e4e455fe3df2fe66d91c88ca Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Thu, 16 Mar 2017 22:05:09 -0400 Subject: [PATCH] refactor(): general cleanup (#1193) --- DEVELOPER.md | 68 +-- circle.yml | 3 +- gulpfile.js | 28 +- karma.conf.ts | 61 --- package.json | 73 +-- scripts/bower.json | 26 -- scripts/bower.sh | 28 -- scripts/templates/wrap-min.tmpl | 8 +- scripts/templates/wrap.tmpl | 10 +- test/plugin.spec.ts | 174 ------- test/plugins/googlemap.spec.ts | 40 -- test/plugins/inappbrowser.spec.ts | 30 -- test/plugins/mixpanel.spec.ts | 28 -- typings/es6-shim/es6-shim.d.ts | 668 --------------------------- typings/globals/jasmine/index.d.ts | 502 -------------------- typings/globals/jasmine/typings.json | 8 - typings/index.d.ts | 1 - 17 files changed, 57 insertions(+), 1699 deletions(-) delete mode 100644 karma.conf.ts delete mode 100644 scripts/bower.json delete mode 100644 scripts/bower.sh delete mode 100644 test/plugin.spec.ts delete mode 100644 test/plugins/googlemap.spec.ts delete mode 100644 test/plugins/inappbrowser.spec.ts delete mode 100644 test/plugins/mixpanel.spec.ts delete mode 100644 typings/es6-shim/es6-shim.d.ts delete mode 100644 typings/globals/jasmine/index.d.ts delete mode 100644 typings/globals/jasmine/typings.json delete mode 100644 typings/index.d.ts diff --git a/DEVELOPER.md b/DEVELOPER.md index e52ff352bf..9cf7bf27b9 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -12,6 +12,9 @@ First, let's start by creating a new plugin wrapper from template. // Make sure to capitalize the first letter, or use CamelCase if necessary. gulp plugin:create -n PluginName + +// add -m flag to get a minimal template to start with +gulp plugin:create -m -n PluginName ``` @@ -22,17 +25,18 @@ Let's take a look at the existing plugin wrapper for Geolocation to see what goe plugin: 'cordova-plugin-geolocation', pluginRef: 'navigator.geolocation' }) +@Injectable() export class Geolocation { @Cordova() - static getCurrentPosition(options?: GeolocationOptions): Promise { return } + getCurrentPosition(options?: GeolocationOptions): Promise { return; } @Cordova({ callbackOrder: 'reverse', observable: true, clearFunction: 'clearWatch' }) - static watchPosition(options?: GeolocationOptions): Observable { return } + watchPosition(options?: GeolocationOptions): Observable { return; } } ``` @@ -41,6 +45,7 @@ export class Geolocation { First and foremost, we want to create a class representing our plugin, in this case Geolocation. ``` +@Injectable() class Geolocation { } @@ -57,6 +62,7 @@ For example, the `@Plugin` decorator adds information about the plugin to our Ge plugin: 'cordova-plugin-geolocation', pluginRef: 'navigator.geolocation' }) +@Injectable() export class Geolocation { } @@ -74,7 +80,7 @@ Let's take a look at `getCurrentPosition` first. ``` @Cordova() - static getCurrentPosition(options?: GeolocationOptions): Promise { return } + getCurrentPosition(options?: GeolocationOptions): Promise { return } ``` It's just a stub. The `return` is only there to keep the TypeScript type-checker from complaining since we indicate that `getCurrentPosition` returns a `Promise`. @@ -91,7 +97,7 @@ Next, let's look at the `watchPosition` method. observable: true, clearFunction: 'clearWatch' }) - static watchPosition(options?: GeolocationOptions): Observable { return } + watchPosition(options?: GeolocationOptions): Observable { return } ``` The `@Cordova` decorator has a few more options now. @@ -102,58 +108,6 @@ The `@Cordova` decorator has a few more options now. `clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed. -### Updating index.ts - -For new plugins, you will need to update `/src/index.ts` to properly export your plugin and make it available for use. - -1. Import the plugin class into `index.ts`: - -`import {PluginClassName} from ./plugins/filenameForPlugin` - -No need to put the `.ts` extension on the filename. - -2. Add the plugin class name to the list in the `export` object: - -``` -export { - ActionSheet, - AdMob, - AndroidFingerprintAuth, - YourPluginClassName, - ... -} -``` - -3. Add the plugin class name to the `window['IonicNative']` object: - -``` -window['IonicNative'] = { - ActionSheet: ActionSheet, - AdMob: AdMob, - AndroidFingerprintAuth: AndroidFingerprintAuth, - YourPluginClassName: YourPluginClassName, - ... -``` - -4. If your plugin exports any other objects outside of the plugin class, add an export statement for the file: - -`export * from './plugins/filenameForPlugin';` - -No need to put the `.ts` extension on the filename. - -For example, `googlemaps.ts` exports a const outside of the plugin's main `GoogleMap` class: - -``` -export const GoogleMapsAnimation = { - BOUNCE: 'BOUNCE', - DROP: 'DROP' -}; -``` - -To properly export `GoogleMapsAnimation`, `index.ts` is updated with: - -`export * from './plugins/googlemaps';` - ### Testing your changes You need to run `npm run build` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one. @@ -164,7 +118,7 @@ You need to run `npm run lint` to analyze the code and ensure it's consistency w ### 'Wrapping' Up -That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles. +That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles. ## Commit Message Format diff --git a/circle.yml b/circle.yml index 3316522162..da298f4056 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: node: - version: 4.1.0 + version: 7.10.0 ruby: version: 2.1.2 @@ -17,7 +17,6 @@ dependencies: test: override: - - npm test - npm run build deployment: diff --git a/gulpfile.js b/gulpfile.js index 93d75ac456..3cd607b113 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,5 @@ var gulp = require('gulp'); var minimist = require('minimist'); -var uglify = require('gulp-uglify'); var rename = require("gulp-rename"); var tslint = require('gulp-tslint'); var decamelize = require('decamelize'); @@ -17,16 +16,6 @@ var flags = minimist(process.argv.slice(2), flagConfig); /* Docs tasks */ require('./scripts/docs/gulp-tasks')(gulp, flags); - -gulp.task("minify:dist", function(){ - gulp.src('./dist/ionic.native.js') - .pipe(uglify()) - .pipe(rename({ - suffix: '.min' - })) - .pipe(gulp.dest('./dist')); -}); - gulp.task('lint', function() { gulp.src('src/**/*.ts') .pipe(tslint({ @@ -38,12 +27,21 @@ gulp.task('lint', function() { gulp.task('plugin:create', function(){ if(flags.n && flags.n !== ''){ - var src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl'; + + const src = flags.m?'./scripts/templates/wrap-min.tmpl':'./scripts/templates/wrap.tmpl', + pluginName = flags.n, + pluginPackageName = decamelize(pluginName, '-'), + pluginNameSpaced = pluginName.replace(/(?!^)([A-Z])/g, ' $1'); + return gulp.src(src) - .pipe(replace('PluginName', flags.n)) - .pipe(rename(decamelize(flags.n, '-') + '.ts')) - .pipe(gulp.dest('./src/plugins/')); + .pipe(replace('PluginName', pluginName)) + .pipe(replace('Plugin Name', pluginNameSpaced)) + .pipe(rename('index.ts')) + .pipe(gulp.dest('./src/@ionic-native/plugins/' + pluginPackageName)); + } else { + console.log("Usage is: gulp plugin:create -n PluginName"); + } }); diff --git a/karma.conf.ts b/karma.conf.ts deleted file mode 100644 index 5b3106254a..0000000000 --- a/karma.conf.ts +++ /dev/null @@ -1,61 +0,0 @@ -const WATCH = process.argv.indexOf('--watch') > -1; - -module.exports = config => { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: './', - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine', 'browserify'], - - // list of files / patterns to load in the browser - files: [ - 'test/**/*.spec.ts' - ], - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'test/**/*.spec.ts': ['browserify'] - }, - - browserify: { - debug: true, - plugin: [ 'tsify' ], - extensions: ['.js', '.ts'] - }, - - phantomjsLauncher: { - // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom) - exitOnResourceError: true - }, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['dots'], - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: WATCH, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: !WATCH - }); -}; diff --git a/package.json b/package.json index 055fa4f954..933570e157 100644 --- a/package.json +++ b/package.json @@ -2,58 +2,39 @@ "name": "ionic-native", "version": "3.1.0-rc.5", "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", - "main": "dist/es5/index.js", - "module": "dist/esm/index.js", - "typings": "dist/es5/index.d.ts", - "files": [ - "dist" - ], + "license": "MIT", "devDependencies": { "@angular/compiler": "2.4.8", "@angular/compiler-cli": "2.4.8", "@angular/core": "2.4.8", - "browserify": "^13.3.0", "canonical-path": "0.0.2", - "child-process-promise": "^2.2.0", - "conventional-changelog-cli": "^1.2.0", - "conventional-github-releaser": "^1.1.3", - "cpr": "^2.0.2", - "cz-conventional-changelog": "^1.2.0", - "decamelize": "^1.2.0", - "dgeni": "^0.4.7", - "dgeni-packages": "^0.16.10", - "es6-shim": "~0.35.2", - "fs-extra": "^2.0.0", - "fs-extra-promise": "^0.4.1", - "glob": "^7.1.1", - "gulp": "^3.9.1", - "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.4", - "gulp-tslint": "^6.1.2", - "gulp-uglify": "^2.0.0", - "jasmine-core": "~2.5.2", - "karma": "~1.3.0", - "karma-browserify": "~5.1.0", - "karma-jasmine": "~1.1.0", - "karma-phantomjs-launcher": "~1.0.2", + "child-process-promise": "2.2.0", + "conventional-changelog-cli": "1.2.0", + "cpr": "2.0.2", + "cz-conventional-changelog": "1.2.0", + "decamelize": "1.2.0", + "dgeni": "0.4.7", + "dgeni-packages": "0.16.10", + "fs-extra": "2.0.0", + "fs-extra-promise": "0.4.1", + "gulp": "3.9.1", + "gulp-rename": "1.2.2", + "gulp-replace": "0.5.4", + "gulp-tslint": "6.1.2", "lodash": "4.17.4", - "minimist": "^1.1.3", + "minimist": "1.1.3", "node-html-encoder": "0.0.2", "q": "1.4.1", - "queue": "^4.2.1", - "rimraf": "^2.5.4", + "queue": "4.2.1", + "rimraf": "2.5.4", "rxjs": "5.0.1", - "semver": "^5.3.0", - "tsify": "~3.0.0", - "tslint": "^3.15.1", + "semver": "5.3.0", + "tslint": "3.15.1", "tslint-ionic-rules": "0.0.7", "typescript": "2.0.09", - "watchify": "~3.7.0", "zone.js": "0.7.2" }, "scripts": { - "test": "karma start", - "test:watch": "npm test -- --watch", "start": "npm run test:watch", "lint": "gulp lint", "build": "npm run clean && npm run lint && npm run build:core && npm run build:modules", @@ -62,25 +43,11 @@ "clean": "rimraf dist", "shipit": "npm run build && gulp readmes && npm run npmpub", "npmpub": "node scripts/build/publish.js", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", - "plugin:create": "gulp plugin:create" - }, - "repository": { - "type": "git", - "url": "https://github.com/driftyco/ionic-native.git" + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0" }, - "license": "MIT", - "bugs": { - "url": "https://github.com/driftyco/ionic-native/issues" - }, - "homepage": "https://github.com/driftyco/ionic-native", "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } - }, - "dependencies": { - "dgeni": "^0.4.7", - "dgeni-packages": "^0.16.10" } } diff --git a/scripts/bower.json b/scripts/bower.json deleted file mode 100644 index 678bac5915..0000000000 --- a/scripts/bower.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "ionic-native", - "description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", - "main": [ - "ionic.native.js" - ], - "authors": [ - "Max Lynch " - ], - "license": "MIT", - "keywords": [ - "ionic", - "native", - "html5", - "hybrid", - "mobile" - ], - "homepage": "https://github.com/driftyco/ionic-native-bower", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/scripts/bower.sh b/scripts/bower.sh deleted file mode 100644 index cf70d3731c..0000000000 --- a/scripts/bower.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -e - - -# readJsonProp(jsonFile, property) -# - restriction: property needs to be on an own line! -function readJsonProp { - echo $(sed -En 's/.*"'$2'"[ ]*:[ ]*"(.*)".*/\1/p' $1) -} - -VERSION=$(readJsonProp "package.json" "version") - -echo "BOWERING IONIC-NATIVE VERSION $VERSION. FOR GREAT JUSTICE..." - -DIR="scripts/ionic-native-bower" -rm -rf $DIR -mkdir $DIR -cp dist/ionic.native.js dist/ionic.native.min.js $DIR -cd $DIR -git init -git remote add origin git@github.com:driftyco/ionic-native-bower.git -cp ../bower.json . -git add . -git commit -m "Bower release" -git tag -f -m v$VERSION v$VERSION -git push -f --tags origin master - -echo "BOWERING COMPLETED SOMEWHAT SUCCESSFULLY" diff --git a/scripts/templates/wrap-min.tmpl b/scripts/templates/wrap-min.tmpl index 0a947901d4..363d41e4d0 100644 --- a/scripts/templates/wrap-min.tmpl +++ b/scripts/templates/wrap-min.tmpl @@ -1,6 +1,8 @@ -import { Plugin } from './plugin'; +import { Plugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + /** - * @name PluginName + * @name Plugin Name * @description * * @usage @@ -16,5 +18,7 @@ import { Plugin } from './plugin'; pluginRef: '', repo: '' }) +@Injectable() export class PluginName { + } diff --git a/scripts/templates/wrap.tmpl b/scripts/templates/wrap.tmpl index 7bf61ae186..a9ce28efda 100644 --- a/scripts/templates/wrap.tmpl +++ b/scripts/templates/wrap.tmpl @@ -6,15 +6,16 @@ * - Document usage (importing, executing main functionality) * - Remove any imports that you are not using * - Add this file to /src/index.ts (follow style of other plugins) - * - Remove all the comments included in this template, EXCEPT the @Plugin wrapper docs. + * - Remove all the comments included in this template, EXCEPT the @Plugin wrapper docs and any other docs you added * - Remove this note * */ -import { Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty } from './plugin'; +import { Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; /** - * @name PluginName + * @name Plugin Name * @description * This plugin does something * @@ -35,6 +36,7 @@ import { Observable } from 'rxjs/Observable'; repo: '', // the github repository URL for the plugin install: '' // OPTIONAL install command, in case the plugin requires variables }) +@Injectable() export class PluginName { /** @@ -44,7 +46,7 @@ export class PluginName { * @return {Promise} Returns a promise that resolves when something happens */ @Cordova() - static functionName(arg1: string, arg2: number): Promise { + functionName(arg1: string, arg2: number): Promise { return; // We add return; here to avoid any IDE / Compiler errors } diff --git a/test/plugin.spec.ts b/test/plugin.spec.ts deleted file mode 100644 index ae572df285..0000000000 --- a/test/plugin.spec.ts +++ /dev/null @@ -1,174 +0,0 @@ -/// - -import 'es6-shim'; -import {Plugin, Cordova} from './../src/plugins/plugin'; - -declare let window: any; -window.plugins = { - test: {} -}; - -const testPluginMeta = { - pluginName: 'Test', - plugin: 'cordova-plugin-test', - pluginRef: 'plugins.test', - repo: 'https://github.com/apache/cordova-plugin-test', - platforms: ['Android', 'iOS'] -}; - -describe('plugin', () => { - - it('sync method', () => { - - window.plugins.test.syncMethod = () => { - return 'syncResult'; - }; - - @Plugin(testPluginMeta) - class Test { - - @Cordova({ - sync: true - }) - static syncMethod(arg: any): boolean { return; }; - - } - - const spy = spyOn(window.plugins.test, 'syncMethod').and.callThrough(); - const result = Test.syncMethod('foo'); - expect(result).toEqual('syncResult'); - expect(spy).toHaveBeenCalledWith('foo'); - - }); - - it('normal order callback', done => { - - window.plugins.test.normalOrderCallback = (args, success, error) => { - success('normalOrderCallback'); - }; - - @Plugin(testPluginMeta) - class Test { - @Cordova() - static normalOrderCallback(args: any): Promise { return; } - } - - const spy = spyOn(window.plugins.test, 'normalOrderCallback').and.callThrough(); - Test.normalOrderCallback('foo').then(result => { - expect(result).toEqual('normalOrderCallback'); - done(); - }); - expect(spy.calls.mostRecent().args[0]).toEqual('foo'); - - }); - - it('reverse order callback', done => { - - window.plugins.test.reverseOrderCallback = (success, error, args) => { - success('reverseOrderCallback'); - }; - - @Plugin(testPluginMeta) - class Test { - - @Cordova({ - callbackOrder: 'reverse' - }) - static reverseOrderCallback(args: any): Promise { return; } - - } - - const spy = spyOn(window.plugins.test, 'reverseOrderCallback').and.callThrough(); - Test.reverseOrderCallback('foo').then(result => { - expect(result).toEqual('reverseOrderCallback'); - done(); - }); - expect(spy.calls.mostRecent().args[2]).toEqual('foo'); - - }); - - it('node style callback', done => { - - window.plugins.test.nodeStyleCallback = (args, done) => { - done(null, 'nodeStyleCallback'); - }; - - @Plugin(testPluginMeta) - class Test { - - @Cordova({ - callbackStyle: 'node' - }) - static nodeStyleCallback(args: any): Promise { return; } - - } - - const spy = spyOn(window.plugins.test, 'nodeStyleCallback').and.callThrough(); - Test.nodeStyleCallback('foo').then(result => { - expect(result).toEqual('nodeStyleCallback'); - done(); - }); - expect(spy.calls.mostRecent().args[0]).toEqual('foo'); - - }); - - it('object style callback', done => { - - window.plugins.test.objectStyleCallback = (args, {success}) => { - success('objectStyleCallback'); - }; - - @Plugin(testPluginMeta) - class Test { - - @Cordova({ - callbackStyle: 'object', - successName: 'success', - errorName: 'error' - }) - static objectStyleCallback(args: any): Promise { return; } - - } - - const spy = spyOn(window.plugins.test, 'objectStyleCallback').and.callThrough(); - Test.objectStyleCallback('foo').then(result => { - expect(result).toEqual('objectStyleCallback'); - done(); - }); - expect(spy.calls.mostRecent().args[0]).toEqual('foo'); - - }); - - it('reverse callback at the end of the function', done => { - - window.plugins.test.reverseEndCallback = (args, error, success) => { - success('Success'); - }; - - @Plugin(testPluginMeta) - class Test { - - @Cordova({ - successIndex: 2, - errorIndex: 1 - }) - static reverseEndCallback(args: any): Promise { return; } - - } - - const spy = spyOn(window.plugins.test, 'reverseEndCallback').and.callThrough(); - const cb = (result) => { - expect(result).toEqual('Success'); - done(); - }; - - Test.reverseEndCallback('foo').then(cb, cb); - - expect(spy.calls.mostRecent().args[0]).toEqual('foo'); - expect(spy.calls.mostRecent().args[1]).toBeDefined(); - expect(spy.calls.mostRecent().args[2]).toBeDefined(); - expect(spy.calls.mostRecent().args[3]).toBeUndefined(); - - }); - -}); diff --git a/test/plugins/googlemap.spec.ts b/test/plugins/googlemap.spec.ts deleted file mode 100644 index 3f89d15cff..0000000000 --- a/test/plugins/googlemap.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { GoogleMapsLatLngBounds, GoogleMapsLatLng } from '../../src/plugins/googlemap'; - -declare var window: any; - -class LatLngBounds { - public southwest: GoogleMapsLatLng; - public northeast: GoogleMapsLatLng; - - constructor(latLngArray: GoogleMapsLatLng[]) { - this.southwest = latLngArray[0]; - this.northeast = latLngArray[1]; - } -} - -window.plugin = { - google: { - maps: { - LatLngBounds - } - } -}; - -describe('LatLngBounds', () => { - - const southwest = new GoogleMapsLatLng(1,1); - const northeast = new GoogleMapsLatLng(4,4); - let object; - - it('should create an object', () => { - object = new GoogleMapsLatLngBounds([southwest, northeast]); - expect(object).toBeDefined(); - }); - - it('northwest property should be defined', () => expect(object.northeast).toBeDefined()); - - it('southwest property should be defined', () => expect(object.southwest).toBeDefined()); - - - -}); diff --git a/test/plugins/inappbrowser.spec.ts b/test/plugins/inappbrowser.spec.ts deleted file mode 100644 index 9c7c3eee6a..0000000000 --- a/test/plugins/inappbrowser.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { InAppBrowser, InAppBrowserEvent, InAppBrowserOptions } from '../../src/plugins/inappbrowser'; - -declare var window: any; - -window.cordova = { - InAppBrowser: { - open: window.open - } -}; - -describe('InAppBrowser', () => { - - const options: InAppBrowserOptions = { hidden: 'yes', hardwareback: 'no' }; - let object; - - it('should create an object using strings and InAppBrowserOptions signature', () => { - object = new InAppBrowser('http://google.com', '_self', options); - expect(object).toBeDefined(); - }); - - it('should create an object using string only signature', () => { - object = new InAppBrowser('http://google.com', '_self', 'location=no'); - expect(object).toBeDefined(); - }); - - it('should create an object with the least amount of parameters', () => { - object = new InAppBrowser('http://google.com'); - expect(object).toBeDefined(); - }); -}); diff --git a/test/plugins/mixpanel.spec.ts b/test/plugins/mixpanel.spec.ts deleted file mode 100644 index 7eb43d0b40..0000000000 --- a/test/plugins/mixpanel.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {Mixpanel} from '../../src/plugins/mixpanel'; -declare const window: any; - -window.mixpanel = { - people: { - identify: (args, success, error) => success('Success') - } -}; - -describe('Mixpanel', () => { - - it('should return MixpanelPeople', () => { - expect(Mixpanel.people).toBeDefined(); - expect(Mixpanel.people.identify).toBeDefined(); - }); - - it('should call a method of MixpanelPeople', (done) => { - const spy = spyOn(window.mixpanel.people, 'identify').and.callThrough(); - Mixpanel.people.identify('veryDistinctSuchIdVeryWow') - .then(result => { - expect(result).toEqual('Success'); - done(); - }); - expect(spy.calls.mostRecent().args[0]).toEqual('veryDistinctSuchIdVeryWow'); - expect(window.mixpanel.people.identify).toHaveBeenCalled(); - }); - -}); diff --git a/typings/es6-shim/es6-shim.d.ts b/typings/es6-shim/es6-shim.d.ts deleted file mode 100644 index 30621b372e..0000000000 --- a/typings/es6-shim/es6-shim.d.ts +++ /dev/null @@ -1,668 +0,0 @@ -// Type definitions for es6-shim v0.31.2 -// Project: https://github.com/paulmillr/es6-shim -// Definitions by: Ron Buckton -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare type PropertyKey = string | number | symbol; - -interface IteratorResult { - done: boolean; - value?: T; -} - -interface IterableShim { - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): Iterator; -} - -interface Iterator { - next(value?: any): IteratorResult; - return?(value?: any): IteratorResult; - throw?(e?: any): IteratorResult; -} - -interface IterableIteratorShim extends IterableShim, Iterator { - /** - * Shim for an ES6 iterable iterator. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface StringConstructor { - /** - * Return the String value whose elements are, in order, the elements in the List elements. - * If length is 0, the empty string is returned. - */ - fromCodePoint(...codePoints: number[]): string; - - /** - * String.raw is intended for use as a tag function of a Tagged Template String. When called - * as such the first argument will be a well formed template call site object and the rest - * parameter will contain the substitution values. - * @param template A well-formed template string call site representation. - * @param substitutions A set of substitution values. - */ - raw(template: TemplateStringsArray, ...substitutions: any[]): string; -} - -interface String { - /** - * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point - * value of the UTF-16 encoded code point starting at the string element at position pos in - * the String resulting from converting this object to a String. - * If there is no element at that position, the result is undefined. - * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. - */ - codePointAt(pos: number): number; - - /** - * Returns true if searchString appears as a substring of the result of converting this - * object to a String, at one or more positions that are - * greater than or equal to position; otherwise, returns false. - * @param searchString search string - * @param position If position is undefined, 0 is assumed, so as to search all of the String. - */ - includes(searchString: string, position?: number): boolean; - - /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * endPosition – length(this). Otherwise returns false. - */ - endsWith(searchString: string, endPosition?: number): boolean; - - /** - * Returns a String value that is made from count copies appended together. If count is 0, - * T is the empty String is returned. - * @param count number of copies to append - */ - repeat(count: number): string; - - /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * position. Otherwise returns false. - */ - startsWith(searchString: string, position?: number): boolean; - - /** - * Returns an HTML anchor element and sets the name attribute to the text value - * @param name - */ - anchor(name: string): string; - - /** Returns a HTML element */ - big(): string; - - /** Returns a HTML element */ - blink(): string; - - /** Returns a HTML element */ - bold(): string; - - /** Returns a HTML element */ - fixed(): string - - /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string - - /** Returns a HTML element and sets the size attribute value */ - fontsize(size: number): string; - - /** Returns a HTML element and sets the size attribute value */ - fontsize(size: string): string; - - /** Returns an HTML element */ - italics(): string; - - /** Returns an HTML element and sets the href attribute value */ - link(url: string): string; - - /** Returns a HTML element */ - small(): string; - - /** Returns a HTML element */ - strike(): string; - - /** Returns a HTML element */ - sub(): string; - - /** Returns a HTML element */ - sup(): string; - - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface ArrayConstructor { - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: IterableShim): Array; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: T[]): Array; -} - -interface Array { - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: T) => boolean, thisArg?: any): number; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: T, start?: number, end?: number): T[]; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): T[]; - - /** - * Returns an array of key, value pairs for every entry in the array - */ - entries(): IterableIteratorShim<[number, T]>; - - /** - * Returns an list of keys in the array - */ - keys(): IterableIteratorShim; - - /** - * Returns an list of values in the array - */ - values(): IterableIteratorShim; - - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface NumberConstructor { - /** - * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 - * that is representable as a Number value, which is approximately: - * 2.2204460492503130808472633361816 x 10‍−‍16. - */ - EPSILON: number; - - /** - * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a - * number. Only finite values of the type number, result in true. - * @param number A numeric value. - */ - isFinite(number: number): boolean; - - /** - * Returns true if the value passed is an integer, false otherwise. - * @param number A numeric value. - */ - isInteger(number: number): boolean; - - /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a - * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter - * to a number. Only values of the type number, that are also NaN, result in true. - * @param number A numeric value. - */ - isNaN(number: number): boolean; - - /** - * Returns true if the value passed is a safe integer. - * @param number A numeric value. - */ - isSafeInteger(number: number): boolean; - - /** - * The value of the largest integer n such that n and n + 1 are both exactly representable as - * a Number value. - * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. - */ - MAX_SAFE_INTEGER: number; - - /** - * The value of the smallest integer n such that n and n − 1 are both exactly representable as - * a Number value. - * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). - */ - MIN_SAFE_INTEGER: number; - - /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ - parseFloat(string: string): number; - - /** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ - parseInt(string: string, radix?: number): number; -} - -interface ObjectConstructor { - /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. - */ - assign(target: any, ...sources: any[]): any; - - /** - * Returns true if the values are the same value, false otherwise. - * @param value1 The first value. - * @param value2 The second value. - */ - is(value1: any, value2: any): boolean; - - /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. - * @param o The object to change its prototype. - * @param proto The value of the new prototype or null. - * @remarks Requires `__proto__` support. - */ - setPrototypeOf(o: any, proto: any): any; -} - -interface RegExp { - /** - * Returns a string indicating the flags of the regular expression in question. This field is read-only. - * The characters in this string are sequenced and concatenated in the following order: - * - * - "g" for global - * - "i" for ignoreCase - * - "m" for multiline - * - "u" for unicode - * - "y" for sticky - * - * If no flags are set, the value is the empty string. - */ - flags: string; -} - -interface Math { - /** - * Returns the number of leading zero bits in the 32-bit binary representation of a number. - * @param x A numeric expression. - */ - clz32(x: number): number; - - /** - * Returns the result of 32-bit multiplication of two numbers. - * @param x First number - * @param y Second number - */ - imul(x: number, y: number): number; - - /** - * Returns the sign of the x, indicating whether x is positive, negative or zero. - * @param x The numeric expression to test - */ - sign(x: number): number; - - /** - * Returns the base 10 logarithm of a number. - * @param x A numeric expression. - */ - log10(x: number): number; - - /** - * Returns the base 2 logarithm of a number. - * @param x A numeric expression. - */ - log2(x: number): number; - - /** - * Returns the natural logarithm of 1 + x. - * @param x A numeric expression. - */ - log1p(x: number): number; - - /** - * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of - * the natural logarithms). - * @param x A numeric expression. - */ - expm1(x: number): number; - - /** - * Returns the hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cosh(x: number): number; - - /** - * Returns the hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sinh(x: number): number; - - /** - * Returns the hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tanh(x: number): number; - - /** - * Returns the inverse hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - acosh(x: number): number; - - /** - * Returns the inverse hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - asinh(x: number): number; - - /** - * Returns the inverse hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - atanh(x: number): number; - - /** - * Returns the square root of the sum of squares of its arguments. - * @param values Values to compute the square root for. - * If no arguments are passed, the result is +0. - * If there is only one argument, the result is the absolute value. - * If any argument is +Infinity or -Infinity, the result is +Infinity. - * If any argument is NaN, the result is NaN. - * If all arguments are either +0 or −0, the result is +0. - */ - hypot(...values: number[]): number; - - /** - * Returns the integral part of the a numeric expression, x, removing any fractional digits. - * If x is already an integer, the result is x. - * @param x A numeric expression. - */ - trunc(x: number): number; - - /** - * Returns the nearest single precision float representation of a number. - * @param x A numeric expression. - */ - fround(x: number): number; - - /** - * Returns an implementation-dependent approximation to the cube root of number. - * @param x A numeric expression. - */ - cbrt(x: number): number; -} - -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: (reason: any) => T | PromiseLike): Promise; - catch(onrejected?: (reason: any) => void): Promise; -} - -interface PromiseConstructor { - /** - * A reference to the prototype. - */ - prototype: Promise; - - /** - * Creates a new Promise. - * @param executor A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, - * and a reject callback used to reject the promise with a provided reason or error. - */ - new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - all(values: IterableShim>): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: IterableShim>): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject(reason: any): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject(reason: any): Promise; - - /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ - resolve(value: T | PromiseLike): Promise; - - /** - * Creates a new resolved promise . - * @returns A resolved promise. - */ - resolve(): Promise; -} - -declare var Promise: PromiseConstructor; - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value?: V): Map; - size: number; - entries(): IterableIteratorShim<[K, V]>; - keys(): IterableIteratorShim; - values(): IterableIteratorShim; -} - -interface MapConstructor { - new (): Map; - new (iterable: IterableShim<[K, V]>): Map; - prototype: Map; -} - -declare var Map: MapConstructor; - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; - entries(): IterableIteratorShim<[T, T]>; - keys(): IterableIteratorShim; - values(): IterableIteratorShim; -} - -interface SetConstructor { - new (): Set; - new (iterable: IterableShim): Set; - prototype: Set; -} - -declare var Set: SetConstructor; - -interface WeakMap { - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value?: V): WeakMap; -} - -interface WeakMapConstructor { - new (): WeakMap; - new (iterable: IterableShim<[K, V]>): WeakMap; - prototype: WeakMap; -} - -declare var WeakMap: WeakMapConstructor; - -interface WeakSet { - add(value: T): WeakSet; - delete(value: T): boolean; - has(value: T): boolean; -} - -interface WeakSetConstructor { - new (): WeakSet; - new (iterable: IterableShim): WeakSet; - prototype: WeakSet; -} - -declare var WeakSet: WeakSetConstructor; - -declare module Reflect { - function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; - function enumerate(target: any): IterableIteratorShim; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; - function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; - function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; - function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; - function setPrototypeOf(target: any, proto: any): boolean; -} - -declare module "es6-shim" { - var String: StringConstructor; - var Array: ArrayConstructor; - var Number: NumberConstructor; - var Math: Math; - var Object: ObjectConstructor; - var Map: MapConstructor; - var Set: SetConstructor; - var WeakMap: WeakMapConstructor; - var WeakSet: WeakSetConstructor; - var Promise: PromiseConstructor; - module Reflect { - function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; - function enumerate(target: any): Iterator; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; - function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; - function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; - function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; - function setPrototypeOf(target: any, proto: any): boolean; - } -} diff --git a/typings/globals/jasmine/index.d.ts b/typings/globals/jasmine/index.d.ts deleted file mode 100644 index e81f5ace5d..0000000000 --- a/typings/globals/jasmine/index.d.ts +++ /dev/null @@ -1,502 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c49913aa9ea419ea46c1c684e488cf2a10303b1a/jasmine/jasmine.d.ts -declare function describe(description: string, specDefinitions: () => void): void; -declare function fdescribe(description: string, specDefinitions: () => void): void; -declare function xdescribe(description: string, specDefinitions: () => void): void; - -declare function it(expectation: string, assertion?: () => void, timeout?: number): void; -declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; -declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; -declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; -declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; -declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; - -/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ -declare function pending(reason?: string): void; - -declare function beforeEach(action: () => void, timeout?: number): void; -declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void; -declare function afterEach(action: () => void, timeout?: number): void; -declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void; - -declare function beforeAll(action: () => void, timeout?: number): void; -declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; -declare function afterAll(action: () => void, timeout?: number): void; -declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; - -declare function expect(spy: Function): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; - -declare function fail(e?: any): void; -/** Action method that should be called when the async work is complete */ -interface DoneFn extends Function { - (): void; - - /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */ - fail: (message?: Error|string) => void; -} - -declare function spyOn(object: any, method: string): jasmine.Spy; - -declare function runs(asyncMethod: Function): void; -declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; -declare function waits(timeout?: number): void; - -declare namespace jasmine { - - var clock: () => Clock; - - function any(aclass: any): Any; - function anything(): Any; - function arrayContaining(sample: any[]): ArrayContaining; - function objectContaining(sample: any): ObjectContaining; - function createSpy(name: string, originalFn?: Function): Spy; - function createSpyObj(baseName: string, methodNames: any[]): any; - function createSpyObj(baseName: string, methodNames: any[]): T; - function pp(value: any): string; - function getEnv(): Env; - function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; - function addMatchers(matchers: CustomMatcherFactories): void; - function stringMatching(str: string): Any; - function stringMatching(str: RegExp): Any; - - interface Any { - - new (expectedClass: any): any; - - jasmineMatches(other: any): boolean; - jasmineToString(): string; - } - - // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() - interface ArrayLike { - length: number; - [n: number]: T; - } - - interface ArrayContaining { - new (sample: any[]): any; - - asymmetricMatch(other: any): boolean; - jasmineToString(): string; - } - - interface ObjectContaining { - new (sample: any): any; - - jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; - jasmineToString(): string; - } - - interface Block { - - new (env: Env, func: SpecFunction, spec: Spec): any; - - execute(onComplete: () => void): void; - } - - interface WaitsBlock extends Block { - new (env: Env, timeout: number, spec: Spec): any; - } - - interface WaitsForBlock extends Block { - new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; - } - - interface Clock { - install(): void; - uninstall(): void; - /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ - tick(ms: number): void; - mockDate(date?: Date): void; - } - - interface CustomEqualityTester { - (first: any, second: any): boolean; - } - - interface CustomMatcher { - compare(actual: T, expected: T): CustomMatcherResult; - compare(actual: any, expected: any): CustomMatcherResult; - } - - interface CustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; - } - - interface CustomMatcherFactories { - [index: string]: CustomMatcherFactory; - } - - interface CustomMatcherResult { - pass: boolean; - message?: string; - } - - interface MatchersUtil { - equals(a: any, b: any, customTesters?: Array): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; - buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; - } - - interface Env { - setTimeout: any; - clearTimeout: void; - setInterval: any; - clearInterval: void; - updateInterval: number; - - currentSpec: Spec; - - matchersClass: Matchers; - - version(): any; - versionString(): string; - nextSpecId(): number; - addReporter(reporter: Reporter): void; - execute(): void; - describe(description: string, specDefinitions: () => void): Suite; - // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these - beforeEach(beforeEachFunction: () => void): void; - beforeAll(beforeAllFunction: () => void): void; - currentRunner(): Runner; - afterEach(afterEachFunction: () => void): void; - afterAll(afterAllFunction: () => void): void; - xdescribe(desc: string, specDefinitions: () => void): XSuite; - it(description: string, func: () => void): Spec; - // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these - xit(desc: string, func: () => void): XSpec; - compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; - compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; - equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; - contains_(haystack: any, needle: any): boolean; - addCustomEqualityTester(equalityTester: CustomEqualityTester): void; - addMatchers(matchers: CustomMatcherFactories): void; - specFilter(spec: Spec): boolean; - throwOnExpectationFailure(value: boolean): void; - } - - interface FakeTimer { - - new (): any; - - reset(): void; - tick(millis: number): void; - runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; - scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; - } - - interface HtmlReporter { - new (): any; - } - - interface HtmlSpecFilter { - new (): any; - } - - interface Result { - type: string; - } - - interface NestedResults extends Result { - description: string; - - totalCount: number; - passedCount: number; - failedCount: number; - - skipped: boolean; - - rollupCounts(result: NestedResults): void; - log(values: any): void; - getItems(): Result[]; - addResult(result: Result): void; - passed(): boolean; - } - - interface MessageResult extends Result { - values: any; - trace: Trace; - } - - interface ExpectationResult extends Result { - matcherName: string; - passed(): boolean; - expected: any; - actual: any; - message: string; - trace: Trace; - } - - interface Trace { - name: string; - message: string; - stack: any; - } - - interface PrettyPrinter { - - new (): any; - - format(value: any): void; - iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; - emitScalar(value: any): void; - emitString(value: string): void; - emitArray(array: any[]): void; - emitObject(obj: any): void; - append(value: any): void; - } - - interface StringPrettyPrinter extends PrettyPrinter { - } - - interface Queue { - - new (env: any): any; - - env: Env; - ensured: boolean[]; - blocks: Block[]; - running: boolean; - index: number; - offset: number; - abort: boolean; - - addBefore(block: Block, ensure?: boolean): void; - add(block: any, ensure?: boolean): void; - insertNext(block: any, ensure?: boolean): void; - start(onComplete?: () => void): void; - isRunning(): boolean; - next_(): void; - results(): NestedResults; - } - - interface Matchers { - - new (env: Env, actual: any, spec: Env, isNot?: boolean): any; - - env: Env; - actual: any; - spec: Env; - isNot?: boolean; - message(): any; - - toBe(expected: any, expectationFailOutput?: any): boolean; - toEqual(expected: any, expectationFailOutput?: any): boolean; - toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; - toBeDefined(expectationFailOutput?: any): boolean; - toBeUndefined(expectationFailOutput?: any): boolean; - toBeNull(expectationFailOutput?: any): boolean; - toBeNaN(): boolean; - toBeTruthy(expectationFailOutput?: any): boolean; - toBeFalsy(expectationFailOutput?: any): boolean; - toHaveBeenCalled(): boolean; - toHaveBeenCalledWith(...params: any[]): boolean; - toHaveBeenCalledTimes(expected: number): boolean; - toContain(expected: any, expectationFailOutput?: any): boolean; - toBeLessThan(expected: number, expectationFailOutput?: any): boolean; - toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; - toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean; - toThrow(expected?: any): boolean; - toThrowError(message?: string | RegExp): boolean; - toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean; - not: Matchers; - - Any: Any; - } - - interface Reporter { - reportRunnerStarting(runner: Runner): void; - reportRunnerResults(runner: Runner): void; - reportSuiteResults(suite: Suite): void; - reportSpecStarting(spec: Spec): void; - reportSpecResults(spec: Spec): void; - log(str: string): void; - } - - interface MultiReporter extends Reporter { - addReporter(reporter: Reporter): void; - } - - interface Runner { - - new (env: Env): any; - - execute(): void; - beforeEach(beforeEachFunction: SpecFunction): void; - afterEach(afterEachFunction: SpecFunction): void; - beforeAll(beforeAllFunction: SpecFunction): void; - afterAll(afterAllFunction: SpecFunction): void; - finishCallback(): void; - addSuite(suite: Suite): void; - add(block: Block): void; - specs(): Spec[]; - suites(): Suite[]; - topLevelSuites(): Suite[]; - results(): NestedResults; - } - - interface SpecFunction { - (spec?: Spec): void; - } - - interface SuiteOrSpec { - id: number; - env: Env; - description: string; - queue: Queue; - } - - interface Spec extends SuiteOrSpec { - - new (env: Env, suite: Suite, description: string): any; - - suite: Suite; - - afterCallbacks: SpecFunction[]; - spies_: Spy[]; - - results_: NestedResults; - matchersClass: Matchers; - - getFullName(): string; - results(): NestedResults; - log(arguments: any): any; - runs(func: SpecFunction): Spec; - addToQueue(block: Block): void; - addMatcherResult(result: Result): void; - expect(actual: any): any; - waits(timeout: number): Spec; - waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; - fail(e?: any): void; - getMatchersClass_(): Matchers; - addMatchers(matchersPrototype: CustomMatcherFactories): void; - finishCallback(): void; - finish(onComplete?: () => void): void; - after(doAfter: SpecFunction): void; - execute(onComplete?: () => void): any; - addBeforesAndAftersToQueue(): void; - explodes(): void; - spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; - removeAllSpies(): void; - } - - interface XSpec { - id: number; - runs(): void; - } - - interface Suite extends SuiteOrSpec { - - new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; - - parentSuite: Suite; - - getFullName(): string; - finish(onComplete?: () => void): void; - beforeEach(beforeEachFunction: SpecFunction): void; - afterEach(afterEachFunction: SpecFunction): void; - beforeAll(beforeAllFunction: SpecFunction): void; - afterAll(afterAllFunction: SpecFunction): void; - results(): NestedResults; - add(suiteOrSpec: SuiteOrSpec): void; - specs(): Spec[]; - suites(): Suite[]; - children(): any[]; - execute(onComplete?: () => void): void; - } - - interface XSuite { - execute(): void; - } - - interface Spy { - (...params: any[]): any; - - identity: string; - and: SpyAnd; - calls: Calls; - mostRecentCall: { args: any[]; }; - argsForCall: any[]; - wasCalled: boolean; - } - - interface SpyAnd { - /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ - callThrough(): Spy; - /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ - returnValue(val: any): Spy; - /** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */ - returnValues(...values: any[]): Spy; - /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ - callFake(fn: Function): Spy; - /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ - throwError(msg: string): Spy; - /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ - stub(): Spy; - } - - interface Calls { - /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ - any(): boolean; - /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ - count(): number; - /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ - argsFor(index: number): any[]; - /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ - allArgs(): any[]; - /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ - all(): CallInfo[]; - /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ - mostRecent(): CallInfo; - /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ - first(): CallInfo; - /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ - reset(): void; - } - - interface CallInfo { - /** The context (the this) for the call */ - object: any; - /** All arguments passed to the call */ - args: any[]; - /** The return value of the call */ - returnValue: any; - } - - interface Util { - inherit(childClass: Function, parentClass: Function): any; - formatException(e: any): any; - htmlEscape(str: string): string; - argsToArray(args: any): any; - extend(destination: any, source: any): any; - } - - interface JsApiReporter extends Reporter { - - started: boolean; - finished: boolean; - result: any; - messages: any; - - new (): any; - - suites(): Suite[]; - summarize_(suiteOrSpec: SuiteOrSpec): any; - results(): any; - resultsForSpec(specId: any): any; - log(str: any): any; - resultsForSpecs(specIds: any): any; - summarizeResult_(result: any): any; - } - - interface Jasmine { - Spec: Spec; - clock: Clock; - util: Util; - } - - export var HtmlReporter: HtmlReporter; - export var HtmlSpecFilter: HtmlSpecFilter; - export var DEFAULT_TIMEOUT_INTERVAL: number; -} \ No newline at end of file diff --git a/typings/globals/jasmine/typings.json b/typings/globals/jasmine/typings.json deleted file mode 100644 index 3fb336cf1c..0000000000 --- a/typings/globals/jasmine/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c49913aa9ea419ea46c1c684e488cf2a10303b1a/jasmine/jasmine.d.ts", - "raw": "registry:dt/jasmine#2.2.0+20160621224255", - "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c49913aa9ea419ea46c1c684e488cf2a10303b1a/jasmine/jasmine.d.ts" - } -} diff --git a/typings/index.d.ts b/typings/index.d.ts deleted file mode 100644 index 7cf8a3f75b..0000000000 --- a/typings/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -///