-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for route definitions (#443)
* test: add unit tests for route action utils/enhancers * test: use .at.least() instead of .within() * test: add unit test for action factory * fix: give track-perf duration assertions some wiggle room * test: add unit tests for resource action enhancer and route definition utils * test: add unit tests for route definitions
- Loading branch information
1 parent
ec18b7a
commit c8995a2
Showing
25 changed files
with
694 additions
and
79 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 was deleted.
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 was deleted.
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
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
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
107 changes: 107 additions & 0 deletions
107
src/packages/router/definitions/test/normalize-resource-args.test.js
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,107 @@ | ||
// @flow | ||
import { expect } from 'chai'; | ||
import { it, describe, before } from 'mocha'; | ||
|
||
import { BUILT_IN_ACTIONS } from '../../../controller'; | ||
|
||
import normalizeResourceArgs from '../context/utils/normalize-resource-args'; | ||
|
||
describe('module "router/definitions/context"', () => { | ||
describe('util normalizeResourceArgs()', () => { | ||
it('normalizes arguments with a name only', () => { | ||
// $FlowIgnore | ||
const result = normalizeResourceArgs(['posts']); | ||
|
||
expect(result).to.be.an('array'); | ||
|
||
expect(result) | ||
.to.have.property('0') | ||
.and.deep.equal({ | ||
name: 'posts', | ||
path: '/posts', | ||
only: BUILT_IN_ACTIONS | ||
}); | ||
|
||
expect(result) | ||
.to.have.property('1') | ||
.and.be.a('function'); | ||
}); | ||
|
||
it('normalizes arguments with a name and options', () => { | ||
// $FlowIgnore | ||
const result = normalizeResourceArgs(['posts', { | ||
only: [ | ||
'show', | ||
'index' | ||
] | ||
}]); | ||
|
||
expect(result).to.be.an('array'); | ||
|
||
expect(result) | ||
.to.have.property('0') | ||
.and.deep.equal({ | ||
name: 'posts', | ||
path: '/posts', | ||
only: [ | ||
'show', | ||
'index' | ||
] | ||
}); | ||
|
||
expect(result) | ||
.to.have.property('1') | ||
.and.be.a('function'); | ||
}); | ||
|
||
it('normalizes arguments with a name and builder', () => { | ||
// $FlowIgnore | ||
const result = normalizeResourceArgs(['posts', function () { | ||
return undefined; | ||
}]); | ||
|
||
expect(result).to.be.an('array'); | ||
|
||
expect(result) | ||
.to.have.property('0') | ||
.and.deep.equal({ | ||
name: 'posts', | ||
path: '/posts', | ||
only: BUILT_IN_ACTIONS | ||
}); | ||
|
||
expect(result) | ||
.to.have.property('1') | ||
.and.be.a('function'); | ||
}); | ||
|
||
it('normalizes arguments with a name, options, and builder', () => { | ||
// $FlowIgnore | ||
const result = normalizeResourceArgs(['posts', { | ||
only: [ | ||
'show', | ||
'index' | ||
] | ||
}, function () { | ||
return undefined; | ||
}]); | ||
|
||
expect(result).to.be.an('array'); | ||
|
||
expect(result) | ||
.to.have.property('0') | ||
.and.deep.equal({ | ||
name: 'posts', | ||
path: '/posts', | ||
only: [ | ||
'show', | ||
'index' | ||
] | ||
}); | ||
|
||
expect(result) | ||
.to.have.property('1') | ||
.and.be.a('function'); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// @flow | ||
export const FINAL_HANDLER = '__FINAL__HANDLER__'; | ||
export const FINAL_HANDLER = '__FINAL_HANDLER__'; |
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
Oops, something went wrong.