diff --git a/.gitignore b/.gitignore index a4a5374..6ce3994 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,7 @@ hooks/ # autogenerated files www/* -tsd/* -!tsd/tsd.d.ts +typings/* test_out/* # Created by https://www.gitignore.io diff --git a/.travis.yml b/.travis.yml index 550e3fa..01f024d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ sudo: false language: node_js node_js: - - "0.10" + - "v6.2.1" before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - npm install -g typescript - - npm install tsd@next -g + - npm install -g typings - npm install -g gulp - npm install -g ionic - npm install -g bower diff --git a/README.md b/README.md index 8c9b630..54b61d5 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Cucumber tests are located at `features/**/*.feature` -- these were placed outsi Adding dependencies ----------------------- -* For [TSDs](http://definitelytyped.org/tsd/) (to have TypeScript detection), use `tsd install --save`. This may break the `.tsd.d.ts` file -- if this happens, just review the generated file paths carefully before proceeding. +* For [typings](http://definitelytyped.org/) (to have TypeScript detection), use `typings install dt~ --ambient --save`. For more information about how to use typings, see [typings](https://github.com/typings/typings) * For bower (things used in the browser), use `bower install --save` * For npm (things used to build stuff), use `npm install --save-dev` * For 3rd party, non-TSD definitions, placed them in `lib/definitions/`, and don't touch `lib/definitions/e2e-definitions/` unless you want something added to the E2E test build @@ -116,7 +116,7 @@ Notes * The `module` syntax is used to create actual TypeScript modules -- code inside a module is scoped to it. Each feature folder uses its own module name and the shared scope is used in the unit tests to access the declarations without requiring verbose prefixes. * The `angular.module` syntax is an Angular thing for componentizing code. To avoid confusion, wherever possible, the two types of module references should be the same in a file/feature. -* You will need to add new `src/**/.ts` files to `src/definitions.d.ts` to ensure the TypeScript compiler doesn't get confused (see next caveat); if anything breaks in your `tsd/tsd.d.ts` file, [double check the paths didn't get munged](https://github.com/DefinitelyTyped/tsd/issues/112) +* You will need to add new `src/**/.ts` files to `src/definitions.d.ts` to ensure the TypeScript compiler doesn't get confused * When creating interfaces in `.d.ts` files, you can declare them by [prefixing the `module` declaration with `declare`](http://stackoverflow.com/questions/17635033/error-ts1046-declare-modifier-required-for-top-level-element). * Always assume the `www/` folder is scratch space -- including `index.html`! * Place images, fonts, scss, etc. in `assets/` diff --git a/bower.json b/bower.json index 63faed0..fdb67b3 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "typeScriptIonic", "private": "true", "devDependencies": { - "ionic": "driftyco/ionic-bower#1.0.0-beta.14", - "angular-mocks": "1.3.6" + "ionic": "driftyco/ionic-bower#1.3.1", + "angular-mocks": "1.5.3" } } diff --git a/cucumber.conf.js b/cucumber.conf.js index 15bca9d..6495031 100644 --- a/cucumber.conf.js +++ b/cucumber.conf.js @@ -1,20 +1,54 @@ -// protractor configuration file for cucumber -exports.config = { - allScriptsTimeout: 11000, +'use strict'; + +const SHARD_COUNT = exports.SHARD_COUNT || 2; + +const _ = require('lodash'); +const glob = require('glob'); +const fs = require('fs'); + +const cucumberOpts = { + format: ['pretty', 'json:results.json'], + require: 'features/step_definitions/**/*.js', + 'no-source': true +}; + +function getShardedFeatures(allFeatures) { + const featuresPerShard = Math.floor(allFeatures.length / SHARD_COUNT); - specs: [ - 'features/**/*.feature' - ], + return _.reduce(allFeatures, function (memo, feature) { + let lastShard = _.last(memo); - capabilities: { - 'browserName': 'chrome' - }, + if (lastShard.length >= featuresPerShard) { + lastShard = []; + memo.push(lastShard); + } - baseUrl: 'http://localhost:8000/', + lastShard.push(feature); + return memo; + }, [[]]); +} - framework: 'cucumber', - cucumberOpts: { - require: 'features/', - format: "pretty" - } -}; \ No newline at end of file +function getMultiCapabilities () { + const shards = getShardedFeatures(glob.sync('features/**/*.feature')); + + return _.map(shards, function (files, i) { + const shardNumber = ++i; + + return { + browserName: 'chrome', + specs: files, + cucumberOpts: _.tap(_.clone(cucumberOpts), function (options) { + options.format = _.map(options.format, function (format) { + return format.replace(/\.json/, `-${shardNumber}.json`); + }); + }) + }; + }); +} + +exports.config = { + framework: 'custom', + frameworkPath: 'node_modules/protractor-cucumber-framework', + cucumberOpts, + getMultiCapabilities +}; diff --git a/features/step_definitions/pages.js b/features/step_definitions/pages.js index e5d016c..34d6c7f 100644 --- a/features/step_definitions/pages.js +++ b/features/step_definitions/pages.js @@ -3,13 +3,13 @@ chai.use(require('chai-as-promised')); var expect = chai.expect; var steps = function () { - var Given = When = Then = this.defineStep + var Given = When = Then = this.defineStep; // centralize page definitions and navigation to them var pages = { 'home': '/app/home', 'login': '/app/login' - } + }; Given(/visit the (\w+) page$/, function (pageName, next) { this.browser.get('http://localhost:8000/#' + pages[pageName]); diff --git a/gulpfile.js b/gulpfile.js index e52506a..8d8581e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,7 +16,7 @@ var paths = { e2e: ['src/**/*.e2e.ts', './lib/definitions/e2e-definitions/**/*.d.ts'], sass: ['./assets/scss/**/*.scss', './assets/scss/*.scss'], ts: ['src/*.ts', 'src/**/*.ts', 'lib/**/*.ts', '!lib/definitions/e2e-definitions/**/*.d.ts', '!src/*.js', '!src/**/*.js'], - tsds: ['*.d.ts', 'tsd/**/*.d.ts', 'src/*.d.ts', 'src/**/*.d.ts', 'lib/definitions/**/*.d.ts', '!lib/definitions/e2e-definitions/**/*.d.ts', '!src/**/*.e2e.ts'], + typings: ['*.d.ts', 'typings/**/*.d.ts', 'src/*.d.ts', 'src/**/*.d.ts', 'lib/definitions/**/*.d.ts', '!lib/definitions/e2e-definitions/**/*.d.ts', '!src/**/*.e2e.ts'], tsSpec: ['src/**/*.spec.ts'], html: ['src/**/*.html'], lib: ['lib/**/*.js'], @@ -51,14 +51,14 @@ gulp.task('watch', function () { gulp.task('watch-tasks', function () { gulp.watch(paths.e2e, ['tsE2E', 'tslint']); gulp.watch(paths.sass, ['css']); - gulp.watch(paths.ts.concat(paths.tsds), ['ts', 'tsTest', 'tsE2E', 'tslint']); + gulp.watch(paths.ts.concat(paths.typings), ['ts', 'tsTest', 'tsE2E', 'tslint']); gulp.watch(paths.html, ['html']); gulp.watch(paths.fonts, ['fonts']); gulp.watch(paths.images, ['images']); gulp.watch(paths.index, ['index']); gulp.watch(paths.lib, ['lib']); gulp.watch(paths.testJs, ['runJustTest']); -}) +}); /* * purges all generated files @@ -154,7 +154,7 @@ var tsProject = ts.createProject({ noExternalResolve: true }); gulp.task('ts', function () { - return gulp.src(paths.ts.concat(paths.tsds, ['!' + testFilePattern])) + return gulp.src(paths.ts.concat(paths.typings, ['!' + testFilePattern])) .pipe(sourcemaps.init({debug: true})) .pipe(ts(tsProject)) .pipe(concat('app.js')) diff --git a/lib/definitions/ionic/ionic.d.ts b/lib/definitions/ionic/ionic.d.ts deleted file mode 100644 index c072462..0000000 --- a/lib/definitions/ionic/ionic.d.ts +++ /dev/null @@ -1,1402 +0,0 @@ - -/** - * Define a global ionic object - */ -declare var ionic: Ionic.IBase; - -declare module Ionic -{ - - //#region Base - interface IBase - { - Platform: IPlatform; - DomUtil: IDomUtil; - EventController: IEventController; - - //#region EventController Aliases - /** - * @param eventType The event to trigger - * @param data The data for the event. Hint: pass in {target: targetElement} - * @param bubbles Whether the event should bubble up the DOM - * @param cancelable Whether the event should be cancelable - */ - trigger(eventType: string, data: Object, bubbles?: boolean, cancelable?: boolean): void; - - /** - * Listen to an event on an element. - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - on(type: string, callback: () => void, element: Element): void; - - - /** - * Remove an event listener - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - off(type: string, callback: () => void, element: Element): void; - - /** - * Add an event listener for a gesture on an element. - * - * @param eventType The gesture event to listen for - * @param callback The function to call when the gesture happens - * @param element The angular element to listen for the event on - */ - onGesture(eventType: string, callback: () => void, element: Element): void; - onGesture(eventType: "hold", callback: () => void, element: Element): void; - onGesture(eventType: "tap", callback: () => void, element: Element): void; - onGesture(eventType: "doubletap", callback: () => void, element: Element): void; - onGesture(eventType: "drag", callback: () => void, element: Element): void; - onGesture(eventType: "dragstart", callback: () => void, element: Element): void; - onGesture(eventType: "dragend", callback: () => void, element: Element): void; - onGesture(eventType: "dragup", callback: () => void, element: Element): void; - onGesture(eventType: "dragdown", callback: () => void, element: Element): void; - onGesture(eventType: "dragleft", callback: () => void, element: Element): void; - onGesture(eventType: "dragright", callback: () => void, element: Element): void; - onGesture(eventType: "swipe", callback: () => void, element: Element): void; - onGesture(eventType: "swipeup", callback: () => void, element: Element): void; - onGesture(eventType: "swipedown", callback: () => void, element: Element): void; - onGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - onGesture(eventType: "swiperight", callback: () => void, element: Element): void; - onGesture(eventType: "transform", callback: () => void, element: Element): void; - onGesture(eventType: "transformstart", callback: () => void, element: Element): void; - onGesture(eventType: "transformend", callback: () => void, element: Element): void; - onGesture(eventType: "rotate", callback: () => void, element: Element): void; - onGesture(eventType: "pinch", callback: () => void, element: Element): void; - onGesture(eventType: "pinchin", callback: () => void, element: Element): void; - onGesture(eventType: "pinchout", callback: () => void, element: Element): void; - onGesture(eventType: "touch", callback: () => void, element: Element): void; - onGesture(eventType: "release", callback: () => void, element: Element): void; - - /** - * Remove an event listener for a gesture on an element. - * - * @param eventType The gesture event - * @param callback The listener that was added earlier - * @param element The element the listener was added on - */ - offGesture(eventType: string, callback: () => void, element: Element): void; - offGesture(eventType: "hold", callback: () => void, element: Element): void; - offGesture(eventType: "tap", callback: () => void, element: Element): void; - offGesture(eventType: "doubletap", callback: () => void, element: Element): void; - offGesture(eventType: "drag", callback: () => void, element: Element): void; - offGesture(eventType: "dragstart", callback: () => void, element: Element): void; - offGesture(eventType: "dragend", callback: () => void, element: Element): void; - offGesture(eventType: "dragup", callback: () => void, element: Element): void; - offGesture(eventType: "dragdown", callback: () => void, element: Element): void; - offGesture(eventType: "dragleft", callback: () => void, element: Element): void; - offGesture(eventType: "dragright", callback: () => void, element: Element): void; - offGesture(eventType: "swipe", callback: () => void, element: Element): void; - offGesture(eventType: "swipeup", callback: () => void, element: Element): void; - offGesture(eventType: "swipedown", callback: () => void, element: Element): void; - offGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - offGesture(eventType: "swiperight", callback: () => void, element: Element): void; - offGesture(eventType: "transform", callback: () => void, element: Element): void; - offGesture(eventType: "transformstart", callback: () => void, element: Element): void; - offGesture(eventType: "transformend", callback: () => void, element: Element): void; - offGesture(eventType: "rotate", callback: () => void, element: Element): void; - offGesture(eventType: "pinch", callback: () => void, element: Element): void; - offGesture(eventType: "pinchin", callback: () => void, element: Element): void; - offGesture(eventType: "pinchout", callback: () => void, element: Element): void; - offGesture(eventType: "touch", callback: () => void, element: Element): void; - offGesture(eventType: "release", callback: () => void, element: Element): void; - - //#endregion - - //#region DomUtil Aliases - - /** - * Calls requestAnimationFrame, or a polyfill if not available. - * - * @param callback The function to call when the next frame happens - */ - requestAnimationFrame(callback: () => void): void; - - /** - * When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls. - * - * @param callback a function which will be throttled to requestAnimationFrame - */ - animationFrameThrottle(callback: () => void): void; - - //#endregion - } - //#endregion - - //#region Config Provider - /** - * Angular service: $ionicConfigProvider - * - * $ionicConfigProvider can be used during the configuration phase of your app to change how Ionic works. - */ - interface IConfigProvider - { - /** - * Set whether Ionic should prefetch all templateUrls defined in $stateProvider.state. Default true. - * If set to false, the user will have to wait for a template to be fetched the first time he/she is going to a a new page. - * - * @param shouldPrefetch Whether Ionic should prefetch templateUrls defined in $stateProvider.state(). Default true. - */ - prefetchTemplates(shouldPrefetch: boolean): boolean; - } - //#endregion - - //#region Platform - - interface IDevice - { - /** Get the version of Cordova running on the device. */ - cordova: string; - /** - * The device.model returns the name of the device's model or product. The value is set - * by the device manufacturer and may be different across versions of the same product. - */ - model: string; - /** device.name is deprecated as of version 2.3.0. Use device.model instead. */ - name: string; - /** Get the device's operating system name. */ - platform: string; - /** Get the device's Universally Unique Identifier (UUID). */ - uuid: string; - /** Get the operating system version. */ - version: string; - } - - - interface IPlatform - { - //#region Properties - /** - * Whether the device is ready - */ - isReady: boolean; - - /** - * Whether the device is full screen. - */ - isFullScreen: boolean; - - /** - * An array of all platforms found. - */ - platforms: string[]; - - /** - * What grade the current platform is. - */ - grade: string; - //#endregion - - - /** - * Trigger a callback once the device is ready, or immediately if the device is already ready. - * This method can be run from anywhere and does not need to be wrapped by any additional methods. - * When the app is within a WebView (Cordova), it'll fire the callback once the device is ready. - * If the app is within a web browser, it'll fire the callback after window.load. - */ - ready(callback: () => void): void; - - /** - * Set the grade of the device: 'a', 'b', or 'c'. 'a' is the best (most css features enabled), - * 'c' is the worst. By default, sets the grade depending on the current device. - */ - setGrade(grade): void; - - /** - * Return the current device (given by Cordova). - */ - device(): IDevice; - - /** - * Check if we are running within a WebView (such as Cordova). - */ - isWebView(): boolean; - - /** - * Whether we are running on iPad. - */ - isIPad(): boolean; - - /** - * Whether we are running on iOS. - */ - isIOS(): boolean; - - /** - * Whether we are running on Android - */ - isAndroid(): boolean; - - /** - * Whether we are running on Windows Phone. - */ - isWindowsPhone(): boolean; - - /** - * The name of the current platform. - */ - platform(): string; - - /** - * The version of the current device platform. - */ - version(): string; - - /** - * Exit the application. - */ - exitApp(): void; - - /** - * Shows or hides the device status bar (in Cordova). - * - * @param showShould Whether or not to show the status bar. - */ - showStatusBar(shouldShow: boolean): void; - - /** - * Sets whether the app is full screen or not (in Cordova). - * - * @param showFullScreen Whether or not to set the app to full screen. Defaults to true. - * @param showStatusBar Whether or not to show the device's status bar. Defaults to false. - */ - fullScreen(showFullScreen: boolean, showStatusBar: boolean): void; - } - //#endregion - - // #region Dom Utils - - /** - * ionic.DomUtil - */ - interface IDomUtil - { - /** - * alias: ionic.requestAnimationFrame - * - * Calls requestAnimationFrame, or a polyfill if not available. - * - * @param callback The function to call when the next frame happens - */ - requestAnimationFrame(callback: () => void): void; - - /** - * alias: ionic.animationFrameThrottle - * - * When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls. - * - * @param callback a function which will be throttled to requestAnimationFrame - */ - animationFrameThrottle(callback: () => void): void; - - /** - * Find an element's scroll offset within its container - * - * @param element The element to find the offset of - */ - getPositionInParent(element: Element): void; - - /** - * The Window.requestAnimationFrame() method tells the browser that you wish to perform an animation and requests that the browser - * call a specified function to update an animation before the next repaint. - * The method takes as an argument a callback to be invoked before the repaint. - * - * @param callback The function to be called - */ - ready(callback: () => void): void; - - /** - * Get a rect representing the bounds of the given textNode. - */ - getTextBounds(textNode: Element): { - left: number; - right: number; - top: number; - bottom: number; - width: number; - height: number; - }; - - /** - * Get the first index of a child node within the given element of the specified type. - * - * @param element The element to find the index of. - * @param type The nodeName to match children of element against. - */ - getChildIndex(element: Element, type: string): number; - - /** - * Returns the closest parent of element matching the className, or null. - * - * @param element - * @param className - */ - getParentWithClass(element: Element, className: string): Element - - /** - * Returns the closest parent or self matching the className, or null. - */ - getParentOrSelfWithClass(element: Element, className: string): Element; - - - /** - * Returns whether {x,y} fits within the rectangle defined by {x1,y1,x2,y2}. - * - * @param x - * @param y - * @param x1 - * @param y1 - * @param x2 - * @param y2 - */ - rectContains(x: number, y: number, x1: number, y1: number, x2: number, y2: number): boolean; - } - //#endregion - - //#region EventController - - /** - * Angular service: $ionicGesture - */ - interface IEventController - { - /** - * alias: ionic.trigger - * - * @param eventType The event to trigger - * @param data The data for the event. Hint: pass in {target: targetElement} - * @param bubbles Whether the event should bubble up the DOM - * @param cancelable Whether the event should be cancelable - */ - trigger(eventType: string, data: Object, bubbles?: boolean, cancelable?: boolean): void; - - /** - * alias: ionic.on - * - * Listen to an event on an element - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - on(type: string, callback: () => void, element: Element): void; - - /** - * alias: ionic.off - * - * Remove an event listener - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - off(type: string, callback: () => void, element: Element): void; - - /** - * alias: ionic.onGesture - * - * Add an event listener for a gesture on an element. - * - * @param eventType The gesture event to listen for - * @param callback The function to call when the gesture happens - * @param element The angular element to listen for the event on - */ - onGesture(eventType: string, callback: () => void, element: Element): void; - onGesture(eventType: "hold", callback: () => void, element: Element): void; - onGesture(eventType: "tap", callback: () => void, element: Element): void; - onGesture(eventType: "doubletap", callback: () => void, element: Element): void; - onGesture(eventType: "drag", callback: () => void, element: Element): void; - onGesture(eventType: "dragstart", callback: () => void, element: Element): void; - onGesture(eventType: "dragend", callback: () => void, element: Element): void; - onGesture(eventType: "dragup", callback: () => void, element: Element): void; - onGesture(eventType: "dragdown", callback: () => void, element: Element): void; - onGesture(eventType: "dragleft", callback: () => void, element: Element): void; - onGesture(eventType: "dragright", callback: () => void, element: Element): void; - onGesture(eventType: "swipe", callback: () => void, element: Element): void; - onGesture(eventType: "swipeup", callback: () => void, element: Element): void; - onGesture(eventType: "swipedown", callback: () => void, element: Element): void; - onGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - onGesture(eventType: "swiperight", callback: () => void, element: Element): void; - onGesture(eventType: "transform", callback: () => void, element: Element): void; - onGesture(eventType: "transformstart", callback: () => void, element: Element): void; - onGesture(eventType: "transformend", callback: () => void, element: Element): void; - onGesture(eventType: "rotate", callback: () => void, element: Element): void; - onGesture(eventType: "pinch", callback: () => void, element: Element): void; - onGesture(eventType: "pinchin", callback: () => void, element: Element): void; - onGesture(eventType: "pinchout", callback: () => void, element: Element): void; - onGesture(eventType: "touch", callback: () => void, element: Element): void; - onGesture(eventType: "release", callback: () => void, element: Element): void; - - /** - * alias: ionic.offGesture - * - * Remove an event listener for a gesture on an element. - * - * @param eventType The gesture event - * @param callback The listener that was added earlier - * @param element The element the listener was added on - */ - offGesture(eventType: string, callback: () => void, element: Element): void; - offGesture(eventType: "hold", callback: () => void, element: Element): void; - offGesture(eventType: "tap", callback: () => void, element: Element): void; - offGesture(eventType: "doubletap", callback: () => void, element: Element): void; - offGesture(eventType: "drag", callback: () => void, element: Element): void; - offGesture(eventType: "dragstart", callback: () => void, element: Element): void; - offGesture(eventType: "dragend", callback: () => void, element: Element): void; - offGesture(eventType: "dragup", callback: () => void, element: Element): void; - offGesture(eventType: "dragdown", callback: () => void, element: Element): void; - offGesture(eventType: "dragleft", callback: () => void, element: Element): void; - offGesture(eventType: "dragright", callback: () => void, element: Element): void; - offGesture(eventType: "swipe", callback: () => void, element: Element): void; - offGesture(eventType: "swipeup", callback: () => void, element: Element): void; - offGesture(eventType: "swipedown", callback: () => void, element: Element): void; - offGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - offGesture(eventType: "swiperight", callback: () => void, element: Element): void; - offGesture(eventType: "transform", callback: () => void, element: Element): void; - offGesture(eventType: "transformstart", callback: () => void, element: Element): void; - offGesture(eventType: "transformend", callback: () => void, element: Element): void; - offGesture(eventType: "rotate", callback: () => void, element: Element): void; - offGesture(eventType: "pinch", callback: () => void, element: Element): void; - offGesture(eventType: "pinchin", callback: () => void, element: Element): void; - offGesture(eventType: "pinchout", callback: () => void, element: Element): void; - offGesture(eventType: "touch", callback: () => void, element: Element): void; - offGesture(eventType: "release", callback: () => void, element: Element): void; - } - - //#endregion - - //#region Ionic Position - - /** - * Angular service: $ionicPosition - * - * A set of utility methods that can be use to retrieve position of DOM elements. - * It is meant to be used where we need to absolute-position DOM elements in relation to other, existing elements (this is the case for tooltips, popovers, etc.). - */ - interface IPosition - { - /** - * Get the current coordinates of the element, relative to the offset parent. Read-only equivalent of jQuery's position function. - * - * @param element The element to get the position of - */ - position(element: Element): { - top: number; - left: number; - width: number; - height: number; - } - - /** - * Get the current coordinates of the element, relative to the document. Read-only equivalent of jQuery's offset function. - * - * @param element The element to get offset of - */ - offset(element: Element): { - top: number; - left: number; - width: number; - height: number; - } - } - - //#endregion - - - //#region Action Sheet - interface IActionSheetOptions - { - /** - * Which buttons to show. Each button is an object with a text field. - */ - buttons?: Array<{ text: string }>; - - /** - * The title to show on the action sheet. - */ - titleText?: string; - - /** - * The text for a 'cancel' button on the action sheet. - */ - cancelText?: string; - - /** - * The text for a 'danger' on the action sheet. - */ - destructiveText?: string; - - /** - * Called if the cancel button is pressed, the backdrop is tapped or the hardware back button is pressed. - */ - cancel?: () => void; - - /** - * Called when one of the non-destructive buttons is clicked, with the index of the button that was clicked and the button object. - * Return true to close the action sheet, or false to keep it opened. - */ - buttonClicked?: () => boolean; - - /** - * Called when the destructive button is clicked. Return true to close the action sheet, or false to keep it opened. - */ - destructiveButtonClicked?: () => boolean; - - /** - * Whether to cancel the actionSheet when navigating to a new state. Default true. - */ - cancelOnStateChange?: boolean; - } - - - /** - * Angular service: $ionicActionSheet - * - * The Action Sheet is a slide-up pane that lets the user choose from a set of options. Dangerous options are highlighted in red and made obvious. - * There are easy ways to cancel out of the action sheet, such as tapping the backdrop or even hitting escape on the keyboard for desktop testing. - */ - interface IActionSheet - { - /** - * Load and return a new action sheet. - * A new isolated scope will be created for the action sheet and the new element will be appended into the body. - * - * Returns hideSheet, a function which, when called, hides & cancels the action sheet. - */ - show(options: IActionSheetOptions): () => void; - } - //#endregion - - //#region Backdrop - - /** - * Angular service: $ionicBackdrop - */ - interface IBackdrop - { - /** - * Retains the backdrop. - */ - retain(): void; - - /** - * Releases the backdrop. - */ - release(): void; - } - //#endregion - - //#region Gesture - - /** - * Angular service: $ionicGesture - */ - interface IGesture extends IEventController { } - - //#endregion - - //#region Lists - - /** - * Angular service: $ionicListDelegate - * - * Delegate for controlling the ionList directive. - * Methods called directly on the $ionicListDelegate service will control all lists. Use the $getByHandle method to control specific ionList instances. - */ - interface IListDelegate - { - /** - * Set whether or not this list is showing its reorder buttons. - * Returns whether the reorder buttons are shown. - */ - showReorder(showReorder?: boolean): boolean; - - /** - * Set whether or not this list is showing its delete buttons. - * Returns whether the delete buttons are shown. - */ - showDelete(showDelete?: boolean): boolean; - - /** - * Set whether or not this list is able to swipe to show option buttons. - * Returns whether the list is able to swipe to show option buttons. - */ - canSwipeItems(canSwipeItems?: boolean): boolean; - - /** - * Closes any option buttons on the list that are swiped open. - */ - closeOptionButtons(): void; - - /** - * Return delegate instance that controls only the ionTabs directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): IListDelegate; - } - //#endregion - - //#region Loading - interface ILoadingOptions - { - template?: string; - templateUrl?: string; - noBackdrop?: boolean; - delay?: number; - duration?: number; - } - - /** - * Angular service: $ionicLoading - * - * An overlay that can be used to indicate activity while blocking user interaction. - */ - interface ILoading - { - show(opts?: ILoadingOptions): void; - - hide(): void; - } - //#endregion - - //#region Modals - - interface IModalOptions - { - /** - * The scope to be a child of. Default: creates a child of $rootScope. - */ - scope?: ng.IScope; - - /** - * The animation to show & hide with. Default: 'slide-in-up' - */ - animation?: string; - - /** - * Whether to autofocus the first input of the modal when shown. Default: false. - */ - focusFirstInput?: boolean; - - /** - * Whether to close the modal on clicking the backdrop. Default: true. - */ - backdropClickToClose?: boolean; - - /** - * Whether the modal can be closed using the hardware back button on Android and similar devices. Default: true. - */ - hardwareBackButtonClose?: boolean; - } - - /** - * Angular service: $ionicModal - */ - interface IModal - { - /** - * Creates a new modal controller instance. - * - * @param options An IModalOptions object - */ - initialize(options: IModalOptions): void; - - // TODO: add Promise object as returns - - /** - * Show this modal instance - * Returns a promise which is resolved when the modal is finished animating in - */ - show(): any; - - /** - * Hide this modal instance - * Returns a promise which is resolved when the modal is finished animating out - */ - hide(): any; - - /** - * Remove this modal instance from the DOM and clean up - * Returns a promise which is resolved when the modal is finished animating out - */ - remove(): any; - - /** - * Returns whether this modal is currently shown. - */ - isShown(): boolean; - } - - //#endregion - - //#region Navigation - - /** - * Angular service: $ionicNavBarDelegate - * - * Delegate for controlling the ionNavBar directive. - */ - interface INavBarDelegate - { - /** - * Goes back in the view history - * - * @param event The event object (eg from a tap event) - */ - back(event?: Event): void; - - /** - * Aligns the title with the buttons in a given direction - * - * @param direction The direction to the align the title text towards. Available: 'left', 'right', 'center'. Default: 'center'. - */ - align(direction?: string): void; - align(direction: "left"): void; - align(direction: "right"): void; - align(direction: "center"): void; - - /** - * Set/get whether the ionNavBackButton is shown (if it exists). - * Returns whether the back button is shown - * - * @param show Whether to show the back button - */ - showBackButton(show?: boolean): boolean; - - /** - * Set/get whether the ionNavBar is shown - * Returns whether the bar is shown - * - * @param show whether to show the bar - */ - showBar(show?: boolean): boolean; - - /** - * Set the title for the ionNavBar - * - * @param title The new title to show - */ - setTitle(title: string): void; - - /** - * Change the title, transitioning the new title in and the old one out in a given direction - * - * @param title the new title to show - * @param direction the direction to transition the new title in. Available: 'forward', 'back'. - */ - changeTitle(title: string, direction: string): void; - changeTitle(title: string, direction: "forward"): void; - changeTitle(title: string, direction: "back"): void; - - /** - * Returns the current title of the navbar. - */ - getTitle(): string; - - /** - * Returns the previous title of the navbar. - */ - getPreviousTitle(): string; - - /** - * Return a delegate instance that controls only the navBars with delegate-handle matching the given handl - */ - $getByHandle(handle: string): INavBarDelegate; - } - - //#endregion - - //#region Popover - - interface IPopoverOptions - { - /** - * The scope to be a child of. Default: creates a child of $rootScope - */ - scope?: ng.IScope; - - /** - * Whether to autofocus the first input of the popover when shown. Default: false - */ - focusFirstInput?: boolean; - - /** - * Whether to close the popover on clicking the backdrop. Default: true - */ - backdropClickToClose?: boolean; - - /** - * Whether the popover can be closed using the hardware back button on Android and similar devices. Default: true - */ - hardwareBackButtonClose?: boolean; - } - - /** - * Angular service: $ionicPopover - * - * The Popover is a view that floats above an app’s content. - * Popovers provide an easy way to present or gather information from the user and are commonly used in the following situations: - * show more info about the current view, select a commonly used tool or configuration, present a list of actions to perform inside one of your views. - * Put the content of the popover inside of an element - */ - interface IPopover - { - /** - * @param templateString The template string to use as the popovers's content - * @param Options to be passed to the initialize method - */ - fromTemplate(templateString: string, options: IPopoverOptions): IPopover; - - // TODO: promise - /** - * Returns a promise that will be resolved with an instance of an ionicPopover controller ($ionicPopover is built on top of $ionicPopover). - * - * @param templateUrl The url to load the template from - * @param Options to be passed to the initialize method - */ - fromTemplateUrl(templateUrl: string, options: IPopoverOptions): any; - - /** - * Creates a new popover controller instance - * - */ - initialize(options: IPopoverOptions): void; - - // TODO: promise - /** - * Show this popover instance. - * Returns a promise which is resolved when the popover is finished animating in. - * - * @param $event The $event or target element which the popover should align itself next to. - */ - show($event: any): any; - - // TODO: promise - /** - * Hide this popover instance. - * Returns a promise which is resolved when the popover is finished animating out. - */ - hide(): any; - - // TODO: promise - /** - * Remove this popover instance from the DOM and clean up. - * Returns a promise which is resolved when the popover is finished animating out. - */ - remove(): any; - - /** - * Returns whether this popover is currently shown. - */ - isShown(): boolean; - } - - //#endregion - - //#region Popup - - interface IPopupButton - { - text: string; - type: string; - onTap(e: Event): void; - } - - interface IPopupOptions - { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * A scope to link to the popup content - */ - scope?: ng.IScope; - - /** - * Buttons to place in the popup footer - */ - buttons?: Array; - } - - interface IPopupAlertOptions - { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - interface IPopupConfirmOptions - { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The text of the Cancel button - */ - canelText?: string; - - /** - * The type of the Cancel button - */ - cancelType?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - interface IPopupPromptOptions - { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The type of input of use - */ - inputType: string; - - /** - * A placeholder to use for the input - */ - inputPlaceholder: string; - - /** - * The text of the Cancel button - */ - canelText?: string; - - /** - * The type of the Cancel button - */ - cancelType?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - /** - * Angular service: $ionicPopup - * - * The Ionic Popup service allows programmatically creating and showing popup windows that require the user to respond in order to continue. - * The popup system has support for more flexible versions of the built in alert(), prompt(), and confirm() functions that users are used to, - * in addition to allowing popups with completely custom content and look. - * An input can be given an autofocus attribute so it automatically receives focus when the popup first shows. - * However, depending on certain use-cases this can cause issues with the tap/click system, - * which is why Ionic prefers using the autofocus attribute as an opt-in feature and not the default. - */ - interface IPopup - { - // TODO: promise - /** - * Show a complex popup. This is the master show function for all popups. - * A complex popup has a buttons array, with each button having a text and type field, in addition to an onTap function. - * The onTap function, called when the correspondingbutton on the popup is tapped, - * will by default close the popup and resolve the popup promise with its return value. - * If you wish to prevent the default and keep the popup open on button tap, call event.preventDefault() on the passed in tap event. - * - * Returns a promise which is resolved when the popup is closed. Has an additional close function, which can be used to programmatically close the popup. - * - * @param options The options for the new popup - */ - show(options: IPopupOptions): any; - - /** - * Show a simple alert popup with a message and one button that the user can tap to close the popup. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @param options The options for showing the alert - */ - alert(options: IPopupAlertOptions): any; - - /** - * Show a simple confirm popup with a Cancel and OK button. - * Resolves the promise with true if the user presses the OK button, and false if the user presses the Cancel button. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @parma options The options for showing the confirm popup - */ - confirm(options: IPopupConfirmOptions): any; - - /** - * Show a simple prompt popup, which has an input, OK button, and Cancel button. Resolves the promise with the value of the input if the user presses OK, and with undefined if the user presses Cancel. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @param options The options for showing the prompt popup - */ - prompt(options: IPopupPromptOptions): any; - } - - //#endregion - - //#region Scroll - interface IScrollPosition - { - /** - * The distance the user has scrolled from the left (starts at 0) - */ - left: number; - - /** - * The distance the user has scrolled from the top (starts at 0) - */ - top: number; - } - - /** - * Angular service: $ionicScrollDelegate - * - * Delegate for controlling scrollViews (created by ionContent and ionScroll directives). - * Methods called directly on the $ionicScrollDelegate service will control all scroll views. Use the $getByHandle method to control specific scrollViews. - */ - interface IScrollDelegate - { - /** - * Tell the scrollView to recalculate the size of its container - */ - resize(): void; - - - /** - * @param shouldAnimate Whether the scroll should animate - */ - scrollTop(shouldAnimate?: boolean): void; - - - /** - * @param shouldAnimate Whether the scroll should animate - */ - scrollBottom(shouldAnimate?: boolean): void; - - - - /** - * @param left The x-value to scroll to - * @param top The y-value to scroll to - * @param shouldAnimate Whether the scroll should animate - */ - scrollTo(left: number, top: number, shouldAnimate?: boolean): void; - - /** - * @param left The x-offset to scroll by - * @param top The y-offset to scroll by - * @param shouldAnimate Whether the scroll should animate - */ - scrollBy(left: number, top: number, shouldAnimate?: boolean): void; - - /** - * @param level Level to zoom to - * @param animate Whether to animate the zoom - * @param originLeft Zoom in at given left coordinate - * @param originTop Zoom in at given top coordinate - */ - zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void; - - /** - * @param factor The factor to zoom by - * @param animate Whether to animate the zoom - * @param originLeft Zoom in at given left coordinate - * @param originTop Zoom in at given top coordinate - */ - zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void; - - /** - * Returns the scroll position of this view - */ - getScrollPosition(): IScrollPosition; - - /** - * Tell the scrollView to scroll to the element with an id matching window.location.hash - * If no matching element is found, it will scroll to top - * - * @param shouldAnimate Whether the scroll should animate - */ - anchorScroll(shouldAnimate?: boolean): void; - - /** - * Returns the scrollView associated with this delegate. - */ - // TODO: define ScrollView object - getScrollView(): any; - - /** - * Stop remembering the scroll position for this scrollView - */ - forgetScrollPosition(): void; - - /** - * If this scrollView has an id associated with its scroll position, (through calling rememberScrollPosition), and that position is remembered, load the position and scroll to it. - * - * @param shouldAnimate Whether the scroll should animate - */ - scrollToRememberedPosition(shouldAnimate?: boolean): void; - - /** - * Return a delegate instance that controls only the scrollViews with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): IScrollDelegate; - } - //#endregion - - //#region Side Menus - - /** - * Angular service: $ionicSideMenuDelegate - * - * Delegate for controlling the ionSideMenus directive. - * Methods called directly on the $ionicSideMenuDelegate service will control all side menus. Use the $getByHandle method to control specific ionSideMenus instances. - */ - interface ISideMenuDelegate - { - /** - * Toggle the left side menu (if it exists). - * - * @param isOpen Whether to open or close the menu. Default: Toggles the menu. - */ - toggleLeft(isOpen?: boolean): void; - - - /** - * Toggle the right side menu (if it exists). - * - * @param isOpen Whether to open or close the menu. Default: Toggles the menu. - */ - toggleRight(isOpen?: boolean): void; - - /** - * Gets the ratio of open amount over menu width. For example, a menu of width 100 that is opened by 50 pixels is 50% opened, and would return a ratio of 0.5. - * Returns 0 if nothing is open, between 0 and 1 if left menu is opened/opening, and between 0 and -1 if right menu is opened/opening. - */ - getOpenRatio(): number; - - /** - * Returns whether either the left or right menu is currently opened. - */ - isOpen(): boolean; - - /** - * Returns whether the left menu is currently opened. - */ - isOpenLeft(): boolean; - - /** - * Returns whether the right menu is currently opened. - */ - isOpenRight(): boolean; - - /** - * Returns whether the content can be dragged to open side menus. - * - * @param canDrag Set whether the content can or cannot be dragged to open side menus - */ - canDragContent(canDrag?: boolean): boolean; - - /** - * Returns whether the drag can start only from within the edge of screen threshold. - * - * @param value Set whether the content drag can only start if it is below a certain threshold distance from the edge of the screen. If a non-zero number is given, that many pixels is used as the maximum allowed distance from the edge that starts dragging the side menu. If 0 is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed. - */ - edgeDragThreshold(value: boolean): boolean; - - /** - * Returns whether the drag can start only from within the edge of screen threshold. - * - * @param value Set whether the content drag can only start if it is below a certain threshold distance from the edge of the screen. If true is given, the default number of pixels (25) is used as the maximum allowed distance. If false is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed. - */ - edgeDragThreshold(value: number): boolean; - - /** - * Return a delegate instance that controls only the ionSideMenus directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ISideMenuDelegate; - } - - //#endregion - - //#region Slide Box - - /** - * Angular service: $ionicSlideBoxDelegate - * - * Delegate that controls the ionSlideBox directive. - * Methods called directly on the $ionicSlideBoxDelegate service will control all slide boxes. Use the $getByHandle method to control specific slide box instances. - */ - interface ISlideBoxDelegate - { - /** - * Update the slidebox (for example if using Angular with ng-repeat, resize it for the elements inside). - */ - update(): void; - - /** - * @param to The index to slide to - * @param speed The number of milliseconds for the change to take - */ - slide(to: number, speed?: number): void; - - /** - * Returns whether sliding is enabled. - * - * @param shouldEnable Whether to enable sliding the slidebox. - */ - enableSlide(shouldEnable?: boolean): boolean; - - /** - * Go to the previous slide. Wraps around if at the beginning. - */ - previous(): void; - - /** - * Go to the next slide. Wraps around if at the end. - */ - next(): void; - - /** - * Stop sliding. The slideBox will not move again until explicitly told to do so. - */ - stop(): void; - - /** - * Start sliding again if the slideBox was stopped. - */ - start(): void; - - /** - * Returns the index of the current slide. - */ - currentIndex(): number; - - /** - * Returns the number of slides there are currently. - */ - slidesCount(): number; - - /** - * Returns a delegate instance that controls only the ionSlideBox directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ISlideBoxDelegate; - } - - //#endregion - - //#region Tabs - interface ITabsDelegate - { - - /** - * Select the tab matching the given index. - * - * @param index Index of the tab to select. - */ - select(index: number): void; - - /** - * Returns the index of the selected tab, or -1. - */ - selectedIndex(): number; - - /** - * Return delegate instance that controls only the ionTabs directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ITabsDelegate; - } - //#endregion -} \ No newline at end of file diff --git a/package.json b/package.json index 576d237..da88ad4 100644 --- a/package.json +++ b/package.json @@ -2,54 +2,12 @@ "name": "typescript-ionic-seed", "version": "1.0.0", "license": "MIT", - "description": "Get started on TypeScript + Angular + Ionic + TDD", - "devDependencies": { - "bower": "^1.3.3", - "chai": "^1.10.0", - "chai-as-promised": "^4.1.1", - "gulp": "^3.8.10", - "gulp-angular-templatecache": "^1.5.0", - "gulp-clean": "^0.3.1", - "gulp-concat": "^2.2.0", - "gulp-concat-sourcemap": "^1.3.1", - "gulp-htmlmin": "^0.2.0", - "gulp-jasmine": "^1.0.1", - "gulp-karma": "0.0.4", - "gulp-minify-css": "^0.3.0", - "gulp-ng-annotate": "^0.4.4", - "gulp-notify": "^2.1.0", - "gulp-plumber": "^0.6.6", - "gulp-rename": "^1.2.0", - "gulp-sass": "^0.7.1", - "gulp-sourcemaps": "^1.3.0", - "gulp-ts": "0.0.15", - "gulp-tslint": "^1.4.1", - "gulp-typescript": "^2.3.0", - "gulp-typescript-compiler": "^1.0.1", - "gulp-uglify": "^1.0.2", - "gulp-util": "^2.2.14", - "http-server": "^0.7.4", - "jasmine-core": "^2.1.3", - "karma": "^0.12.30", - "karma-chrome-launcher": "^0.1.7", - "karma-firefox-launcher": "^0.1.4", - "karma-jasmine": "^0.3.3", - "karma-junit-reporter": "^0.2.2", - "karma-notify-reporter": "^0.1.1", - "karma-phantomjs-launcher": "^0.1.4", - "karma-sourcemap-loader": "^0.3.2", - "karma-spec-reporter": "0.0.16", - "main-bower-files": "^2.5.0", - "ng-annotate": "^0.14.1", - "protractor-cucumber": "^0.1.2", - "shelljs": "^0.3.0", - "yargs": "^1.3.3" - }, + "description": "Hands-on-metal Ionic App", "scripts": { "postinstall": "bower install", - "pretsd": "npm install", - "tsd": "tsd reinstall --overwrite", - "presetup": "npm run tsd", + "pretypings": "npm install", + "typings": "typings install", + "presetup": "npm run typings", "setup": "gulp", "preserver": "npm run setup", "server": "ionic serve --port 8000", @@ -75,5 +33,53 @@ "presuite": "npm run tests", "suite": "npm run cucumber" }, - "private": true + "private": true, + "dependencies": { + "bower": "^1.7.9", + "chai": "^3.5.0", + "chai-as-promised": "^5.3.0", + "cucumber": "0.9.5", + "glob": "7.0.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^1.8.0", + "gulp-clean": "^0.3.2", + "gulp-concat": "^2.6.0", + "gulp-concat-sourcemap": "^1.3.1", + "gulp-htmlmin": "^2.0.0", + "gulp-jasmine": "^2.3.0", + "gulp-karma": "^0.0.5", + "gulp-minify-css": "^1.2.4", + "gulp-ng-annotate": "^2.0.0", + "gulp-notify": "^2.2.0", + "gulp-plumber": "^1.1.0", + "gulp-rename": "^1.2.2", + "gulp-sass": "^2.3.1", + "gulp-sourcemaps": "^1.6.0", + "gulp-ts": "0.3.0", + "gulp-tslint": "^5.0.0", + "gulp-typescript": "^2.13.6", + "gulp-uglify": "^1.5.3", + "gulp-util": "^3.0.7", + "http-server": "^0.9.0", + "jasmine-core": "^2.4.1", + "karma": "^0.13.22", + "karma-chrome-launcher": "^1.0.1", + "karma-firefox-launcher": "^1.0.0", + "karma-jasmine": "^1.0.2", + "karma-junit-reporter": "^2.0.0", + "karma-notify-reporter": "^1.0.0", + "karma-phantomjs-launcher": "^1.0.0", + "karma-spec-reporter": "0.0.26", + "lodash": "4.5.1", + "main-bower-files": "^2.13.1", + "ng-annotate": "^1.2.1", + "phantomjs-prebuilt": "^2.1.7", + "protractor": "3.1.1", + "protractor-cucumber-framework": "github:flynetworks/protractor-cucumber-framework#master", + "shelljs": "^0.7.0", + "tslint": "^3.11.0", + "typescript": "^1.8.10", + "typings": "^1.0.4", + "yargs": "^4.7.1" + } } diff --git a/src/common/directives/example_tag/ExampleTag.ts b/src/common/directives/example_tag/ExampleTag.ts index d123745..3470b93 100644 --- a/src/common/directives/example_tag/ExampleTag.ts +++ b/src/common/directives/example_tag/ExampleTag.ts @@ -17,13 +17,13 @@ module typeScriptIonicApp.common.directives { } export class ExampleTagDirectiveController { - constructor(public $scope:IExampleTagDirectiveScope) { + constructor(public $scope: IExampleTagDirectiveScope) { $scope.vm = this; } } // this module is re-declared per directive - export var app:ng.IModule = app || angular.module('typeScriptIonicApp.common.directives', ['templates', 'ionic']); + export var app: ng.IModule = app || angular.module('typeScriptIonicApp.common.directives', ['templates', 'ionic']); app.directive('exampleTag', () => new ExampleTagDirective()); app.controller('ExampleTagDirectiveController', ExampleTagDirectiveController); diff --git a/src/common/services/SampleData.spec.ts b/src/common/services/SampleData.spec.ts index 359bc1e..91d67b6 100644 --- a/src/common/services/SampleData.spec.ts +++ b/src/common/services/SampleData.spec.ts @@ -2,13 +2,13 @@ module typeScriptIonicApp.common.services { describe('SampleDataService', function () { - var $log:ng.ILogService, SampleDataService:ISampleData; + var $log: ng.ILogService, SampleDataService: ISampleData; beforeEach(function () { angular.mock.module('typeScriptIonicApp.common.services'); }); - beforeEach(inject(function (_SampleDataService_:ISampleData, _$log_:ng.ILogService) { + beforeEach(inject(function (_SampleDataService_: ISampleData, _$log_: ng.ILogService) { $log = _$log_; SampleDataService = _SampleDataService_; })); diff --git a/src/common/services/SampleData.ts b/src/common/services/SampleData.ts index 10f2100..89ae9c3 100644 --- a/src/common/services/SampleData.ts +++ b/src/common/services/SampleData.ts @@ -7,9 +7,9 @@ module typeScriptIonicApp.common.services { } export class SampleData implements ISampleData { - static $inject = ['$log']; - - constructor(private $log:ng.ILogService) { + + /** @ngInject */ + constructor(private $log: ng.ILogService) { } getData():string { @@ -18,6 +18,6 @@ module typeScriptIonicApp.common.services { } } - export var app:ng.IModule = app || angular.module('typeScriptIonicApp.common.services', ['ionic']); + export var app: ng.IModule = app || angular.module('typeScriptIonicApp.common.services', ['ionic']); app.service('SampleDataService', SampleData); } diff --git a/src/components/home/HomeController.ts b/src/components/home/HomeController.ts index 9246a26..4d58842 100644 --- a/src/components/home/HomeController.ts +++ b/src/components/home/HomeController.ts @@ -11,8 +11,11 @@ module typeScriptIonicApp.components.home { // this export lets us directly initialize this during tests export class HomeController { public data:string; - - constructor(public $scope:IHomeScope, private $state:ng.ui.IStateService, private $ionicHistory, private SampleDataService) { + + constructor(public $scope: IHomeScope, + private $state: ng.ui.IStateService, + private $ionicHistory: ionic.navigation.IonicHistoryService, + private SampleDataService: typeScriptIonicApp.common.services.SampleData) { console.log('home loaded!'); // 'vm' stands for 'view model'. An additional benefit to this is to prevent primatives getting // assigned to the scope directly @@ -29,8 +32,8 @@ module typeScriptIonicApp.components.home { } } - function setRouteState($stateProvider:ng.ui.IStateProvider) { - var state:ng.ui.IState = { + function setRouteState($stateProvider: ng.ui.IStateProvider) { + var state: ng.ui.IState = { url: '/home', views: { menuContent: { @@ -43,7 +46,7 @@ module typeScriptIonicApp.components.home { $stateProvider.state('app.home', state); } - export var app:ng.IModule = app || angular.module('typeScriptIonicApp.components.home', ['ionic']); + export var app: ng.IModule = app || angular.module('typeScriptIonicApp.components.home', ['ionic']); app.controller('HomeController', HomeController); app.config(setRouteState); } diff --git a/src/components/login/LoginController.ts b/src/components/login/LoginController.ts index 5c0a29d..1d0dc85 100644 --- a/src/components/login/LoginController.ts +++ b/src/components/login/LoginController.ts @@ -10,10 +10,12 @@ module typeScriptIonicApp.components.login { } export class LoginController { - public username:string; - public password:string; + public username: string; + public password: string; - constructor(public $scope:ILoginScope, private $state:ng.ui.IStateService, private $ionicHistory) { + constructor(public $scope: ILoginScope, + private $state: ng.ui.IStateService, + private $ionicHistory: ionic.navigation.IonicHistoryService) { this.username = 'default'; console.log('Login loaded'); // 'vm' stands for 'view model'. An additional benefit to this is to prevent primatives getting diff --git a/src/definitions.d.ts b/src/definitions.d.ts index f906a72..e75a718 100644 --- a/src/definitions.d.ts +++ b/src/definitions.d.ts @@ -1,7 +1,4 @@ -// https://github.com/danibo86/ionic-typescript-definitions -/// - -/// +/// /******* * INCLUDE ALL YOUR CUSTOM SOURCE FILES HERE diff --git a/src/layout/AppController.ts b/src/layout/AppController.ts index 8aec8c8..1901a48 100644 --- a/src/layout/AppController.ts +++ b/src/layout/AppController.ts @@ -1,7 +1,7 @@ /// module typeScriptIonicApp { class AppController { - constructor(private $scope:IAppScope) { + constructor(private $scope: IAppScope) { console.log('app loaded'); // 'vm' stands for 'view model'. An additional benefit to this is to prevent primatives getting // assigned to the scope directly @@ -9,6 +9,6 @@ module typeScriptIonicApp { } } - export var app:ng.IModule = app || angular.module('typeScriptIonicApp'); + export var app: ng.IModule = app || angular.module('typeScriptIonicApp'); app.controller('AppController', AppController); } diff --git a/src/main.ts b/src/main.ts index 7f5defb..c5d36fc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,4 @@ /// - // this hide message errors from compiler interface Window { cordova: any; @@ -7,7 +6,7 @@ interface Window { } module typeScriptIonicApp { - export var app:ng.IModule = angular.module('typeScriptIonicApp', [ + export var app: ng.IModule = angular.module('typeScriptIonicApp', [ 'ionic', 'templates', 'typeScriptIonicApp.common.services', @@ -16,8 +15,8 @@ module typeScriptIonicApp { 'typeScriptIonicApp.components.login' ]); - app.run(function ($ionicPlatform) { - $ionicPlatform.ready(function () { + app.run(($ionicPlatform: ionic.platform.IonicPlatformService) => { + $ionicPlatform.ready(() => { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if (window.cordova && window.cordova.plugins.Keyboard) { @@ -31,7 +30,7 @@ module typeScriptIonicApp { }); }); - app.config(function ($stateProvider, $urlRouterProvider) { + app.config(($stateProvider: ng.ui.IStateProvider, $urlRouterProvider: ng.ui.IUrlRouterProvider) => { $stateProvider.state('app', { url: '/app', abstract: true, diff --git a/tsd.json b/tsd.json deleted file mode 100644 index 1df745e..0000000 --- a/tsd.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "tsd", - "bundle": "tsd/tsd.d.ts", - "installed": { - "angularjs/angular.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/cordova.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/BatteryStatus.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Device.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/DeviceMotion.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/DeviceOrientation.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Contacts.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Dialogs.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Camera.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/FileTransfer.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Globalization.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/FileSystem.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/InAppBrowser.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Media.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/MediaCapture.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/NetworkInformation.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Push.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Splashscreen.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/Vibration.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "cordova/plugins/WebSQL.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "jquery/jquery.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "angularjs/angular-mocks.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "jasmine/jasmine.d.ts": { - "commit": "ca32947b75a2b1203779dac7154ffbc232746e4d" - }, - "chai-as-promised/chai-as-promised.d.ts": { - "commit": "494b30d2327ab489fa5b5f082a3c9a299e4c5644" - }, - "chai/chai.d.ts": { - "commit": "494b30d2327ab489fa5b5f082a3c9a299e4c5644" - }, - "angular-ui-router/angular-ui-router.d.ts": { - "commit": "f7d47e35f7f29c151889286e8b8bf2bd31317490" - } - } -} diff --git a/tsd/tsd.d.ts b/tsd/tsd.d.ts deleted file mode 100644 index ecf5b74..0000000 --- a/tsd/tsd.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..3bcb108 --- /dev/null +++ b/typings.json @@ -0,0 +1,34 @@ +{ + "name": "typescript-ionic-seed", + "globalDependencies": { + "BatteryStatus": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/BatteryStatus.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Camera": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Camera.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Contacts": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Contacts.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Device": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Device.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "DeviceMotion": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/DeviceMotion.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "DeviceOrientation": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/DeviceOrientation.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Dialogs": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Dialogs.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "FileSystem": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/FileSystem.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "FileTransfer": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/FileTransfer.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Globalization": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Globalization.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "InAppBrowser": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/InAppBrowser.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Media": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Media.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "MediaCapture": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/MediaCapture.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "NetworkInformation": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/NetworkInformation.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Push": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Push.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Splashscreen": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Splashscreen.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "Vibration": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/Vibration.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "WebSQL": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/WebSQL.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "angular-mocks": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-mocks.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "angular-ui-router": "github:onderceylan/angular-ui-router-ng-typing/angular-ui-router.d.ts#5f8e271450ae65fc194f5a58c681282f3f314fbf", + "chai": "github:DefinitelyTyped/DefinitelyTyped/chai/chai.d.ts#494b30d2327ab489fa5b5f082a3c9a299e4c5644", + "chai-as-promised": "github:DefinitelyTyped/DefinitelyTyped/chai-as-promised/chai-as-promised.d.ts#494b30d2327ab489fa5b5f082a3c9a299e4c5644", + "cordova": "github:DefinitelyTyped/DefinitelyTyped/cordova/cordova.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "cordova-ionic": "github:DefinitelyTyped/DefinitelyTyped/cordova-ionic/cordova-ionic.d.ts#62eedc3121a5e28c50473d2e4a9cefbcb9c3957f", + "ionic": "github:DefinitelyTyped/DefinitelyTyped/ionic/ionic.d.ts#14ab703f435375194360cdba3abab61afc879c18", + "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "keyboard": "github:DefinitelyTyped/DefinitelyTyped/cordova-ionic/plugins/keyboard.d.ts#62eedc3121a5e28c50473d2e4a9cefbcb9c3957f" + } +} diff --git a/typings/globals/angular-mocks/index.d.ts b/typings/globals/angular-mocks/index.d.ts new file mode 100644 index 0000000..4e407bd --- /dev/null +++ b/typings/globals/angular-mocks/index.d.ts @@ -0,0 +1,218 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/ca32947b75a2b1203779dac7154ffbc232746e4d/angularjs/angular-mocks.d.ts +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see http://docs.angularjs.org/api/angular.mock.dump + dump(obj: any): string; + + // see http://docs.angularjs.org/api/angular.mock.inject + inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works + + // see http://docs.angularjs.org/api/angular.mock.module + module(...modules: any[]): any; + + // see http://docs.angularjs.org/api/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ngMock.$exceptionHandler + // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ngMock.$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ngMock.$interval + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + flush(millis?: number): number; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ngMock.$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface ILogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ngMock.$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} \ No newline at end of file diff --git a/typings/globals/angular-mocks/typings.json b/typings/globals/angular-mocks/typings.json new file mode 100644 index 0000000..5548c31 --- /dev/null +++ b/typings/globals/angular-mocks/typings.json @@ -0,0 +1,8 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/ca32947b75a2b1203779dac7154ffbc232746e4d/angularjs/angular-mocks.d.ts", + "raw": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-mocks.d.ts#ca32947b75a2b1203779dac7154ffbc232746e4d", + "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/ca32947b75a2b1203779dac7154ffbc232746e4d/angularjs/angular-mocks.d.ts" + } +}