Skip to content

Commit

Permalink
Migration: js() to addJS() tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Jun 2, 2017
1 parent f869eff commit ea5effe
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions migration/lib/transformers/8-block-in-block.js
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);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
block('a').block('b').tag()('a');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
block('b').tag()('a');
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);
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);
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ block('b')(

content()('test')
);

block('b')(
js()(true),

content()('test')
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ block('b')(

content()('test')
);

block('b')(
addJs()(true),

content()('test')
);
2 changes: 2 additions & 0 deletions migration/lib/transformers/__tests__/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ defineTest(__dirname, '8-mix-to-addmix', null, '8-mix-to-addmix-1');
defineTest(__dirname, '8-mix-to-addmix', null, '8-mix-to-addmix-2');
defineTest(__dirname, '8-js-to-addjs', null, '8-js-to-addjs-1');
defineTest(__dirname, '8-js-to-addjs', null, '8-js-to-addjs-2');
defineTest(__dirname, '8-chain-js-to-chain-addjs', null, '8-chain-js-to-chain-addjs-1');
defineTest(__dirname, '8-block-in-block', null, '8-block-in-block-chain-1');

0 comments on commit ea5effe

Please sign in to comment.