-
Notifications
You must be signed in to change notification settings - Fork 54
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 #227 from zxan1285/user-search-pagination
User search pagination fixed
- Loading branch information
Showing
6 changed files
with
97 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import UserOverview from '../../../../../client/components/Users/UserOverview'; | ||
|
||
describe('#Client-Components-UserOverview', () => { | ||
const renderComponent = (options) => { | ||
options = options || {}; | ||
|
||
const defaultFunction = () => ''; | ||
return shallow( | ||
<UserOverview | ||
onReset={options.onReset || defaultFunction} | ||
onSearch={options.onSearch || defaultFunction} | ||
error={options.error || null} | ||
users={options.users || []} | ||
total={options.total || 0} | ||
loading={options.loading || false} | ||
fetchQuery={options.fetchQuery || ''} | ||
renderActions={options.renderActions || defaultFunction} | ||
getUsersOnPage={options.getUsersOnPage || defaultFunction} | ||
/> | ||
); | ||
}; | ||
|
||
it('handleUsersPageChange should use correct query/filter params', (done) => { | ||
const pageNum = 1; | ||
const selectedFilter = 'email'; | ||
const options = { | ||
fetchQuery: '*@example.com', | ||
getUsersOnPage: (page, query, filter) => { | ||
expect(page).to.equal(pageNum); | ||
expect(query).to.equal(options.fetchQuery); | ||
expect(filter).to.equal(selectedFilter); | ||
return done(); | ||
} | ||
}; | ||
|
||
const component = renderComponent(options); | ||
|
||
component.setState({ selectedFilter: { filterBy: selectedFilter } }); | ||
component.instance().handleUsersPageChange(pageNum); | ||
}); | ||
}); |
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,39 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-15'; | ||
import { JSDOM } from 'jsdom'; | ||
import auth0 from 'auth0-js'; | ||
import chai from 'chai'; | ||
import chaiMatch from 'chai-match'; | ||
|
||
chai.use(chaiMatch); | ||
|
||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>'); | ||
const { window } = jsdom; | ||
|
||
function copyProps(src, target) { | ||
const props = Object.getOwnPropertyNames(src) | ||
.filter(prop => typeof target[prop] === 'undefined') | ||
.reduce((result, prop) => ({ | ||
...result, | ||
[prop]: Object.getOwnPropertyDescriptor(src, prop), | ||
}), {}); | ||
Object.defineProperties(target, props); | ||
} | ||
|
||
/* Initialize configuration */ | ||
window.config = { | ||
AUTH0_DOMAIN: 'unitTesting.fakeAuth0.com', | ||
AUTH0_CLIENT_ID: 'fake-client-id' | ||
}; | ||
|
||
global.auth0 = auth0; | ||
global.window = window; | ||
global.document = window.document; | ||
global.navigator = { | ||
userAgent: 'node.js' | ||
}; | ||
global.self = { navigator: global.navigator }; | ||
|
||
copyProps(window, global); | ||
|
||
configure({ adapter: new Adapter() }); |
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