diff --git a/.travis.yml b/.travis.yml index 765ef3e..681dfce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ branches: before_install: - nvm use 4.1.2 - npm install -g cordova ionic + - ionic state clear install: npm install @@ -58,6 +59,8 @@ before_deploy: - echo "y" | ./android-sdk-linux/tools/android update sdk --no-ui --filter android-23,build-tools-23.0.1 - export ANDROID_HOME=${PWD}/android-sdk-linux # end install android + - ionic state restore + - ionic platform add android - ionic build android # `ionic build android` wraps `cordova build android`, which gives a legit exit code if it fails. Ionic does not; test apk exists. - ls ./platforms/android/build/outputs/apk/android*.apk diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b3bac..6bf3f4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + +# 1.3.0 (2016-05-22) + +### Features + +* **Update**: Update to Ionic 2.0.0.beta.7 and Angular 2.0.0.rc.1 PR[#93](https://github.com/lathonez/clicker/pull/93) big update due to Angular RC1 ([f3b6641](https://github.com/lathonez/clicker/commit/f3b6641)) + +### Browserify in Karma + # 1.2.0 (2016-04-28) diff --git a/README.md b/README.md index cdc9528..defd017 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,12 @@ See the changelog [here](https://github.com/lathonez/clicker/blob/master/CHANGEL ## Dependencies -* **Angular:** 2.0.0-beta.15 -* **Ionic:** 2.0.0-beta.6 +* **@Angular:** 2.0.0-rc.1 +* **Ionic:** 2.0.0-beta.7 External dependencies are listed here to justify their inclusion and to allow for their removal if your project isn't using the related functionality. +* browserify: peer dependency of karma-browserify * browserify-istanbul: coverage transformer for karma-browserify * codecov.io: sending unit test coverage reports to codecov.io * gulp-tslint: access tslint from gulp @@ -76,7 +77,6 @@ External dependencies are listed here to justify their inclusion and to allow fo * karma-phantomjs-launcher: allows using phantom with Karma * phantomjs-prebuilt: phantom headless browser * protractor: e2e test runner -* traceur: needed to prevent errors in Phantom * tsify: typescript plugin for karma-browserify * ts-node: transpile gulpfile * tslint: static code analysis for typescript diff --git a/app/app.html b/app/app.html index 761a41e..77613ff 100644 --- a/app/app.html +++ b/app/app.html @@ -6,7 +6,7 @@ - diff --git a/app/app.spec.ts b/app/app.spec.ts index 0ac4137..2a4165a 100644 --- a/app/app.spec.ts +++ b/app/app.spec.ts @@ -1,22 +1,20 @@ -import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser'; -import { setBaseTestProviders } from 'angular2/testing'; -import { ClickerApp } from './app'; - -// this needs doing _once_ for the entire test suite, hence it's here -setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); +import { ADDITIONAL_TEST_BROWSER_PROVIDERS, TEST_BROWSER_STATIC_PLATFORM_PROVIDERS } from '@angular/platform-browser/testing/browser_static'; +import { BROWSER_APP_DYNAMIC_PROVIDERS } from '@angular/platform-browser-dynamic'; +import { resetBaseTestProviders, setBaseTestProviders } from '@angular/core/testing'; +import { ClickerApp } from './app'; +import { Page2 } from './pages/page2/page2'; + +resetBaseTestProviders(); +setBaseTestProviders( + TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, + [ + BROWSER_APP_DYNAMIC_PROVIDERS, + ADDITIONAL_TEST_BROWSER_PROVIDERS, + ] +); let clickerApp: ClickerApp = null; -function getComponentStub(name: string): any { - 'use strict'; - - let component: Object = { - setRoot: function(): boolean { return true; }, - close: function(root: any): boolean { return true; }, - }; - return component; -} - class MockClass { public ready(): any { return new Promise((resolve: Function) => { @@ -24,7 +22,11 @@ class MockClass { }); } - public getComponent(): any { + public close(): any { + return true; + } + + public setRoot(): any { return true; } } @@ -49,9 +51,12 @@ describe('ClickerApp', () => { }); it('opens a page', () => { - spyOn(clickerApp['app'], 'getComponent').and.callFake(getComponentStub); + spyOn(clickerApp['menu'], 'close'); + // cant be bothered to set up DOM testing for app.ts to get access to @ViewChild (Nav) + clickerApp['nav'] = (clickerApp['menu']); + spyOn(clickerApp['nav'], 'setRoot'); clickerApp.openPage(clickerApp['pages'][1]); - expect(clickerApp['app'].getComponent).toHaveBeenCalledWith('leftMenu'); - expect(clickerApp['app'].getComponent).toHaveBeenCalledWith('nav'); + expect(clickerApp['menu']['close']).toHaveBeenCalled(); + expect(clickerApp['nav'].setRoot).toHaveBeenCalledWith(Page2); }); }); diff --git a/app/app.ts b/app/app.ts index e970915..4f93d91 100644 --- a/app/app.ts +++ b/app/app.ts @@ -1,9 +1,10 @@ 'use strict'; -import { Type } from 'angular2/core'; -import { App, IonicApp, Platform } from 'ionic-angular'; -import { ClickerList } from './pages/clickerList/clickerList'; -import { Page2 } from './pages/page2/page2'; +import { Type, ViewChild } from '@angular/core'; +import { App, Platform, MenuController, Nav } from 'ionic-angular'; +import { StatusBar } from 'ionic-native'; +import { ClickerList } from './pages/clickerList/clickerList'; +import { Page2 } from './pages/page2/page2'; @App({ templateUrl: 'build/app.html', @@ -11,15 +12,17 @@ import { Page2 } from './pages/page2/page2'; }) export class ClickerApp { + @ViewChild(Nav) private nav: Nav; + private rootPage: Type; private pages: Array<{title: string, component: Type}>; - private app: IonicApp; + private menu: MenuController; private platform: Platform; - constructor(app: IonicApp, platform: Platform) { + constructor(platform: Platform, menu: MenuController) { - this.app = app; this.platform = platform; + this.menu = menu; this.rootPage = ClickerList; this.initializeApp(); @@ -33,27 +36,16 @@ export class ClickerApp { private initializeApp(): void { this.platform.ready().then(() => { - // The platform is now ready. Note: if this callback fails to fire, follow - // the Troubleshooting guide for a number of possible solutions: - // // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. - // - // First, let's hide the keyboard accessory bar (only works natively) since - // that's a better default: - // - // Keyboard.setAccessoryBarVisible(false); - // - // For example, we might change the StatusBar color. This one below is - // good for dark backgrounds and light text: - // StatusBar.setStyle(StatusBar.LIGHT_CONTENT) + StatusBar.styleDefault(); }); } public openPage(page: any): void { // close the menu when clicking a link from the menu - this.app.getComponent('leftMenu').close(); + this.menu.close(); // navigate to the new page if it is not the current page - this.app.getComponent('nav').setRoot(page.component); + this.nav.setRoot(page.component); }; } diff --git a/app/components/clickerButton/clickerButton.spec.ts b/app/components/clickerButton/clickerButton.spec.ts index 634dd6c..74f1067 100644 --- a/app/components/clickerButton/clickerButton.spec.ts +++ b/app/components/clickerButton/clickerButton.spec.ts @@ -1,14 +1,16 @@ import { beforeEach, beforeEachProviders, - ComponentFixture, describe, expect, injectAsync, it, +} from '@angular/core/testing'; +import { + ComponentFixture, TestComponentBuilder, -} from 'angular2/testing'; -import { provide } from 'angular2/core'; +} from '@angular/compiler/testing'; +import { provide } from '@angular/core'; import { Config } from 'ionic-angular'; import { ClickerButton } from './clickerButton'; import { Clickers } from '../../services/clickers'; @@ -16,7 +18,7 @@ import { TestUtils } from '../../../test/testUtils'; import { Utils } from '../../services/utils'; let clickerButton: ClickerButton = null; -let clickerButtonFixture: ComponentFixture = null; +let clickerButtonFixture: ComponentFixture = null; class MockClickers { public doClick(): boolean { @@ -45,7 +47,7 @@ describe('ClickerButton', () => { beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(ClickerButton) - .then((componentFixture: ComponentFixture) => { + .then((componentFixture: ComponentFixture) => { clickerButtonFixture = componentFixture; clickerButton = componentFixture.componentInstance; clickerButton['clicker'] = { name: 'TEST CLICKER' }; diff --git a/app/components/clickerButton/clickerButton.ts b/app/components/clickerButton/clickerButton.ts index 5363175..a3bd5dc 100644 --- a/app/components/clickerButton/clickerButton.ts +++ b/app/components/clickerButton/clickerButton.ts @@ -1,6 +1,6 @@ 'use strict'; -import { Component } from 'angular2/core'; +import { Component } from '@angular/core'; import { Button } from 'ionic-angular'; import { Clickers } from '../../services/clickers'; diff --git a/app/components/clickerForm/clickerForm.spec.ts b/app/components/clickerForm/clickerForm.spec.ts index 0460420..79ebe67 100644 --- a/app/components/clickerForm/clickerForm.spec.ts +++ b/app/components/clickerForm/clickerForm.spec.ts @@ -1,14 +1,16 @@ import { beforeEach, beforeEachProviders, - ComponentFixture, describe, expect, injectAsync, it, +} from '@angular/core/testing'; +import { + ComponentFixture, TestComponentBuilder, -} from 'angular2/testing'; -import { provide } from 'angular2/core'; +} from '@angular/compiler/testing'; +import { provide } from '@angular/core'; import { Config, Form, @@ -21,7 +23,7 @@ import { TestUtils } from '../../../test/testUtils'; import { Utils } from '../../services/utils'; let clickerForm: ClickerForm = null; -let clickerFormFixture: ComponentFixture = null; +let clickerFormFixture: ComponentFixture = null; class MockClickers { public newClicker(): boolean { @@ -56,7 +58,7 @@ describe('ClickerForm', () => { beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(ClickerForm) - .then((componentFixture: ComponentFixture) => { + .then((componentFixture: ComponentFixture) => { clickerFormFixture = componentFixture; clickerForm = componentFixture.componentInstance; spyOn(clickerForm, 'newClicker').and.callThrough(); @@ -72,7 +74,7 @@ describe('ClickerForm', () => { it('passes new clicker through to service', () => { let clickerName: string = 'dave'; let input: any = clickerFormFixture.nativeElement.querySelectorAll('.text-input')[0]; - let button: any = clickerFormFixture.nativeElement.querySelectorAll('button')[0]; + let button: any = clickerFormFixture.nativeElement.querySelectorAll('button')[1]; spyOn(Utils, 'resetControl').and.callThrough(); input.value = clickerName; clickerFormFixture.detectChanges(); @@ -85,7 +87,7 @@ describe('ClickerForm', () => { }); it('doesn\'t try to add a clicker with no name', () => { - let button: any = clickerFormFixture.nativeElement.querySelectorAll('button')[0]; + let button: any = clickerFormFixture.nativeElement.querySelectorAll('button')[1]; TestUtils.eventFire(button, 'click'); expect(clickerForm.newClicker).toHaveBeenCalled(); expect(clickerForm['clickerService'].newClicker).not.toHaveBeenCalled(); diff --git a/app/components/clickerForm/clickerForm.ts b/app/components/clickerForm/clickerForm.ts index 99c755e..f4cc7ed 100644 --- a/app/components/clickerForm/clickerForm.ts +++ b/app/components/clickerForm/clickerForm.ts @@ -1,7 +1,7 @@ 'use strict'; -import { AbstractControl, ControlGroup, FormBuilder, Validators } from 'angular2/common'; -import { Component } from 'angular2/core'; +import { AbstractControl, ControlGroup, FormBuilder, Validators } from '@angular/common'; +import { Component } from '@angular/core'; import { Button, Icon, Item, Label, TextInput } from 'ionic-angular'; import { Clickers } from '../../services/clickers'; import { Utils } from '../../services/utils'; diff --git a/app/pages/clickerList/clickerList.e2e.ts b/app/pages/clickerList/clickerList.e2e.ts index fc28a57..607418e 100644 --- a/app/pages/clickerList/clickerList.e2e.ts +++ b/app/pages/clickerList/clickerList.e2e.ts @@ -1,7 +1,7 @@ import { ElementFinder } from 'protractor'; let clickerField: ElementFinder = element(by.css('.text-input')); -let clickerButton: ElementFinder = element.all(by.className('button')).first(); +let clickerButton: ElementFinder = element.all(by.className('button-outline')).first(); let removeButton: ElementFinder = element.all(by.css('.button-outline-danger')).first(); let firstClicker: ElementFinder = element.all(by.className('clickerList')).first(); diff --git a/app/pages/clickerList/clickerList.html b/app/pages/clickerList/clickerList.html index edbbfe1..0a4277e 100644 --- a/app/pages/clickerList/clickerList.html +++ b/app/pages/clickerList/clickerList.html @@ -7,7 +7,7 @@ - + diff --git a/app/pages/clickerList/clickerList.spec.ts b/app/pages/clickerList/clickerList.spec.ts index 2ef6dc0..1358920 100644 --- a/app/pages/clickerList/clickerList.spec.ts +++ b/app/pages/clickerList/clickerList.spec.ts @@ -1,14 +1,16 @@ import { beforeEach, beforeEachProviders, - ComponentFixture, describe, expect, injectAsync, it, +} from '@angular/core/testing'; +import { + ComponentFixture, TestComponentBuilder, -} from 'angular2/testing'; -import { provide } from 'angular2/core'; +} from '@angular/compiler/testing'; +import { provide } from '@angular/core'; import { ClickerList } from './clickerList'; import { Utils } from '../../services/utils'; import { @@ -35,7 +37,7 @@ class MockClass { } let clickerList: ClickerList = null; -let clickerListFixture: ComponentFixture = null; +let clickerListFixture: ComponentFixture = null; describe('ClickerList', () => { @@ -51,7 +53,7 @@ describe('ClickerList', () => { beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(ClickerList) - .then((componentFixture: ComponentFixture) => { + .then((componentFixture: ComponentFixture) => { clickerListFixture = componentFixture; clickerList = componentFixture.componentInstance; clickerListFixture.detectChanges(); diff --git a/app/pages/page2/page2.spec.ts b/app/pages/page2/page2.spec.ts index 80c941b..52ec4d3 100644 --- a/app/pages/page2/page2.spec.ts +++ b/app/pages/page2/page2.spec.ts @@ -1,14 +1,16 @@ import { beforeEach, beforeEachProviders, - ComponentFixture, describe, expect, injectAsync, it, +} from '@angular/core/testing'; +import { + ComponentFixture, TestComponentBuilder, -} from 'angular2/testing'; -import { provide } from 'angular2/core'; +} from '@angular/compiler/testing'; +import { provide } from '@angular/core'; import { Page2 } from './page2'; import { Utils } from '../../services/utils'; import { @@ -35,7 +37,7 @@ class MockClass { } let page2: Page2 = null; -let page2Fixture: ComponentFixture = null; +let page2Fixture: ComponentFixture = null; describe('Page2', () => { @@ -51,7 +53,7 @@ describe('Page2', () => { beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(Page2) - .then((componentFixture: ComponentFixture) => { + .then((componentFixture: ComponentFixture) => { page2Fixture = componentFixture; page2 = componentFixture.componentInstance; page2Fixture.detectChanges(); diff --git a/app/services/clickers.ts b/app/services/clickers.ts index 7fadb9e..b887c8b 100644 --- a/app/services/clickers.ts +++ b/app/services/clickers.ts @@ -1,6 +1,6 @@ 'use strict'; -import { Injectable } from 'angular2/core'; +import { Injectable } from '@angular/core'; import { SqlStorage } from 'ionic-angular'; import { Clicker } from '../models/clicker'; import { Click } from '../models/click'; diff --git a/app/services/utils.spec.ts b/app/services/utils.spec.ts index 092a399..7667a7b 100644 --- a/app/services/utils.spec.ts +++ b/app/services/utils.spec.ts @@ -1,6 +1,10 @@ import { Utils } from './utils'; -import { AbstractControl, Control } from 'angular2/common'; - +import { AbstractControl, Control } from '@angular/common'; +import { + describe, + expect, + it, +} from '@angular/core/testing'; describe('Utils', () => { it('resets a control', () => { diff --git a/app/services/utils.ts b/app/services/utils.ts index a9e6c06..84d80ec 100644 --- a/app/services/utils.ts +++ b/app/services/utils.ts @@ -1,6 +1,6 @@ 'use strict'; -import { AbstractControl } from 'angular2/common'; +import { AbstractControl } from '@angular/common'; export class Utils { diff --git a/config.xml b/config.xml index dfe4465..ca6bbdb 100644 --- a/config.xml +++ b/config.xml @@ -31,5 +31,5 @@ - + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 6836586..0f2edd0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -51,8 +51,12 @@ gulp.task('build', ['clean'], function(done){ ['sass', 'html', 'fonts', 'scripts'], function(){ buildBrowserify({ + minify: isRelease, browserifyOptions: { debug: !isRelease + }, + uglifyOptions: { + mangle: false } }).on('end', done); } diff --git a/package.json b/package.json index 1ea3d83..aa1668e 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,57 @@ { "dependencies": { - "angular2": "2.0.0-beta.15", - "es6-shim": "^0.35.0", - "ionic-angular": "2.0.0-beta.6", - "ionic-native": "^1.1.0", - "ionicons": "3.0.0-alpha.3", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", - "zone.js": "0.6.10" + "@angular/common": "^2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "es6-shim": "0.35.1", + "ionic-angular": "2.0.0-beta.7", + "ionic-native": "1.2.2", + "ionicons": "3.0.0", + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "0.6.12" }, "devDependencies": { - "browserify-istanbul": "^2.0.0", + "browserify": "13.0.0", + "browserify-istanbul": "2.0.0", "codecov.io": "0.1.6", "del": "2.2.0", "gulp": "3.9.1", - "gulp-tslint": "4.3.5", - "gulp-typescript": "^2.12.1", + "gulp-tslint": "5.0.0", + "gulp-typescript": "2.12.1", "gulp-watch": "4.3.5", - "ionic-gulp-browserify-typescript": "^1.0.1", - "ionic-gulp-fonts-copy": "^1.0.0", - "ionic-gulp-html-copy": "^1.0.0", - "ionic-gulp-sass-build": "^1.0.0", - "ionic-gulp-scripts-copy": "^1.0.0", - "isparta": "^4.0.0", - "jasmine-core": "^2.4.1", - "jasmine-spec-reporter": "^2.4.0", - "karma": "0.13.9", - "karma-browserify": "^5.0.4", - "karma-chrome-launcher": "0.2.3", - "karma-coverage": "0.5.5", - "karma-jasmine": "0.3.8", - "karma-mocha-reporter": "^2.0.1", + "ionic-gulp-browserify-typescript": "1.1.0", + "ionic-gulp-fonts-copy": "1.0.0", + "ionic-gulp-html-copy": "1.0.0", + "ionic-gulp-sass-build": "1.0.0", + "ionic-gulp-scripts-copy": "2.0.0", + "isparta": "4.0.0", + "jasmine-core": "2.4.1", + "jasmine-spec-reporter": "2.4.0", + "karma": "0.13.22", + "karma-browserify": "5.0.4", + "karma-chrome-launcher": "1.0.1", + "karma-coverage": "1.0.0", + "karma-jasmine": "1.0.2", + "karma-mocha-reporter": "2.0.1", "karma-phantomjs-launcher": "1.0.0", "phantomjs-prebuilt": "2.1.7", - "protractor": "^3.1.1", - "run-sequence": "1.1.5", - "traceur": "0.0.107", - "ts-node": "0.7.1", - "tsify": "^0.15.2", - "tslint": "3.7.4", - "tslint-eslint-rules": "1.2.0", - "typings": "0.7.12" + "protractor": "3.1.1", + "run-sequence": "1.2.0", + "ts-node": "0.7.3", + "tsify": "0.16.0", + "tslint": "3.10.2", + "tslint-eslint-rules": "1.3.0", + "typings": "1.0.4" }, "name": "clicker", - "version": "1.2.0", + "version": "1.3.0", "description": "clicker: An Ionic project", "cordovaPlugins": [ - "cordova-sqlite-storage", "cordova-plugin-device", "cordova-plugin-console", "cordova-plugin-whitelist", @@ -54,9 +59,7 @@ "cordova-plugin-statusbar", "ionic-plugin-keyboard" ], - "cordovaPlatforms": [ - "android" - ], + "cordovaPlatforms": [], "scripts": { "build": "gulp --gulpfile test/gulpfile.ts --cwd ./ build-app", "e2e": "gulp --gulpfile test/gulpfile.ts --cwd ./ build-e2e && protractor test/protractor.conf.js", diff --git a/test/gulpfile.ts b/test/gulpfile.ts index 0af459b..e2f0265 100644 --- a/test/gulpfile.ts +++ b/test/gulpfile.ts @@ -55,29 +55,25 @@ gulp.task('clean-test', () => { gulp.task('karma', (done: Function) => { let karma: any = require('karma'); + let karmaOpts: {} = { + configFile: join(process.cwd(), config.testDir, 'karma.config.js'), + singleRun: true, + }; - new (karma).Server( - { - configFile: join(process.cwd(), config.testDir, 'karma.config.js'), - singleRun: true, - }, - (() => done()) - ).start(); + new karma.Server(karmaOpts, done).start(); }); // run jasmine unit tests using karma with Chrome, Karma will be left open in Chrome for debug gulp.task('karma-debug', (done: Function) => { let karma: any = require('karma'); + let karmaOpts: {} = { + configFile: join(process.cwd(), config.testDir, 'karma.config.js'), + singleRun: false, + browsers: ['Chrome'], + }; - new (karma).Server( - { - configFile: join(process.cwd(), config.testDir, 'karma.config.js'), - singleRun: false, - browsers: ['Chrome'], - }, - (() => done()) - ).start(); + new karma.Server(karmaOpts, done).start(); }); // run tslint against all typescript diff --git a/test/karma-static/context.html b/test/karma-static/context.html index 4d7fcbe..ffc78f7 100644 --- a/test/karma-static/context.html +++ b/test/karma-static/context.html @@ -11,6 +11,7 @@ + - + + +