Skip to content

Commit 3ce426e

Browse files
committed
PR Feedback re: experimental mode
-applicationLoaded action creator takes object now -Bump up cyclomatic complexity in .eslintrc
1 parent 9d53cde commit 3ce426e

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
],
5151
"complexity": [
5252
2,
53-
{"max": 27}
53+
{"max": 30}
5454
],
5555
"computed-property-spacing": [
5656
2,

src/actions/applicationLoaded.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ import {createAction} from 'redux-actions';
22

33
export default createAction(
44
'APPLICATION_LOADED',
5-
(gistId = null, isExperimental = false) => ({gistId, isExperimental}),
65
);

src/components/Workspace.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,17 @@ class Workspace extends React.Component {
116116
}
117117

118118
componentWillMount() {
119-
let gistId;
119+
let gistId = null;
120120
let isExperimental = false;
121121
if (location.search) {
122122
const query = qs.parse(location.search.slice(1));
123-
gistId = query.gist;
123+
if (query.gist) {
124+
gistId = query.gist;
125+
}
124126
isExperimental = Object.keys(query).includes('experimental');
125127
}
126128
history.replaceState({}, '', location.pathname);
127-
this.props.dispatch(applicationLoaded(gistId, isExperimental));
129+
this.props.dispatch(applicationLoaded({gistId, isExperimental}));
128130
this._listenForAuthChange();
129131
startSessionHeartbeat();
130132
}

test/unit/reducers/ui.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ test('applicationLoaded', (t) => {
252252
t.test('isExperimental = true', reducerTest(
253253
reducer,
254254
initialState,
255-
partial(applicationLoaded, null, true),
255+
partial(applicationLoaded, {gistId: null, isExperimental: true}),
256256
initialState.set('experimental', true),
257257
));
258258

259259
t.test('isExperimental = false', reducerTest(
260260
reducer,
261261
initialState,
262-
partial(applicationLoaded, null, false),
262+
partial(applicationLoaded, {gistId: null, isExperimental: false}),
263263
initialState.set('experimental', false),
264264
));
265-
});
265+
});

test/unit/sagas/projects.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('changeCurrentProject()', (assert) => {
7272

7373
test('applicationLoaded()', (t) => {
7474
t.test('with no gist ID', (assert) => {
75-
testSaga(applicationLoadedSaga, applicationLoaded(null)).
75+
testSaga(applicationLoadedSaga, applicationLoaded({gistId: null})).
7676
next().call(createProjectSaga).
7777
next().isDone();
7878

@@ -81,8 +81,8 @@ test('applicationLoaded()', (t) => {
8181

8282
t.test('with gist ID', (assert) => {
8383
const gistId = '123abc';
84-
testSaga(applicationLoadedSaga, applicationLoaded(gistId)).
85-
next().call(importGistSaga, applicationLoaded(gistId)).
84+
testSaga(applicationLoadedSaga, applicationLoaded({gistId})).
85+
next().call(importGistSaga, applicationLoaded({gistId})).
8686
next().isDone();
8787

8888
assert.end();
@@ -93,7 +93,7 @@ test('importGist()', (t) => {
9393
const gistId = 'abc123';
9494

9595
t.test('with successful import', (assert) => {
96-
const saga = testSaga(importGistSaga, applicationLoaded(gistId));
96+
const saga = testSaga(importGistSaga, applicationLoaded({gistId}));
9797

9898
saga.next().call(loadFromId, gistId, {authenticated: false});
9999

@@ -122,7 +122,7 @@ test('importGist()', (t) => {
122122
});
123123

124124
t.test('with not found error', (assert) => {
125-
testSaga(importGistSaga, applicationLoaded(gistId)).
125+
testSaga(importGistSaga, applicationLoaded({gistId})).
126126
next().call(loadFromId, gistId, {authenticated: false}).
127127
throw(
128128
Object.create(new Error(), {response: {value: {status: 404}}}),
@@ -132,7 +132,7 @@ test('importGist()', (t) => {
132132
});
133133

134134
t.test('with other error', (assert) => {
135-
testSaga(importGistSaga, applicationLoaded(gistId)).
135+
testSaga(importGistSaga, applicationLoaded({gistId})).
136136
next().call(loadFromId, gistId, {authenticated: false}).
137137
throw(new Error()).put(gistImportError()).
138138
next().isDone();

test/unit/sagas/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {getInitialUserState} from '../../../src/clients/firebaseAuth';
99

1010
test('applicationLoaded', (t) => {
1111
t.test('with no logged in user', (assert) => {
12-
testSaga(applicationLoadedSaga, applicationLoaded()).
12+
testSaga(applicationLoadedSaga, applicationLoaded({})).
1313
next().call(getInitialUserState).
1414
next(null).isDone();
1515

@@ -21,7 +21,7 @@ test('applicationLoaded', (t) => {
2121
user: {uid: 'student1'},
2222
credential: {provider: 'github.com'},
2323
};
24-
testSaga(applicationLoadedSaga, applicationLoaded()).
24+
testSaga(applicationLoadedSaga, applicationLoaded({})).
2525
next().call(getInitialUserState).
2626
next(userCredential).put(userAuthenticated(userCredential)).
2727
next().isDone();

0 commit comments

Comments
 (0)