-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa80274
commit c9867a2
Showing
8 changed files
with
131 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### isLayoutMeta | ||
|
||
Check if '/_layouts/:name/instances/:id/meta' is in the uri | ||
|
||
#### Params | ||
|
||
* `uri` _string_ | ||
|
||
**Returns** _boolean_ | ||
|
||
#### Example | ||
|
||
```js | ||
isPage('domain.com/_layouts/foo/instances/bar/meta') | ||
//=> true | ||
|
||
``` |
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,16 @@ | ||
'use strict'; | ||
|
||
const isUriStringCheck = require('../strCheck'), | ||
isLayout = require('../isLayout'), | ||
getLayoutInstance = require('../getLayoutInstance'); | ||
|
||
/** | ||
* First test if argument is a String. If true, test if '/_layouts/:name/instances/:id/meta' is in the string. | ||
* Otherwise, throw an error. | ||
* @param {string} uri | ||
* @return {Boolean} | ||
*/ | ||
module.exports = function (uri) { | ||
isUriStringCheck.strCheck(uri); | ||
return isLayout(uri) && !!getLayoutInstance(uri) && !!uri.match(/\/meta$/i); | ||
}; |
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,33 @@ | ||
'use strict'; | ||
|
||
const name = __filename.split('/').pop().split('.').shift(), | ||
fn = require('./' + name), | ||
expect = require('chai').expect; | ||
|
||
describe('isLayoutMeta', () => { | ||
it('returns false if default', () => { | ||
expect(fn('domain.com/_layouts/foo/meta')).to.equal(false); | ||
}); | ||
|
||
it('returns false if no meta', () => { | ||
expect(fn('domain.com/_layouts/foo/instances/bar')).to.equal(false); | ||
}); | ||
|
||
it('returns true if meta', () => { | ||
expect(fn('domain.com/sitepath/_layouts/foo/instances/bar/meta')).to.equal(true); | ||
}); | ||
|
||
it('throws an error if the URI passed in is not a string', () => { | ||
const nonStringArgument = function () { | ||
return fn([0, 1, 2, 3]); | ||
}; | ||
|
||
expect(nonStringArgument).to.throw(Error); | ||
}); | ||
|
||
it('returns false if non-layout reference', () => { | ||
expect(fn('domain.com/_users/foo')).to.equal(false); | ||
expect(fn('domain.com/_components/foo')).to.equal(false); | ||
expect(fn('domain.com/_pages/foo/meta')).to.equal(false); | ||
}); | ||
}); |
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,17 @@ | ||
### isPageMeta | ||
|
||
Check if '/_pages/:id/meta' is in the uri | ||
|
||
#### Params | ||
|
||
* `uri` _string_ | ||
|
||
**Returns** _boolean_ | ||
|
||
#### Example | ||
|
||
```js | ||
isPage('domain.com/_pages/foobar/meta') | ||
//=> true | ||
|
||
``` |
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,15 @@ | ||
'use strict'; | ||
|
||
const isUriStringCheck = require('../strCheck'), | ||
isPage = require('../isPage'); | ||
|
||
/** | ||
* First test if argument is a String. If true, test if '/_pages/:id/meta' is in the string. | ||
* Otherwise, throw an error. | ||
* @param {string} uri | ||
* @return {Boolean} | ||
*/ | ||
module.exports = function (uri) { | ||
isUriStringCheck.strCheck(uri); | ||
return isPage(uri) && !!uri.match(/\/meta$/i); | ||
}; |
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,29 @@ | ||
'use strict'; | ||
|
||
const name = __filename.split('/').pop().split('.').shift(), | ||
fn = require('./' + name), | ||
expect = require('chai').expect; | ||
|
||
describe('isPageMeta', () => { | ||
it('returns false if no meta', () => { | ||
expect(fn('domain.com/_pages/foo')).to.equal(false); | ||
}); | ||
|
||
it('returns true if meta', () => { | ||
expect(fn('domain.com/sitepath/_pages/foobarbaz/meta')).to.equal(true); | ||
}); | ||
|
||
it('throws an error if the URI passed in is not a string', () => { | ||
const nonStringArgument = function () { | ||
return fn([0, 1, 2, 3]); | ||
}; | ||
|
||
expect(nonStringArgument).to.throw(Error); | ||
}); | ||
|
||
it('returns false if non-page reference', () => { | ||
expect(fn('domain.com/_users/foo')).to.equal(false); | ||
expect(fn('domain.com/_components/foo')).to.equal(false); | ||
expect(fn('domain.com/_layouts/foo/instances/bar/meta')).to.equal(false); | ||
}); | ||
}); |