-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration: js() to addJS() tests added
- Loading branch information
1 parent
f869eff
commit ea5effe
Showing
8 changed files
with
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var log = require('../logger'); | ||
var Transformer = require('../transformer'); | ||
var t = new Transformer(); | ||
|
||
module.exports = function(file, api, opts) { | ||
t.description = 'You can’t use more than one subpredicate block, elem, mod, elemMod. ' + | ||
'And more than one output generator like tag(), content(), etc '; | ||
|
||
t.find = function(file, j) { | ||
return j(file.source) | ||
.find(j.MemberExpression, { | ||
property: { type: 'Identifier', name: 'block' }, | ||
object: { callee: { type: 'Identifier', name: 'block' }} | ||
}) | ||
}; | ||
|
||
t.replace = function(ret, j) { | ||
return ret.replaceWith(function(p) { | ||
return j.identifier('block'); | ||
}); | ||
}; | ||
|
||
return t.run(file, api, opts); | ||
}; |
1 change: 1 addition & 0 deletions
1
migration/lib/transformers/__testfixtures__/8-block-in-block-chain-1.input.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 @@ | ||
block('a').block('b').tag()('a'); |
1 change: 1 addition & 0 deletions
1
migration/lib/transformers/__testfixtures__/8-block-in-block-chain-1.output.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 @@ | ||
block('b').tag()('a'); |
10 changes: 10 additions & 0 deletions
10
migration/lib/transformers/__testfixtures__/8-chain-js-to-chain-addjs-1.input.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,10 @@ | ||
block('test').js()(function() { | ||
// TODO: ololo | ||
var js = this.ctx.js; | ||
|
||
js = { data: 'lol' }; | ||
|
||
return js; | ||
}); | ||
|
||
block('test').js()(true); |
10 changes: 10 additions & 0 deletions
10
migration/lib/transformers/__testfixtures__/8-chain-js-to-chain-addjs-1.output.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,10 @@ | ||
block('test').addJs()(function() { | ||
// TODO: ololo | ||
var js = this.ctx.js; | ||
|
||
js = { data: 'lol' }; | ||
|
||
return js; | ||
}); | ||
|
||
block('test').addJs()(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 |
---|---|---|
|
@@ -5,3 +5,9 @@ block('b')( | |
|
||
content()('test') | ||
); | ||
|
||
block('b')( | ||
js()(true), | ||
|
||
content()('test') | ||
); |
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 |
---|---|---|
|
@@ -5,3 +5,9 @@ block('b')( | |
|
||
content()('test') | ||
); | ||
|
||
block('b')( | ||
addJs()(true), | ||
|
||
content()('test') | ||
); |
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