-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* incremented test coverage for tasks and maps actions * add tests for PluginUtils
- Loading branch information
1 parent
8164e45
commit b600784
Showing
4 changed files
with
134 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright 2017, 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. | ||
*/ | ||
const expect = require('expect'); | ||
const PluginsUtils = require('../PluginsUtils'); | ||
const assign = require('object-assign'); | ||
|
||
describe('PluginsUtils', () => { | ||
beforeEach( () => { | ||
|
||
}); | ||
afterEach((done) => { | ||
document.body.innerHTML = ''; | ||
|
||
setTimeout(done); | ||
}); | ||
it('combineReducers', () => { | ||
const P1 = { | ||
reducers: { | ||
reducer1: () => {} | ||
} | ||
}; | ||
|
||
const P2 = { | ||
reducers: { | ||
reducer1: (state = {}) => assign({}, state, { A: "A"}), | ||
reducer2: (state = {}) => state | ||
} | ||
}; | ||
const reducers = { | ||
reducer3: (state = {}) => state | ||
}; | ||
const spyNo = expect.spyOn(P1.reducers, "reducer1"); | ||
const finalReducer = PluginsUtils.combineReducers([P1, P2], reducers); | ||
const state = finalReducer(); | ||
expect(state.reducer1).toExist(); | ||
expect(state.reducer1.A).toBe("A"); | ||
|
||
// test overriding | ||
expect(spyNo.calls.length).toBe(0); | ||
}); | ||
it('getPluginDescriptor', () => { | ||
const P1 = assign( () => {}, { | ||
reducers: { | ||
reducer1: () => {} | ||
} | ||
}); | ||
const item = { | ||
test: "TEST" | ||
}; | ||
const P2 = assign( () => {}, { | ||
P1: item, | ||
reducers: { | ||
reducer1: () => ({ A: "A"}), | ||
reducer2: () => {} | ||
} | ||
}); | ||
const cfg = { | ||
test: "TEST" | ||
}; | ||
let desc1 = PluginsUtils.getPluginDescriptor({}, {P1Plugin: P1, P2Plugin: P2}, [{name: "P1", cfg}, "P2"], "P1" ); | ||
expect(desc1).toExist(); | ||
expect(desc1.id).toBe("P1"); | ||
expect(desc1.name).toBe("P1"); | ||
expect(desc1.cfg).toExist(cfg); | ||
expect(desc1.items.length).toBe(1); | ||
expect(desc1.items[0].test).toBe(item.test); | ||
expect(desc1.items[0].cfg).toExist(); | ||
|
||
}); | ||
|
||
}); |