-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
222 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@import '~sass-flex-mixin/flex'; | ||
|
||
.footer { | ||
@extend %flexbox; | ||
@include justify-content(flex-end); | ||
|
||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
padding: 0.5rem; | ||
} | ||
|
||
.updaterBar { | ||
@extend %flexbox; | ||
@include flex-grow(1); | ||
@include align-items(center); | ||
|
||
:global { | ||
.icon { | ||
width: 1.5rem; | ||
margin-left: 1rem; | ||
} | ||
} | ||
} | ||
|
||
.contactBar { | ||
width: 4rem; | ||
} | ||
|
||
.link { | ||
font-size: 0.5rem; | ||
color: #fff; | ||
background: #ceecd2; | ||
padding: 0.2rem; | ||
margin-right: 1rem; | ||
text-decoration: none; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import configureMockStore from 'redux-mock-store'; | ||
import { expect } from 'chai'; | ||
import nock from 'nock'; | ||
import Immutable from 'seamless-immutable'; | ||
import { apiMiddleware } from 'redux-api-middleware'; | ||
import thunk from 'redux-thunk'; | ||
import apiMiddlewareHook from '../../middlewares/apiMiddlewareHook'; | ||
import camelizeState from '../../middlewares/camelizeState'; | ||
import _last from 'lodash/last'; | ||
import updater, { FETCH_SUCCESS, check } from '../updater'; | ||
|
||
const middlewares = [ | ||
thunk, apiMiddlewareHook, apiMiddleware, camelizeState | ||
]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
describe('Updater Actions', function actions() { | ||
afterEach(() => { | ||
nock.cleanAll(); | ||
}); | ||
|
||
it('FETCH_SUCCESS', function fetchSuccess(done) { | ||
nock('https://api.github.com') | ||
.get('/repos/Darmody/DoubanFMac/releases/latest') | ||
.reply(200, { tagName: 'v1.0.0' }); | ||
|
||
const store = mockStore({ | ||
updater: { | ||
currentVersion: '1.0.0' | ||
} | ||
}); | ||
store.dispatch(check()); | ||
setTimeout(() => { | ||
expect(_last(store.getActions()).type).to.equal(FETCH_SUCCESS); | ||
done(); | ||
}, 20); | ||
}); | ||
}); | ||
|
||
describe('Updater Reducers', function reducers() { | ||
it('FETCH_SUCCESS', function fetchSuccess() { | ||
expect( | ||
updater(Immutable({ | ||
currentVersion: '1.0.0', | ||
outdated: false, | ||
}), { | ||
type: FETCH_SUCCESS, | ||
payload: { tagName: 'v1.0.1' } | ||
}) | ||
).to.deep.equal({ | ||
currentVersion: '1.0.0', | ||
outdated: true, | ||
}); | ||
|
||
expect( | ||
updater(Immutable({ | ||
currentVersion: '1.0.0', | ||
outdated: false, | ||
}), { | ||
type: FETCH_SUCCESS, | ||
payload: { tagName: 'v1.0.0' } | ||
}) | ||
).to.deep.equal({ | ||
currentVersion: '1.0.0', | ||
outdated: false, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Immutable from 'seamless-immutable'; | ||
import { CALL_API } from 'redux-api-middleware'; | ||
import { handleActions } from 'redux-actions'; | ||
import semver from 'semver'; | ||
import pkg from '../../package.json'; | ||
|
||
export const FETCH_REQUEST = 'UPDATER/FETCH_REQUEST'; | ||
export const FETCH_SUCCESS = 'UPDATER/FETCH_SUCCESS'; | ||
export const FETCH_FAILURE = 'UPDATER/FETCH_FAILURE'; | ||
|
||
const initialState = Immutable({ | ||
outdated: false, | ||
currentVersion: pkg.version | ||
}); | ||
|
||
export default handleActions({ | ||
[FETCH_SUCCESS]: (state, action) => { | ||
const latestVersion = semver.clean(action.payload.tagName); | ||
return state.merge({ outdated: semver.gt(latestVersion, state.currentVersion) }); | ||
} | ||
}, initialState); | ||
|
||
export function check() { | ||
return { | ||
[CALL_API]: { | ||
endpoint: 'https://api.github.com/repos/Darmody/DoubanFMac/releases/latest', | ||
method: 'GET', | ||
types: [ | ||
FETCH_REQUEST, | ||
FETCH_SUCCESS, | ||
FETCH_FAILURE | ||
] | ||
} | ||
}; | ||
} |