Skip to content

Commit 322baf8

Browse files
Merge pull request #3 from PistachoSoft/feature/add-travis-support
Feature/add travis support
2 parents 067725f + bd8d9e0 commit 322baf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+496
-261
lines changed

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- "5"
4+
- "6"
5+
6+
before_install:
7+
- "npm i -g [email protected]"
8+
9+
install:
10+
- npm install
11+
- npm run setup
12+
13+
script:
14+
- npm test

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[![Build Status](https://travis-ci.org/PistachoSoft/NMM-frontend.png?branch=develop)](https://travis-ci.org/PistachoSoft/NMM-frontend)
2+
3+
# NMM-Frontend
4+
5+
React browser application for NMM.
6+
7+
## Building the application
8+
9+
Before anything, run
10+
11+
```
12+
npm install
13+
npm run setup
14+
npm start
15+
```
16+
17+
Once this is done, you can open [localhost:8080](http://localhost:8080) file to browse
18+
the application.
19+
20+
The test account is `test:test`.
21+
22+
## Scripts
23+
24+
- `npm run setup`: run this command to install typings.
25+
- `npm start`: run the default dev task.
26+
- `npm run build`: build TypeScript sources and UMD distributable.
27+
- `npm test`: run all tests.
28+
- `npm run test:unit`: run unit tests only.
29+
- `npm run test:coverage`: run coverage tests.
30+
31+
## Coverage
32+
33+
The coverage reports can be found under `test/results/coverage`.
34+
35+
## Sonar
36+
37+
You will need to add the plugin [SonarTsPlugin](https://github.com/Pablissimo/SonarTsPlugin).

app/App.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import SongsView from './views/songs/SongsView';
1717
import AuthService from './services/AuthService';
1818

1919
export default class App extends React.Component<{}, {}> {
20-
constructor() {
20+
public constructor() {
2121
super();
2222
}
2323

24-
getFirstPage() {
24+
public getFirstPage() {
2525
return AuthService.isAuth() ? '/home' : '/login';
2626
}
2727

28-
requireAuth(next: RouterState, replace: Function) {
28+
public requireAuth(next: RouterState, replace: Function) {
2929
if (!AuthService.isAuth()) {
3030
replace({
3131
pathname: '/',
@@ -34,7 +34,7 @@ export default class App extends React.Component<{}, {}> {
3434
}
3535
}
3636

37-
render() {
37+
public render() {
3838
return (
3939
<Router history={browserHistory}>
4040
<Route path="/">

app/components/navbar/Navbar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {Link} from 'react-router';
33
import AuthService from '../../services/AuthService';
44

55
export default class Navbar extends React.Component<{}, {}> {
6-
logout() {
6+
public logout() {
77
AuthService.removeAuth();
88
}
99

10-
render() {
10+
public render() {
1111
return (
1212
<div className="navbar">
1313
<div className="navbar-logo">

app/components/player/Player.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22

33
export default class Player extends React.Component<{}, {}> {
4-
render() {
4+
public render() {
55
return (
66
<div className="player">
77
Player

app/components/song/Song.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from 'react';
2-
import {SongModel} from '../../models/SongModel';
2+
import {ISongModel} from '../../models/ISongModel';
33

44
export interface ISongProps {
5-
model: SongModel;
5+
model: ISongModel;
66
className: string;
77
}
88

99
export default class Song extends React.Component<ISongProps, {}> {
10-
render() {
10+
public render() {
1111
return (
1212
<div className={`${this.props.className} song`}>
1313
{this.props.model.id}. {this.props.model.name}

app/mocks/Repository.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@ import {albums} from './Albums';
44
import {songs} from './Songs';
55

66
export default class Repository {
7-
static findAllArtists() {
7+
public static findAllArtists() {
88
return Promise.resolve({
99
artists
1010
});
1111
}
1212

13-
static findAllAlbums() {
13+
public static findAllAlbums() {
1414
return Promise.resolve({
1515
albums
1616
});
1717
}
1818

19-
static findAllSongs() {
19+
public static findAllSongs() {
2020
return Promise.resolve({
2121
songs
2222
});
2323
}
2424

25-
static findSongsByAlbum(albumId: number) {
25+
public static findSongsByAlbum(albumId: number) {
2626
return Promise.resolve({
2727
songs: songs.filter((song) => {
2828
return song.albumId === albumId;
2929
})
3030
});
3131
}
3232

33-
static findAlbumsByArtist(artistId: number) {
33+
public static findAlbumsByArtist(artistId: number) {
3434
return Promise.resolve({
3535
albums: albums.filter((album) => {
3636
return album.artistId === artistId;
3737
})
3838
});
3939
}
4040

41-
static findSongsByArtist(artistId: number) {
41+
public static findSongsByArtist(artistId: number) {
4242
return Promise.resolve({
4343
songs: songs.filter((song) => {
4444
return song.artistId === artistId;
4545
})
4646
});
4747
}
4848

49-
static findArtistById(id: number) {
49+
public static findArtistById(id: number) {
5050
return Promise.resolve(artists.filter((artist) => {
5151
return artist.id === id;
5252
})[0]);
5353
}
5454

55-
static findAlbumById(id: number) {
55+
public static findAlbumById(id: number) {
5656
return Promise.resolve(albums.filter((album) => {
5757
return album.id === id;
5858
})[0]);

app/models/AlbumModel.ts renamed to app/models/IAlbumModel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface AlbumModel {
1+
export interface IAlbumModel {
22
id: number;
33
name: string;
44
image: string;

app/models/ArtistModel.ts renamed to app/models/IArtistModel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface ArtistModel {
1+
export interface IArtistModel {
22
id: number;
33
name: string;
44
image: string;

app/models/SongModel.ts renamed to app/models/ISongModel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface SongModel {
1+
export interface ISongModel {
22
id: number;
33
name: string;
44
albumId?: number;

app/models/responses/AlbumsResponse.ts

-5
This file was deleted.

app/models/responses/ArtistsResponse.ts

-5
This file was deleted.

app/models/responses/ErrorResponse.ts

-3
This file was deleted.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {IAlbumModel} from '../IAlbumModel';
2+
3+
export interface IAlbumsResponse {
4+
albums: Array<IAlbumModel>;
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {IArtistModel} from '../IArtistModel';
2+
3+
export interface IArtistsResponse {
4+
artists: Array<IArtistModel>;
5+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface IErrorResponse {
2+
message: string;
3+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {ISongModel} from '../ISongModel';
2+
3+
export interface ISongsResponse {
4+
songs: Array<ISongModel>;
5+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface ITokenResponse {
2+
token: string;
3+
}

app/models/responses/SongsResponse.ts

-5
This file was deleted.

app/models/responses/TokenResponse.ts

-3
This file was deleted.

app/services/AuthService.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
let auth = localStorage.getItem('auth') || false;
22

33
export default class AuthService {
4-
static isAuth() {
4+
public static isAuth() {
55
return !!auth;
66
}
77

8-
static setAuth(token: string) {
8+
public static setAuth(token: string) {
99
auth = token;
1010

1111
localStorage.setItem('auth', token);
1212
}
1313

14-
static removeAuth() {
14+
public static removeAuth() {
1515
auth = null;
1616

1717
localStorage.removeItem('auth');

app/services/LoginService.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import {Promise} from 'es6-promise';
2-
import {ErrorResponse} from '../models/responses/ErrorResponse';
3-
import {TokenResponse} from '../models/responses/TokenResponse';
2+
import {IErrorResponse} from '../models/responses/IErrorResponse';
3+
import {ITokenResponse} from '../models/responses/ITokenResponse';
44

55
export default class LoginService {
6-
static login(user, pass): Promise<TokenResponse> {
6+
public static login(user, pass): Promise<ITokenResponse> {
77
return new Promise((resolve, reject) => {
8-
console.log('Login:', user, pass);
9-
108
if (user.trim() === 'test' && pass.trim() === 'test' ||
119
user.trim() === 'kimjonun') {
1210
resolve({
1311
token: 'ok'
14-
} as TokenResponse);
12+
} as ITokenResponse);
1513
} else {
1614
reject({
1715
message: 'Oops, try again!'
18-
} as ErrorResponse);
16+
} as IErrorResponse);
1917
}
2018
});
2119
}

app/services/MusicService.ts

+13-29
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,41 @@
11
import {Promise} from 'es6-promise';
22
import Repository from '../mocks/Repository';
3-
import {SongsResponse} from '../models/responses/SongsResponse';
4-
import {AlbumsResponse} from '../models/responses/AlbumsResponse';
5-
import {ArtistsResponse} from '../models/responses/ArtistsResponse';
6-
import {ArtistModel} from '../models/ArtistModel';
7-
import {AlbumModel} from '../models/AlbumModel';
3+
import {ISongsResponse} from '../models/responses/ISongsResponse';
4+
import {IAlbumsResponse} from '../models/responses/IAlbumsResponse';
5+
import {IArtistsResponse} from '../models/responses/IArtistsResponse';
6+
import {IArtistModel} from '../models/IArtistModel';
7+
import {IAlbumModel} from '../models/IAlbumModel';
88

99
export default class MusicService {
10-
static getAllSongs(): Promise<SongsResponse> {
11-
console.info('GET', '/songs');
12-
10+
public static getAllSongs(): Promise<ISongsResponse> {
1311
return Repository.findAllSongs();
1412
}
1513

16-
static getSongsByAlbum(albumId: number) {
17-
console.info('GET', `/albums/${albumId}/songs`);
18-
14+
public static getSongsByAlbum(albumId: number) {
1915
return Repository.findSongsByAlbum(albumId);
2016
}
2117

22-
static getAllAlbums(): Promise<AlbumsResponse> {
23-
console.info('GET', '/albums');
24-
18+
public static getAllAlbums(): Promise<IAlbumsResponse> {
2519
return Repository.findAllAlbums();
2620
}
2721

28-
static getAlbumsByArtist(artistId: number) {
29-
console.info('GET', `/artists/${artistId}/albums`);
30-
22+
public static getAlbumsByArtist(artistId: number) {
3123
return Repository.findAlbumsByArtist(artistId);
3224
}
3325

34-
static getSongsByArtist(artistId: number) {
35-
console.info('GET', `/artists/${artistId}/songs`);
36-
26+
public static getSongsByArtist(artistId: number) {
3727
return Repository.findSongsByArtist(artistId);
3828
}
3929

40-
static getAllArtists(): Promise<ArtistsResponse> {
41-
console.info('GET', '/artists');
42-
30+
public static getAllArtists(): Promise<IArtistsResponse> {
4331
return Repository.findAllArtists();
4432
}
4533

46-
static getArtistById(id: number): Promise<ArtistModel> {
47-
console.info('GET', `/artists/${id}`);
48-
34+
public static getArtistById(id: number): Promise<IArtistModel> {
4935
return Repository.findArtistById(id);
5036
}
5137

52-
static getAlbumById(id: number): Promise<AlbumModel> {
53-
console.info('GET', `/albums/${id}`);
54-
38+
public static getAlbumById(id: number): Promise<IAlbumModel> {
5539
return Repository.findAlbumById(id);
5640
}
5741
}

0 commit comments

Comments
 (0)