-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b4e1dfc
commit 4064803
Showing
7 changed files
with
181 additions
and
25 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,129 @@ | ||
/* | ||
* Copyright 2018, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var expect = require('expect'); | ||
const { testEpic, addTimeoutEpic, TEST_TIMEOUT } = require('./epicTestUtils'); | ||
|
||
const { | ||
clearWidgetsOnLocationChange | ||
} = require('../widgets'); | ||
const { | ||
CLEAR_WIDGETS | ||
} = require('../../actions/widgets'); | ||
const { | ||
savingMap, | ||
mapCreated | ||
} = require('../../actions/maps'); | ||
const { | ||
configureMap | ||
} = require('../../actions/config'); | ||
const { LOCATION_CHANGE } = require('react-router-redux'); | ||
|
||
describe('widgets Epics', () => { | ||
it('clearWidgetsOnLocationChange triggers CLEAR_WIDGETS on LOCATION_CHANGE', (done) => { | ||
const checkActions = actions => { | ||
expect(actions.length).toBe(1); | ||
const action = actions[0]; | ||
expect(action.type).toBe(CLEAR_WIDGETS); | ||
done(); | ||
}; | ||
let count = 0; | ||
testEpic(clearWidgetsOnLocationChange, | ||
1, | ||
[configureMap(), { type: LOCATION_CHANGE, payload: { | ||
pathname: "newPath" | ||
}}], | ||
checkActions, | ||
() => { | ||
return count++ | ||
? { | ||
routing: { | ||
location: "new" | ||
} | ||
} | ||
: { | ||
routing: { | ||
location: "old" | ||
} | ||
}; | ||
}); | ||
}); | ||
it('clearWidgetsOnLocationChange stops CLEAR_WIDGETS triggers if saving', (done) => { | ||
const checkActions = actions => { | ||
expect(actions.length).toBe(1); | ||
const action = actions[0]; | ||
expect(action.type).toBe(TEST_TIMEOUT); | ||
done(); | ||
}; | ||
let count = 0; | ||
testEpic(addTimeoutEpic(clearWidgetsOnLocationChange, 20), | ||
1, | ||
[ | ||
configureMap(), | ||
savingMap(), | ||
{ | ||
type: LOCATION_CHANGE, | ||
payload: { | ||
pathname: "newPath" | ||
} | ||
} | ||
], | ||
checkActions, | ||
() => { | ||
return count++ | ||
? { | ||
routing: { | ||
location: "new" | ||
} | ||
} | ||
: { | ||
routing: { | ||
location: "old" | ||
} | ||
}; | ||
}); | ||
}); | ||
it('clearWidgetsOnLocationChange restores CLEAR_WIDGETS triggers after save completed', (done) => { | ||
const checkActions = actions => { | ||
expect(actions.length).toBe(1); | ||
const action = actions[0]; | ||
expect(action.type).toBe(CLEAR_WIDGETS); | ||
done(); | ||
}; | ||
let count = 0; | ||
testEpic(clearWidgetsOnLocationChange, | ||
1, | ||
[configureMap(), | ||
savingMap(), | ||
{ | ||
type: LOCATION_CHANGE, | ||
payload: { | ||
pathname: "newPath" | ||
} | ||
}, | ||
mapCreated(), | ||
{ | ||
type: LOCATION_CHANGE, payload: { | ||
pathname: "newPath" | ||
} | ||
}], | ||
checkActions, | ||
() => { | ||
return count++ | ||
? { | ||
routing: { | ||
location: "new" | ||
} | ||
} | ||
: { | ||
routing: { | ||
location: "old" | ||
} | ||
}; | ||
}); | ||
}); | ||
}); |
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