{name}
26 |39 | {nextOne === 'DONE' ? '' : `Next One: ${nextOne}`} 40 |
41 |BilgiShuttle is an open-source project that aims to build simple and usable cross-platform app for listing the shuttle routes and times of İstanbul Bilgi University.
15 |There is a REST API on the backend which is running on api.bilgishuttle.com
16 |You are currently viewing the web application.
17 |We also have iOS and Android versions, but they aren't published yet.
18 |However, you can check all the applications written for this project on Github.
19 |If you'd like to support the project, you can contact us on bilgishuttle@gmail.com
20 |
69 |
70 |
71 |
72 |
73 | ## License
74 |
75 | Copyright [2016] [Altay Aydemir]
76 |
77 | Licensed under the Apache License, Version 2.0 (the "License");
78 | you may not use this file except in compliance with the License.
79 | You may obtain a copy of the License at
80 |
81 | http://www.apache.org/licenses/LICENSE-2.0
82 |
83 | Unless required by applicable law or agreed to in writing, software
84 | distributed under the License is distributed on an "AS IS" BASIS,
85 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86 | See the License for the specific language governing permissions and
87 | limitations under the License.
88 |
--------------------------------------------------------------------------------
/app/redux/modules/nodes/index.test.ts:
--------------------------------------------------------------------------------
1 | import { API_URL, createMockStore } from '../../../helpers/Test';
2 | import { expect } from 'chai';
3 | const fetchMock = require('fetch-mock');
4 |
5 | import * as n from './';
6 | import * as I from '../../../models/nodes';
7 |
8 | /** Fake Data */
9 | const data: I.NodeDetail[] = [
10 | {
11 | image: '/media/nodes/kabatas_JtKuUYU.png',
12 | id: 8,
13 | name: 'Kabataş'
14 | },
15 | {
16 | image: '/media/nodes/santral_AD5d4PA.png',
17 | id: 9,
18 | name: 'Santral'
19 | }
20 | ];
21 |
22 | const error: Object = {
23 | message: 'Error'
24 | };
25 |
26 | /** Nodes Module: Reducer Tests */
27 | describe('Nodes Module: Reducer', () => {
28 |
29 | it('returns current state by default', () => {
30 | expect(n.nodesReducer(n.initialState)).to.eql(n.initialState);
31 | });
32 |
33 | it('handles GET_NODES_REQUEST', () => {
34 | const action: I.NodeAction = n.getNodesRequest();
35 | expect(n.nodesReducer(n.initialState, action)).to.eql({
36 | isFetching: true,
37 | data: []
38 | });
39 | });
40 |
41 | it('handles GET_NODES_SUCCESS', () => {
42 | const action: I.NodeAction = n.getNodesSuccess(data);
43 | expect(n.nodesReducer(n.initialState, action)).to.eql({
44 | isFetching: false,
45 | data: action.payload
46 | });
47 | });
48 |
49 | it('handles GET_NODES_FAILURE', () => {
50 | const action: I.NodeAction = n.getNodesFailure(error);
51 | expect(n.nodesReducer(n.initialState, action)).to.eql({
52 | isFetching: false,
53 | data: [],
54 | error: action.error
55 | });
56 | });
57 |
58 | });
59 |
60 | /** Nodes Module: Action Creators */
61 | describe('Nodes Module: Action Creators', () => {
62 |
63 | describe('Get Nodes (Async)', () => {
64 |
65 | afterEach(() => {
66 | fetchMock.restore();
67 | });
68 |
69 | it('dispatches getNodesSuccess on OK reqs', (done) => {
70 | fetchMock.mock(`${API_URL}/index.json`, {
71 | status: 200,
72 | body: {
73 | nodes: data
74 | }
75 | });
76 |
77 | const action: I.NodeAction = n.getNodes();
78 | const store = createMockStore(n.initialState);
79 |
80 | const expectedActions: I.NodeAction[] = [
81 | { type: n.GET_NODES_REQUEST },
82 | { type: n.GET_NODES_SUCCESS, payload: data }
83 | ];
84 |
85 | store.dispatch(action)
86 | .then(() => expect(store.getActions()).to.eql(expectedActions))
87 | .then(() => done())
88 | .catch(err => done(err));
89 | });
90 |
91 | it('dispatches getNodesFailure on failed reqs', (done) => {
92 | fetchMock.mock(`${API_URL}/index.json`, {
93 | status: 400,
94 | body: {
95 | error
96 | }
97 | });
98 |
99 | const action: I.NodeAction = n.getNodes();
100 | const store = createMockStore(n.initialState);
101 |
102 | const expectedActions: I.NodeAction[] = [
103 | { type: n.GET_NODES_REQUEST },
104 | { type: n.GET_NODES_FAILURE, error: {error} }
105 | ];
106 |
107 | store.dispatch(action)
108 | .then(() => expect(store.getActions()).to.eql(expectedActions))
109 | .then(() => done())
110 | .catch(err => done(err));
111 | });
112 |
113 | });
114 |
115 | describe('Get Nodes Request', () => {
116 | it('has the correct type', () => {
117 | const action: I.NodeAction = n.getNodesRequest();
118 | expect(action.type).to.eql(n.GET_NODES_REQUEST);
119 | });
120 | });
121 |
122 | describe('Get Nodes Success', () => {
123 | it('has the correct type and payload', () => {
124 | const action: I.NodeAction = n.getNodesSuccess(data);
125 | expect(action.type).to.eql(n.GET_NODES_SUCCESS);
126 | expect(action.payload).to.eql(data);
127 | });
128 | });
129 |
130 | describe('Get Nodes Failure', () => {
131 | it('has the correct type and payload', () => {
132 | const action: I.NodeAction = n.getNodesFailure(error);
133 | expect(action.type).to.eql(n.GET_NODES_FAILURE);
134 | expect(action.error).to.eql(error);
135 | });
136 | });
137 |
138 | });
139 |
--------------------------------------------------------------------------------
/app/redux/modules/routes/index.test.ts:
--------------------------------------------------------------------------------
1 | import { API_URL, createMockStore } from '../../../helpers/Test';
2 | import { expect } from 'chai';
3 |
4 | import * as r from './';
5 | import * as I from '../../../models/routes';
6 |
7 | const fetchMock = require('fetch-mock');
8 |
9 | /** Mock Data */
10 | const data: I.RouteData = [{
11 | 'routes': [
12 | {
13 | 'raw_data': '08:00 - Ring - 20:00',
14 | 'destination': 'Santral',
15 | 'next': {
16 | 'in_secs': 23159,
17 | 'ring': false,
18 | 'next_next_one': '20:00'
19 | },
20 | 'start': {
21 | 'image': '/media/nodes/kabatas_JtKuUYU.png',
22 | 'id': 8,
23 | 'name': 'Kabataş'
24 | },
25 | 'destination_image': '/media/nodes/santral_AD5d4PA.png'
26 | }
27 | ],
28 | 'start_node': {
29 | 'image': '/media/nodes/kabatas_JtKuUYU.png',
30 | 'id': 8,
31 | 'name':
32 | 'Kabataş'
33 | }
34 | }];
35 |
36 | const error: Object = {
37 | message: 'Error'
38 | };
39 |
40 | /** Routes Module: Reducer Tests */
41 | describe('Routes Module: Reducer', () => {
42 | it('returns current state by default', () => {
43 | expect(r.routesReducer(r.initialState)).to.eql(r.initialState);
44 | });
45 |
46 | it('handles GET_ROUTES_REQUEST', () => {
47 | const action: I.RouteAction = r.getRoutesRequest();
48 | expect(r.routesReducer(r.initialState, action)).to.eql({
49 | isFetching: true,
50 | data: [],
51 | error: ''
52 | });
53 | });
54 |
55 | it('handles GET_ROUTES_SUCCESS', () => {
56 | const action: I.RouteAction = r.getRoutesSuccess(data);
57 | expect(r.routesReducer(r.initialState, action).data[0]).to.eql(
58 | action.payload
59 | );
60 | expect(r.routesReducer(r.initialState, action).isFetching).to.be.false;
61 | });
62 |
63 | it('handles GET_ROUTES_FAILURE', () => {
64 | const action: I.RouteAction = r.getRoutesFailure(error);
65 |
66 | expect(r.routesReducer(r.initialState, action)).to.eql({
67 | isFetching: false,
68 | data: [],
69 | error: action.error
70 | });
71 | });
72 | });
73 |
74 |
75 | /** Routes Module: Action Creators */
76 | describe('Routes Module: Action Creators', () => {
77 | describe('Get Routes (Async)', () => {
78 | afterEach(() => {
79 | fetchMock.restore();
80 | });
81 |
82 | it('dispatches getRoutesSuccess on OK reqs', (done) => {
83 | fetchMock.mock(`${API_URL}/kabatas.json`, {
84 | status: 200,
85 | body: data
86 | });
87 |
88 | const action: I.RouteAction = r.getRoutes('kabatas');
89 | const store = createMockStore(r.initialState);
90 |
91 | const expectedActions: I.RouteAction[] = [
92 | { type: r.GET_ROUTES_REQUEST },
93 | { type: r.GET_ROUTES_SUCCESS, payload: data }
94 | ];
95 |
96 | store.dispatch(action)
97 | .then(() => expect(store.getActions()).to.eql(expectedActions))
98 | .then(() => done())
99 | .catch(err => done(err));
100 | });
101 |
102 | it('dispatches getRoutesFailure on failed reqs', (done) => {
103 | fetchMock.mock(`${API_URL}/kabatas.json`, {
104 | status: 400,
105 | body: error
106 | });
107 |
108 | const action: I.RouteAction = r.getRoutes('kabatas');
109 | const store = createMockStore(r.initialState);
110 |
111 | const expectedActions: I.RouteAction[] = [
112 | { type: r.GET_ROUTES_REQUEST },
113 | { type: r.GET_ROUTES_FAILURE, error }
114 | ];
115 |
116 | store.dispatch(action)
117 | .then(() => expect(store.getActions()).to.eql(expectedActions))
118 | .then(() => done())
119 | .catch(err => done(err));
120 | });
121 | });
122 |
123 | describe('Get Routes Request', () => {
124 | it('has the correct type', () => {
125 | const action: I.RouteAction = r.getRoutesRequest();
126 | expect(action.type).to.eql(r.GET_ROUTES_REQUEST);
127 | });
128 | });
129 |
130 | describe('Get Routes Success', () => {
131 | it('has the correct type and payload', () => {
132 | const action: I.RouteAction = r.getRoutesSuccess(data);
133 | expect(action.type).to.eql(r.GET_ROUTES_SUCCESS);
134 | expect(action.payload).to.eql(data);
135 | });
136 | });
137 |
138 | describe('Get Routes Failure', () => {
139 | it('has the correct type and payload', () => {
140 | const action: I.RouteAction = r.getRoutesFailure(error);
141 | expect(action.type).to.eql(r.GET_ROUTES_FAILURE);
142 | expect(action.error).to.eql(error);
143 | });
144 | });
145 |
146 | });
147 |
--------------------------------------------------------------------------------