Skip to content

Commit

Permalink
Test: position with appendContent()/prependContent()
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Dec 10, 2016
1 parent eaa2728 commit b32094e
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/bemcontext-position-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,53 @@ describe('BEMContext this.position', function() {
'<div class="b b_first_yes"></div><div class="b"></div>' +
'<div class="b b_last_yes"></div>');
});


it('should calc position with appendContent()', function() {
test(function() {
block('a').appendContent()({ block: 'b', mix: 'added' });

block('b')(
match(function(self) { return self.isFirst(); })
.addMods()({ first: 'yes' }),

match(function(self) { return self.isLast(); })
.addMods()({ last: 'yes' }),

cls()(function() {
return 'p_' + this.position;
})
);
},
{ block: 'a', content: [ { block: 'b' }, { block: 'b' } ] },
'<div class="a">' +
'<div class="b b_first_yes p_1"></div>' +
'<div class="b p_2"></div>' +
'<div class="b b_last_yes added p_3"></div>' +
'</div>');
});

it('should calc position with prependContent()', function() {
test(function() {
block('a').prependContent()({ block: 'b', mix: 'added' });

block('b')(
match(function(self) { return self.isFirst(); })
.addMods()({ first: 'yes' }),

match(function(self) { return self.isLast(); })
.addMods()({ last: 'yes' }),

cls()(function() {
return 'p_' + this.position;
})
);
},
{ block: 'a', content: [ { block: 'b' }, { block: 'b' } ] },
'<div class="a">' +
'<div class="b b_first_yes added p_1"></div>' +
'<div class="b p_2"></div>' +
'<div class="b b_last_yes p_3"></div>' +
'</div>');
});
});

0 comments on commit b32094e

Please sign in to comment.