forked from neo4j/neo4j-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request neo4j#880 from oskarhane/act-on-arg-change-in-desktop
Register callback for onArgumentsChange from Neo4j Desktop
- Loading branch information
Showing
5 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
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
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,87 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j, Inc" | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* global beforeAll */ | ||
import configureMockStore from 'redux-mock-store' | ||
import { createEpicMiddleware } from 'redux-observable' | ||
import { createBus, createReduxMiddleware } from 'suber' | ||
import { populateEditorFromUrlEpic, SET_CONTENT } from './editorDuck' | ||
import { APP_START, URL_ARGUMENTS_CHANGE } from '../app/appDuck' | ||
|
||
describe('editorDuck Epics', () => { | ||
let store | ||
const bus = createBus() | ||
const epicMiddleware = createEpicMiddleware(populateEditorFromUrlEpic) | ||
const mockStore = configureMockStore([ | ||
epicMiddleware, | ||
createReduxMiddleware(bus) | ||
]) | ||
beforeAll(() => { | ||
store = mockStore({ | ||
settings: { | ||
cmdchar: ':' | ||
} | ||
}) | ||
}) | ||
afterEach(() => { | ||
bus.reset() | ||
store.clearActions() | ||
}) | ||
test('Sends a SET_CONTENT event on initial url arguments', done => { | ||
const cmd = 'play' | ||
const arg = 'test-guide' | ||
const action = { | ||
type: APP_START, | ||
url: `http://url.com?cmd=${cmd}&arg=${arg}` | ||
} | ||
|
||
bus.take(SET_CONTENT, currentAction => { | ||
// Then | ||
expect(store.getActions()).toEqual([ | ||
action, | ||
{ type: SET_CONTENT, message: `:${cmd} ${arg}` } | ||
]) | ||
done() | ||
}) | ||
|
||
// When | ||
store.dispatch(action) | ||
}) | ||
test('Sends a SET_CONTENT event on url arguments change', done => { | ||
const cmd = 'play' | ||
const arg = 'test-guide' | ||
const action = { | ||
type: URL_ARGUMENTS_CHANGE, | ||
url: `?cmd=${cmd}&arg=${arg}` | ||
} | ||
|
||
bus.take(SET_CONTENT, currentAction => { | ||
// Then | ||
expect(store.getActions()).toEqual([ | ||
action, | ||
{ type: SET_CONTENT, message: `:${cmd} ${arg}` } | ||
]) | ||
done() | ||
}) | ||
|
||
// When | ||
store.dispatch(action) | ||
}) | ||
}) |