-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yarn-support #488
Merged
Merged
yarn-support #488
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f0a56d1
get template by name
mattiaerre f289a5c
fix test
mattiaerre ab7e7bb
Merge branch 'master' into yarn-support
mattiaerre 66fa535
use mocha
mattiaerre bdc3b1b
remove jest
mattiaerre 035dae2
consolidate test
mattiaerre 085b4e6
no destructuring
mattiaerre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,52 +1,47 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const injectr = require('injectr'); | ||
const path = require('path'); | ||
const _ = require('lodash'); | ||
|
||
const requireTemplate = require('../../src/utils/require-template'); | ||
|
||
describe('utils : require-template', () => { | ||
const globals = { | ||
'__dirname': '.', | ||
}; | ||
|
||
const deps = { | ||
'path': { | ||
join (a, b, c, template) { | ||
return path.join(a,b,c,template); | ||
}, | ||
resolve (a,b,template) { | ||
const dir = path.join( | ||
path.resolve(), | ||
'node_modules/oc-template-handlebars/node_modules', | ||
template | ||
); | ||
return dir; | ||
} | ||
} | ||
}; | ||
|
||
const requireTemplate = injectr( | ||
'../../src/utils/require-template.js', deps, globals | ||
); | ||
|
||
it('should return the template found if its of the correct type', () => { | ||
const template = requireTemplate('oc-template-jade'); | ||
const templateAPIs = _.keys(template); | ||
|
||
expect(_.includes(templateAPIs, | ||
'getInfo', | ||
'getCompiledTemplate', | ||
'compile', | ||
'render') | ||
).to.be.true; | ||
it('expect type of `requireTemplate` to be function', () => { | ||
expect(typeof requireTemplate).to.equal('function'); | ||
}); | ||
|
||
it('should throw an error if the template found hasn\'t the right format', () => { | ||
try { | ||
requireTemplate('handlebars'); | ||
} catch (e) { | ||
expect(e).to.equal('Error requiring oc-template: "handlebars" is not a valid oc-template'); | ||
} | ||
describe('valid', () => { | ||
const scenarios = [ | ||
{ name: 'oc-template-handlebars' }, | ||
{ name: 'oc-template-jade' } | ||
]; | ||
|
||
scenarios.forEach(scenario => { | ||
it(scenario.name, () => { | ||
const template = requireTemplate(scenario.name); | ||
|
||
[ | ||
'compile', | ||
'getCompiledTemplate', | ||
'getInfo', | ||
'render' | ||
].forEach(method => { | ||
expect(template).to.have.property(method); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('not valid', () => { | ||
const scenarios = [{ name: 'lodash' }, { name: 'oc-invalid-template' }]; | ||
|
||
scenarios.forEach(scenario => { | ||
it(scenario.name, () => { | ||
const sut = () => { | ||
requireTemplate(scenario.name); | ||
}; | ||
|
||
expect(sut).to.throw(); | ||
}); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to understand, in case of yarn install, why this doesn't work. The oc-template-jade module must be there if yarn installed everything correctly, if it is not we need to find out where it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the infinite-loop-loader. It should be in the node_modules.