-
-
Notifications
You must be signed in to change notification settings - Fork 144
Adding tests for docs-page blueprint #351
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
Merged
samselikoff
merged 2 commits into
ember-learn:master
from
scalvert:docs-page-blueprint-tests
Apr 8, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
{{docs-header}} | ||
|
||
{{#docs-viewer as |viewer|}} | ||
{{#viewer.nav as |nav|}} | ||
{{nav.item 'Introduction' 'docs.index'}} | ||
{{nav.item 'Usage' 'docs.usage'}} | ||
|
||
{{#nav.subnav as |nav|}} | ||
{{nav.item 'Subitem' 'docs.items.subitem'}} | ||
{{/nav.subnav}} | ||
{{/viewer.nav}} | ||
|
||
{{#viewer.main}} | ||
{{outlet}} | ||
{{/viewer.main}} | ||
{{/docs-viewer}} |
This file contains hidden or 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,12 @@ | ||
{{docs-header}} | ||
|
||
{{#docs-viewer as |viewer|}} | ||
{{#viewer.nav as |nav|}} | ||
{{nav.item 'Introduction' 'docs.index'}} | ||
{{nav.item 'Usage' 'docs.usage'}} | ||
{{/viewer.nav}} | ||
|
||
{{#viewer.main}} | ||
{{outlet}} | ||
{{/viewer.main}} | ||
{{/docs-viewer}} |
This file contains hidden or 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,168 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers'); | ||
|
||
let setupTestHooks = blueprintHelpers.setupTestHooks; | ||
let emberNew = blueprintHelpers.emberNew; | ||
let emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; | ||
|
||
const expect = require('ember-cli-blueprint-test-helpers/chai').expect; | ||
const file = require('ember-cli-blueprint-test-helpers/chai').file; | ||
|
||
describe('Blueprints | non-pods docs page test', function() { | ||
setupTestHooks(this); | ||
|
||
it('it generates a docs page and updates router with no docs.hbs present', function() { | ||
return emberNew({ target: 'addon' }).then(() => { | ||
return emberGenerateDestroy(['docs-page', 'foo-bar'], _file => { | ||
expect(_file('tests/dummy/app/templates/docs/foo-bar.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect(file('tests/dummy/app/templates/docs.hbs')).to.not.exist; | ||
}); | ||
}); | ||
}); | ||
|
||
it('it generates a docs page, updates router, and adds nav item to docs.hbs', function() { | ||
return emberNew({ target: 'addon' }) | ||
.then(() => | ||
copyFixtureFile( | ||
getFixturePath('docs.hbs'), | ||
'tests/dummy/app/templates/docs.hbs' | ||
) | ||
) | ||
.then(() => { | ||
return emberGenerateDestroy(['docs-page', 'foo-bar'], _file => { | ||
expect(_file('tests/dummy/app/templates/docs/foo-bar.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect( | ||
file('tests/dummy/app/templates/docs.hbs') | ||
).to.exist.to.contain('{{nav.item "Foo bar" "docs.foo-bar"}}'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('it generates a docs page, updates router, and adds nav item to docs.hbs when subnav present', function() { | ||
return emberNew({ target: 'addon' }) | ||
.then(() => | ||
copyFixtureFile( | ||
getFixturePath('docs-subnav.hbs'), | ||
'tests/dummy/app/templates/docs.hbs' | ||
) | ||
) | ||
.then(() => { | ||
return emberGenerateDestroy(['docs-page', 'foo-bar'], _file => { | ||
expect(_file('tests/dummy/app/templates/docs/foo-bar.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect( | ||
file('tests/dummy/app/templates/docs.hbs') | ||
).to.exist.to.contain('{{nav.item "Foo bar" "docs.foo-bar"}}'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Blueprints | pods docs page test', function() { | ||
setupTestHooks(this); | ||
|
||
it('it generates a docs page and updates router with no docs.hbs present', function() { | ||
return emberNew({ target: 'addon', pod: true }).then(() => { | ||
return emberGenerateDestroy(['docs-page', 'foo-bar', '--pod'], _file => { | ||
expect(_file('tests/dummy/app/pods/docs/foo-bar/template.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect(file('tests/dummy/app/pods/docs/template.hbs')).to.not.exist; | ||
}); | ||
}); | ||
}); | ||
|
||
it('it generates a docs page, updates router, and adds nav item to docs.hbs', function() { | ||
return emberNew({ target: 'addon', pod: true }) | ||
.then(() => | ||
copyFixtureFile( | ||
getFixturePath('docs.hbs'), | ||
'tests/dummy/app/pods/docs/template.hbs' | ||
) | ||
) | ||
.then(() => { | ||
return emberGenerateDestroy( | ||
['docs-page', 'foo-bar', '--pod'], | ||
_file => { | ||
expect(_file('tests/dummy/app/pods/docs/foo-bar/template.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect( | ||
file('tests/dummy/app/pods/docs/template.hbs') | ||
).to.exist.to.contain('{{nav.item "Foo bar" "docs.foo-bar"}}'); | ||
} | ||
); | ||
}); | ||
}); | ||
|
||
it('it generates a docs page, updates router, and adds nav item to docs.hbs when subnav present', function() { | ||
return emberNew({ target: 'addon', pod: true }) | ||
.then(() => | ||
copyFixtureFile( | ||
getFixturePath('docs-subnav.hbs'), | ||
'tests/dummy/app/pods/docs/template.hbs' | ||
) | ||
) | ||
.then(() => { | ||
return emberGenerateDestroy( | ||
['docs-page', 'foo-bar', '--pod'], | ||
_file => { | ||
expect(_file('tests/dummy/app/pods/docs/foo-bar/template.md')) | ||
.to.exist.to.contain('# Foo bar') | ||
.to.contain('Foo bar content'); | ||
|
||
expect(file('tests/dummy/app/router.js')).to.contain( | ||
"this.route('foo-bar');" | ||
); | ||
|
||
expect( | ||
file('tests/dummy/app/pods/docs/template.hbs') | ||
).to.exist.to.contain('{{nav.item "Foo bar" "docs.foo-bar"}}'); | ||
} | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
function copyFixtureFile(src, dest) { | ||
return fs.copy(src, path.join(process.cwd(), dest)); | ||
} | ||
|
||
function getFixturePath(fixtureRelativePath) { | ||
const fixturesPath = path.join(__dirname, '../..', 'fixtures', 'blueprints'); | ||
|
||
return path.join(fixturesPath, fixtureRelativePath); | ||
} |
Oops, something went wrong.
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.
Found this wee bug while I was writing tests. I guess I missed it with my manual testing (I'm old and senile...)