Skip to content

Commit

Permalink
Release 2.1.0-beta.14 🚀
Browse files Browse the repository at this point in the history
- Fix: #168
- Fix: #167
- Fix: #163
  • Loading branch information
Jonathan Casarrubias committed Oct 21, 2016
1 parent 2a3a001 commit 5a6995e
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 42 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#### What type of issue are you creating?
- [ ] Bug
- [ ] Enhancement
- [ ] Question

#### What version of this module are you using?
- [ ] 2.0.10 (Stable)
- [ ] 2.1.0-beta.14
- [ ] Other

Write other if any:

#### Please add a description for your issue:
40 changes: 40 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# How to contribute

I'm really glad you're reading this, volunteer developers to help this project are always welcome.

If you haven't already, follow me ([@johncasarrubias](irc://chat.freenode.net/opengovernment) on twitter). I want you to keep informed about new features and tutorials.

Here are some important resources:

* [MEAN Expert Blog](http://mean.expert) tutorials about the MEAN Stack.
* [WIKI](https://github.com/mean-expert-official/loopback-sdk-builder/wiki) official wiki documentation.
* [Angular 2 Testing](https://angular.io/docs/ts/latest/guide/testing.html) official documentation for testing environment.
* Bugs? [GitHub Issues](https://github.com/mean-expert-official/loopback-sdk-builder/issues) is where to report them

## Adding Issues
If you find any bug or enhancement, you are always welcome to create a [New Issue](https://github.com/mean-expert-official/loopback-sdk-builder/issues).

## Pull Request
If you would like to contribute by adding new features, enhancements or by fixing bugs; please consider that you need to create an issue prior your pull request. This is important for tracking purposes in CHANGELOG.

Please send a [GitHub Pull Request](https://github.com/mean-expert-official/loopback-sdk-builder/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). When you send a pull request, we will love you forever if you include RSpec examples. We can always use more test coverage. Please make sure all of your commits are atomic (one feature per commit).

Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this:

$ git commit -m "A brief summary of the commit
>
> A paragraph describing what changed and its impact."

Most of the times you will need to add a new test or we may not be able to integrate it. Though, there are some cases when you don't need to add a unit test, like fixing a typo, adding a missing type, etc.

## Testing

Tests are being created and excecuted by using the Angular-CLI Tool, please refer to the official documentation.

````sh
$ cd to/loopback-sdk-builder
$ npm test
````

Thanks,
Jonathan Casarrubias, [MEAN Expert](http://mean.expert).
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular`.

## Release 2.1.0-beta.14

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/168
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/167
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/163

## Release 2.1.0-beta.13

- Hot Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/161
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mean-expert/loopback-sdk-builder",
"version": "2.1.0-beta.13",
"version": "2.1.0-beta.14",
"description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack",
"bin": {
"lb-sdk": "bin/lb-sdk"
Expand Down
7 changes: 3 additions & 4 deletions tests/angular2/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ export class AppComponent {
title = 'LoopBack SDK Builder Test Application';

constructor(
private logger: LoggerService,
private realTime: RealTime
private logger: LoggerService
) {
this.logger.info('LoopBack SDK Builder - Test Application');
// Simple IO Test
// this.realTime.IO.emit('hello', 'world');
// this.realTime.IO.on('hello').subscribe((msg: any) => this.logger.info('REALTIME: ', msg));
// Simple FireLoop set and get examples.
let RoomReference: FireLoopRef<Room> = this.realTime.FireLoop.ref<Room>(Room);
/*let RoomReference: FireLoopRef<Room> = this.realTime.FireLoop.ref<Room>(Room);
// This will get the list of results and fire every time there is new data.
RoomReference.on('changes').subscribe((rooms: Array<Room>) => this.logger.info(rooms));
RoomReference.on('child_added', {
Expand All @@ -51,6 +50,6 @@ export class AppComponent {
(messages: Array<Message>) => this.logger.info(messages)
);
MessageReference.upsert({ text : 'Hello Child Reference' }).subscribe((res: Message) => console.log(res.text));
}));
}));*/
}
}
132 changes: 99 additions & 33 deletions tests/angular2/src/app/room-service.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { TestBed, async, inject } from '@angular/core/testing';
import { SDKModule } from './shared/sdk';
import { Room, Message } from './shared/sdk/models';
import { Room, Message, FireLoopRef } from './shared/sdk/models';
import { RoomApi, MessageApi, RealTime } from './shared/sdk/services';

describe('Service: Room Service', () => {
Expand All @@ -26,6 +26,87 @@ describe('Service: Room Service', () => {
})
));


it('should listen for child_added using FireLoop API',
inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = Date.now().toString();
let ref: FireLoopRef<Room> = realTime.FireLoop.ref<Room>(Room);
let subscription = ref.on('child_added').subscribe((result: Room) => {
console.log(result);
expect(result.id).toBeTruthy();
expect(result.name).toBe(room.name);
subscription.unsubscribe();
});
ref.create(room).subscribe();
})
);

it('should listen for child_changed using FireLoop API',
inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = Date.now().toString();
let name2 = room.name + 'SSSS';
let ref: FireLoopRef<Room> = realTime.FireLoop.ref<Room>(Room);
let subscription = ref.on('child_changed').subscribe((result: Room) => {
expect(result.id).toBeTruthy();
expect(result.name).toBe(name2);
subscription.unsubscribe();
});
ref.create(room).subscribe((res: Room) => {
res.name = name2;
ref.upsert(res).subscribe();
});
})
);

it('should listen for child_removed using FireLoop API',
inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = Date.now().toString();
let ref: FireLoopRef<Room> = realTime.FireLoop.ref<Room>(Room);
let subscription = ref.on('child_removed').subscribe((result: Room) => {
console.log(result);
expect(result.id).toBeTruthy();
expect(result.name).toBe(room.name);
subscription.unsubscribe();
});
ref.create(room).subscribe((result: Room) => ref.remove(result).subscribe());
})
);

it('should set data using FireLoop API',
inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = Date.now().toString();
let ref: FireLoopRef<Room> = realTime.FireLoop.ref<Room>(Room);
let subscription = ref.create(room).subscribe((result: Room) => {
expect(result.id).toBeTruthy();
expect(result.name).toBe(room.name);
subscription.unsubscribe();
});
})
);

it('should create child data using FireLoop API',
inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = Date.now().toString();
let message: Message = new Message({ text : 'Hello Child Reference' });
let RoomReference: FireLoopRef<Room> = realTime.FireLoop.ref<Room>(Room);
let RoomSubscription = RoomReference.create(room).subscribe((instance: Room) => {
// Child Feature
let MessageReference: FireLoopRef<Message> = RoomReference.make(instance).child<Message>('messages');
MessageReference.on('child_added').subscribe((result: Message) => {
expect(result.id).toBeTruthy();
expect(result.text).toBe(message.text);
}
);
MessageReference.create(message).subscribe((res: Message) => console.log(res.text));
});
})
);

it('should create a new room instance',
async(inject([RoomApi], (roomApi: RoomApi) => {

Expand Down Expand Up @@ -56,12 +137,12 @@ describe('Service: Room Service', () => {
room.name = Date.now().toString();
return roomApi.create(room).subscribe((instance: Room) =>
roomApi.createMessages(instance.id, {
text: 'HelloRoom'
text: 'HelloRoom'
}).subscribe(message => {
expect(message.id).toBeTruthy();
expect(message.roomId).toBe(instance.id);
})
);
expect(message.id).toBeTruthy();
expect(message.roomId).toBe(instance.id);
})
);
})
));

Expand All @@ -74,9 +155,9 @@ describe('Service: Room Service', () => {
.subscribe((instance: Room) => roomApi.createMessages(instance.id, message)
.subscribe(messageInstance => roomApi.getMessages(instance.id, { where: message })
.subscribe(messages => {
expect(messages.length).toBe(1);
let msg = messages.pop();
expect(msg.text).toBe(messageInstance.text);
expect(messages.length).toBe(1);
let msg = messages.pop();
expect(msg.text).toBe(messageInstance.text);
})));
})
));
Expand All @@ -85,8 +166,8 @@ describe('Service: Room Service', () => {
async(inject([RoomApi], (roomApi: RoomApi) => {
let params = ['Hi', 'My Name Is', 'What'];
return roomApi.greetRoute(params[0], params[1], params[2])
.subscribe((result: {greeting: string}) => {
expect(result.greeting).toBe(params.join(':'));
.subscribe((result: { greeting: string }) => {
expect(result.greeting).toBe(params.join(':'));
});
})
));
Expand All @@ -95,8 +176,8 @@ describe('Service: Room Service', () => {
async(inject([RoomApi], (roomApi: RoomApi) => {
let params = ['Hi', 'My Name Is', 'Who'];
return roomApi.greetGet(params[0], params[1], params[2])
.subscribe((result: {greeting: string}) => {
expect(result.greeting).toBe(params.join(':'));
.subscribe((result: { greeting: string }) => {
expect(result.greeting).toBe(params.join(':'));
});
})
));
Expand All @@ -105,8 +186,8 @@ describe('Service: Room Service', () => {
async(inject([RoomApi], (roomApi: RoomApi) => {
let params = ['Hi', 'My Name Is', 'Slim Shady!!'];
return roomApi.greetPost(params[0], params[1], params[2])
.subscribe((result: {greeting: string}) => {
expect(result.greeting).toBe(params.join(':'));
.subscribe((result: { greeting: string }) => {
expect(result.greeting).toBe(params.join(':'));
});
})
));
Expand All @@ -115,9 +196,9 @@ describe('Service: Room Service', () => {
async(inject([RoomApi], (roomApi: RoomApi) => {
let param = { child: 'filtered' };
return roomApi.singleParamPost(param).subscribe((result: { child: string, param: undefined }) => {
expect(result.param).toBe(undefined);
expect(result.child).toBe(param.child);
});
expect(result.param).toBe(undefined);
expect(result.child).toBe(param.child);
});
})
));

Expand Down Expand Up @@ -153,19 +234,4 @@ describe('Service: Room Service', () => {
})))));
})
));
/**
It can not be tested for now because a strange Angular 2 error (No info available)
This is tested running the Test Application using ng serve instead.
it('should set data using FireLoop API',
async(inject([RealTime], (realTime: RealTime) => {
let room: Room = new Room();
room.name = 'FireLoop Room';
let ref: any = realTime.FireLoop.ref('Room');
return ref.set(room).subscribe((result: Room) => {
expect(result.id).toBeTruthy();
expect(result.name).toBe(room.name);
});
})
));
**/
});
7 changes: 6 additions & 1 deletion tests/angular2/src/app/room/room.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<button (click)="logout()">Log Out</button>
<h3>Room Name</h3>
<h3>Update Email</h3>
<form>
<input name="email" type="email" [(ngModel)]="logged.email" placeholder="Edit Email" />
<button (click)="update()">Update</button>
</form>
<h3>Room Name</h3>
<form>
<input name="name" type="text" [(ngModel)]="room.name" placeholder="Room Name" />
<button (click)="create()">Create</button> or <button (click)="join()">Join</button>
Expand Down
15 changes: 12 additions & 3 deletions tests/angular2/src/app/room/room.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Room } from '../shared/sdk/models';
import { AccountApi, RoomApi, LoggerService } from '../shared/sdk/services';
import { Room, Account, FireLoopRef } from '../shared/sdk/models';
import { AccountApi, RoomApi, LoggerService, RealTime } from '../shared/sdk/services';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
@Component({
Expand All @@ -10,16 +10,21 @@ import { Subscription } from 'rxjs';

export class RoomComponent implements OnInit {

private logged: Account;
private accountRef: FireLoopRef<Account>;
private room: Room = new Room();
private subscription: Subscription;

constructor(
private accountApi: AccountApi,
private roomApi: RoomApi,
private router: Router,
private logger: LoggerService
private logger: LoggerService,
private realTime: RealTime
) {
this.logger.info('Room Module Loaded');
this.logged = this.accountApi.getCachedCurrent();
this.accountRef = this.realTime.FireLoop.ref<Account>(Account);
}

ngOnInit() {}
Expand All @@ -28,6 +33,10 @@ export class RoomComponent implements OnInit {
this.accountApi.logout().subscribe(res => this.router.navigate(['/access']));
}

update(): void {
this.accountRef.upsert(this.logged).subscribe(res => console.log(res));
}

create(): void {
this.roomApi.create(this.room).subscribe((room: Room) => {
this.room = room;
Expand Down

0 comments on commit 5a6995e

Please sign in to comment.