-
Notifications
You must be signed in to change notification settings - Fork 8
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
add support for replacing with string #10
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 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 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 |
---|---|---|
|
@@ -41,12 +41,18 @@ module.exports = function(environment) { | |
file: '_emberIndexContent/file3.txt', | ||
includeInOutput: true, | ||
includeInIndexHtml: false | ||
}, | ||
{ | ||
key: '5', | ||
string: 'My App Title', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
}, { | ||
key: 'coloring-script', | ||
file: '_emberIndexContent/coloring-script.txt', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
}], | ||
},], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove comma here |
||
output: 'index2.html' | ||
} | ||
}; | ||
|
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 |
---|---|---|
|
@@ -21,22 +21,22 @@ function findEmberIndex(app) { | |
} | ||
} | ||
|
||
describe('Addon', function() { | ||
describe('Addon', function () { | ||
var builder; | ||
|
||
this.timeout(15000); | ||
|
||
afterEach(function() { | ||
afterEach(function () { | ||
if (builder) { | ||
return builder.cleanup(); | ||
} | ||
}); | ||
|
||
describe('#contentFor', function() { | ||
describe('#contentFor', function () { | ||
var contentFor; | ||
var addon; | ||
|
||
it('returns proper content for a single "content-for" tag', function() { | ||
it('returns proper content for a single "content-for" tag, replacing a file', function () { | ||
addon = getEmberIndexAddon({ | ||
'ember-index': { | ||
content: { | ||
|
@@ -51,7 +51,22 @@ describe('Addon', function() { | |
expect(contentFor).to.be.equal(addon._startMarkerPrefix + '-default' + '<!-- content from file1 -->' + addon._endMarkerPrefix + '-default'); | ||
}); | ||
|
||
it('returns proper content for multiple "content-for" tags', function() { | ||
it('returns proper content for a single "content-for" tag, replacing a string', function () { | ||
addon = getEmberIndexAddon({ | ||
'ember-index': { | ||
content: { | ||
string: '<!-- content from string -->', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
} | ||
} | ||
}); | ||
contentFor = addon.contentFor('ember-index'); | ||
|
||
expect(contentFor).to.be.equal(addon._startMarkerPrefix + '-default' + '<!-- content from string -->' + addon._endMarkerPrefix + '-default'); | ||
}); | ||
|
||
it('returns proper content for multiple "content-for" tags', function () { | ||
addon = getEmberIndexAddon({ | ||
'ember-index': { | ||
content: [{ | ||
|
@@ -69,6 +84,12 @@ describe('Addon', function() { | |
file: '_emberIndexContent/file3.txt', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
}, | ||
{ | ||
key: '4', | ||
string: '<!-- content from string -->', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
}] | ||
} | ||
}); | ||
|
@@ -84,15 +105,19 @@ describe('Addon', function() { | |
contentFor = addon.contentFor('ember-index-3'); | ||
|
||
expect(contentFor).to.be.equal(addon._startMarkerPrefix + '-3' + '<!-- content from file3 -->' + addon._endMarkerPrefix + '-3'); | ||
|
||
contentFor = addon.contentFor('ember-index-4'); | ||
|
||
expect(contentFor).to.be.equal(addon._startMarkerPrefix + '-3' + '<!-- content from string -->' + addon._endMarkerPrefix + '-3'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have a typo( expect(contentFor).to.be.equal(addon._startMarkerPrefix + '-4' + '<!-- content from string -->' + addon._endMarkerPrefix + '-4'); |
||
}); | ||
}); | ||
|
||
|
||
describe('#appTree', function() { | ||
describe('#appTree', function () { | ||
var appTree; | ||
var dummyVar; | ||
|
||
it('creates a simple clone of index.html', function() { | ||
it('creates a simple clone of index.html', function () { | ||
appTree = new EmberAddon({ | ||
'ember-index': { | ||
output: 'index.jsp' | ||
|
@@ -101,7 +126,7 @@ describe('Addon', function() { | |
|
||
builder = new broccoli.Builder(appTree); | ||
return builder.build() | ||
.then(function(results) { | ||
.then(function (results) { | ||
var indexHtml, indexJsp, | ||
outputPath = results.directory, | ||
indexJspPath = path.join(outputPath, 'index.jsp'), | ||
|
@@ -118,7 +143,7 @@ describe('Addon', function() { | |
}); | ||
}); | ||
|
||
it('ember-index is disabled when enabled=false', function() { | ||
it('ember-index is disabled when enabled=false', function () { | ||
appTree = new EmberAddon({ | ||
'ember-index': { | ||
output: 'index.jsp', | ||
|
@@ -128,15 +153,15 @@ describe('Addon', function() { | |
|
||
builder = new broccoli.Builder(appTree); | ||
return builder.build() | ||
.then(function(results) { | ||
.then(function (results) { | ||
var outputPath = results.directory, | ||
indexJspPath = path.join(outputPath, 'index.jsp'); | ||
|
||
expect(fs.existsSync(indexJspPath)).to.be.equal(false); | ||
}); | ||
}); | ||
|
||
it('Insert content according to "includeInOutput" & "includeInIndexHtml"', function() { | ||
it('Insert content according to "includeInOutput" & "includeInIndexHtml"', function () { | ||
appTree = new EmberAddon({ | ||
'ember-index': { | ||
output: 'index.jsp', | ||
|
@@ -155,28 +180,35 @@ describe('Addon', function() { | |
file: '_emberIndexContent/file3.txt', | ||
includeInOutput: false, | ||
includeInIndexHtml: true | ||
},{ | ||
}, { | ||
key: '4', | ||
file: '_emberIndexContent/file4.txt', | ||
includeInOutput: true, | ||
includeInIndexHtml: true | ||
}, | ||
{ | ||
key: '5', | ||
string: '<!-- content from string -->', | ||
includeInOutput: true, | ||
includeInIndexHtml: true | ||
}] | ||
} | ||
}).toTree(); | ||
|
||
builder = new broccoli.Builder(appTree); | ||
return builder.build() | ||
.then(function(results) { | ||
.then(function (results) { | ||
var indexHtml, indexJsp, | ||
outputPath = results.directory, | ||
indexJspPath = path.join(outputPath, 'index.jsp'), | ||
indexHtmlPath = path.join(outputPath, 'index.html'), | ||
file1RegExp = /<!-- content from file1 -->/, | ||
file2RegExp = /<!-- content from file2 -->/, | ||
file3RegExp = /<!-- content from file3 -->/, | ||
file4RegExp = /<!-- content from file4 -->/; | ||
file4RegExp = /<!-- content from file4 -->/, | ||
stringRegExp = /<!-- content from string -->/; | ||
|
||
expect(fs.existsSync(indexJspPath)).to.be.equal(true); | ||
expect(fs.existsSync(indexJspPath)).to.be.equal(true); | ||
|
||
indexJsp = fs.readFileSync(indexJspPath).toString(); | ||
indexHtml = fs.readFileSync(indexHtmlPath).toString(); | ||
|
@@ -197,38 +229,39 @@ describe('Addon', function() { | |
|
||
expect(file4RegExp.test(indexHtml)).to.be.equal(true); | ||
|
||
expect(stringRegExp.test(indexJsp)).to.be.equal(true); | ||
|
||
expect(stringRegExp.test(indexHtml)).to.be.equal(true); | ||
}); | ||
}); | ||
|
||
it('Use the destDir option correctly.', function() { | ||
appTree = new EmberAddon({ | ||
'ember-index': { | ||
destDir: 'export', | ||
output: 'index.jsp', | ||
content: [{ | ||
key: '1', | ||
file: '_emberIndexContent/file1.txt', | ||
includeInOutput: false, | ||
includeInIndexHtml: false | ||
}, { | ||
key: '2', | ||
file: '_emberIndexContent/file2.txt', | ||
includeInOutput: true, | ||
includeInIndexHtml: false | ||
}] | ||
} | ||
}).toTree(); | ||
|
||
builder = new broccoli.Builder(appTree); | ||
return builder.build() | ||
.then(function(results) { | ||
var outputPath = results.directory; | ||
var indexJspPath = path.join(outputPath, 'export/index.jsp'); | ||
|
||
expect(fs.existsSync(indexJspPath)).to.be.equal(true); | ||
it('Use the destDir option correctly.', function () { | ||
appTree = new EmberAddon({ | ||
'ember-index': { | ||
destDir: 'export', | ||
output: 'index.jsp', | ||
content: [{ | ||
key: '1', | ||
file: '_emberIndexContent/file1.txt', | ||
includeInOutput: false, | ||
includeInIndexHtml: false | ||
}, { | ||
key: '2', | ||
file: '_emberIndexContent/file2.txt', | ||
includeInOutput: true, | ||
includeInIndexHtml: false | ||
}] | ||
} | ||
}).toTree(); | ||
|
||
builder = new broccoli.Builder(appTree); | ||
return builder.build() | ||
.then(function (results) { | ||
var outputPath = results.directory; | ||
var indexJspPath = path.join(outputPath, 'export/index.jsp'); | ||
|
||
}); | ||
expect(fs.existsSync(indexJspPath)).to.be.equal(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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.
You are missing the markers here. change line to:
This causes the following failure: https://travis-ci.org/ramybenaroya/ember-index/jobs/345734590#L986