Skip to content

Commit

Permalink
Merge branch 'kwv-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lathonez committed Jun 29, 2016
2 parents f702378 + 2b858ac commit 0734e45
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 40 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a name="1.3.5"></a>
# 1.3.5 (2016-06-29)

### Features

* **Unit Test**: Implement Barrels and move mocks to individual files PR [#109](https://github.com/lathonez/clicker/pull/109) ([TODO](https://github.com/lathonez/clicker/commit/TODO))
* **Update**: Update to Ionic 2.0.0.beta.10 ([TODO](https://github.com/lathonez/clicker/commit/))

<a name="1.3.4"></a>
# 1.3.4 (2016-06-19)

Expand Down
3 changes: 1 addition & 2 deletions app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import { Component, Type, ViewChild } from '@angular/core';
import { ionicBootstrap, MenuController, Nav, Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { ClickerList } from './pages/clickerList/clickerList';
import { Page2 } from './pages/page2/page2';
import { ClickerList, Page2 } from './pages';

@Component({
templateUrl: 'build/app.html',
Expand Down
9 changes: 8 additions & 1 deletion app/components/clickerButton/clickerButton.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { beforeEach, beforeEachProviders, describe, expect, it } from '@angular/core/testing';
import { provide } from '@angular/core';
import { asyncCallbackFactory, injectAsyncWrapper, providers, TestUtils } from '../../../test/diExports';
import { ClickersMock } from '../../services/mocks';
import { ClickerButton } from './clickerButton';
import { Clickers } from '../../services';

this.fixture = null;
this.instance = null;

let clickerButtonProviders: Array<any> = [
provide(Clickers, {useClass: ClickersMock}),
];

describe('ClickerButton', () => {

let beforeEachFn: Function = ((testSpec) => {
testSpec.instance['clicker'] = { name: 'TEST CLICKER' };
testSpec.instance['clicker'].getCount = function(): number { return 10; };
});

beforeEachProviders(() => providers);
beforeEachProviders(() => providers.concat(clickerButtonProviders));
beforeEach(injectAsyncWrapper(asyncCallbackFactory(ClickerButton, this, false, beforeEachFn)));

it('initialises', () => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/clickerButton/clickerButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Component } from '@angular/core';
import { Button } from 'ionic-angular';
import { Clickers } from '../../services/clickers';
import { Clickers } from '../../services';

@Component({
selector: 'clicker-button',
Expand Down
10 changes: 8 additions & 2 deletions app/components/clickerForm/clickerForm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { beforeEach, beforeEachProviders, describe, expect, it } from '@angular/core/testing';
import { provide } from '@angular/core';
import { asyncCallbackFactory, injectAsyncWrapper, providers, TestUtils } from '../../../test/diExports';
import { Utils } from '../../services/utils';
import { ClickersMock } from '../../services/mocks';
import { Clickers, Utils } from '../../services';
import { ClickerForm } from './clickerForm';

this.fixture = null;
this.instance = null;

let clickerFormProviders: Array<any> = [
provide(Clickers, {useClass: ClickersMock}),
];

describe('ClickerForm', () => {

let beforeEachFn: Function = ((testSpec) => {
spyOn(testSpec.instance, 'newClicker').and.callThrough();
spyOn(testSpec.instance['clickerService'], 'newClicker').and.callThrough();
});

beforeEachProviders(() => providers);
beforeEachProviders(() => providers.concat(clickerFormProviders));
beforeEach(injectAsyncWrapper(asyncCallbackFactory(ClickerForm, this, false, beforeEachFn)));

it('initialises', () => {
Expand Down
3 changes: 1 addition & 2 deletions app/components/clickerForm/clickerForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
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';
import { Clickers, Utils } from '../../services';

@Component({
selector: 'clicker-form',
Expand Down
2 changes: 2 additions & 0 deletions app/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './clickerButton/clickerButton';
export * from './clickerForm/clickerForm';
5 changes: 5 additions & 0 deletions app/models/clicker.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// CLICKERS:
export class ClickerMock {
public name: string = 'TEST CLICKER';
public getCount(): number { return 10; };
}
2 changes: 1 addition & 1 deletion app/models/clicker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { Click } from './click';
import { Click } from './';

// Represents a single Clicker
export class Clicker {
Expand Down
2 changes: 2 additions & 0 deletions app/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './click';
export * from './clicker';
1 change: 1 addition & 0 deletions app/models/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './clicker.mock';
9 changes: 8 additions & 1 deletion app/pages/clickerList/clickerList.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { beforeEach, beforeEachProviders, describe, expect, it } from '@angular/core/testing';
import { provide } from '@angular/core';
import { asyncCallbackFactory, injectAsyncWrapper, providers } from '../../../test/diExports';
import { ClickersMock } from '../../services/mocks';
import { ClickerList } from './clickerList';
import { Clickers } from '../../services';

this.fixture = null;
this.instance = null;

let clickerListProviders: Array<any> = [
provide(Clickers, {useClass: ClickersMock}),
];

describe('ClickerList', () => {

beforeEachProviders(() => providers);
beforeEachProviders(() => providers.concat(clickerListProviders));
beforeEach(injectAsyncWrapper(asyncCallbackFactory(ClickerList, this, true)));

it('initialises', () => {
Expand Down
9 changes: 4 additions & 5 deletions app/pages/clickerList/clickerList.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Clickers } from '../../services/clickers';
import { ClickerButton } from '../../components/clickerButton/clickerButton';
import { ClickerForm } from '../../components/clickerForm/clickerForm';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Clickers } from '../../services';
import { ClickerButton, ClickerForm } from '../../components';

@Component({
templateUrl: 'build/pages/clickerList/clickerList.html',
Expand Down
2 changes: 2 additions & 0 deletions app/pages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './clickerList/clickerList.ts';
export * from './page2/page2.ts';
11 changes: 11 additions & 0 deletions app/services/clickers.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// CLICKERS:

export class ClickersMock {
public doClick(): boolean {
return true;
}

public newClicker(): boolean {
return true;
}
}
7 changes: 3 additions & 4 deletions app/services/clickers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

import { Injectable } from '@angular/core';
import { SqlStorage } from 'ionic-angular';
import { Clicker } from '../models/clicker';
import { Click } from '../models/click';
import { Injectable } from '@angular/core';
import { SqlStorage } from 'ionic-angular';
import { Click, Clicker } from '../models';

@Injectable()
export class Clickers {
Expand Down
2 changes: 2 additions & 0 deletions app/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './clickers';
export * from './utils';
1 change: 1 addition & 0 deletions app/services/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './clickers.mock';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"typings": "1.3.0"
},
"name": "clicker",
"version": "1.3.4",
"version": "1.3.5",
"description": "clicker: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-device",
Expand Down
4 changes: 1 addition & 3 deletions test/diExports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/te
import { injectAsync } from '@angular/core/testing';
import { Control } from '@angular/common';
import { App, Config, Form, NavController, Platform } from 'ionic-angular';
import { ClickersMock, ConfigMock, NavMock } from './mocks';
import { ConfigMock, NavMock } from './mocks';
import { Utils } from '../app/services/utils';
import { Clickers } from '../app/services/clickers';
export { TestUtils } from './testUtils';

export let providers: Array<any> = [
Form,
provide(Config, {useClass: ConfigMock}),
provide(Clickers, {useClass: ClickersMock}), // required by ClickerButton
provide(App, {useClass: ConfigMock}), // required by ClickerList
provide(NavController, {useClass: NavMock}), // required by ClickerList
provide(Platform, {useClass: ConfigMock}), // -> IonicApp
Expand Down
2 changes: 1 addition & 1 deletion test/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function(config) {
transform: [
['browserify-istanbul', {
instrumenter: require('isparta'),
ignore: ['**/*.spec.ts','**/*.d.ts'],
ignore: ['**/*.spec.ts','**/*.d.ts', '**/index.ts', '**/mocks.ts', '**/*.mock.ts'],
}]
],
plugin: [
Expand Down
16 changes: 0 additions & 16 deletions test/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
// CLICKERS:

export class ClickersMock {
public doClick(): boolean {
return true;
}

public newClicker(): boolean {
return true;
}
}

export class ClickerMock {
public name: string = 'TEST CLICKER';
public getCount(): number { return 10; };
}

// IONIC:

Expand Down

0 comments on commit 0734e45

Please sign in to comment.