Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.

Commit d0812dc

Browse files
committed
add unit test for the get tag api.
1 parent d6594a5 commit d0812dc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/unit/run-functions-spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ Authors: Nera Liu <neraliu@yahoo-inc.com>
216216

217217
});
218218

219+
describe('#getCurrentTagIndex and #getCurrentTag', function(){
220+
221+
it('should return correct tag name/index', function(){
222+
223+
[ { html: "<div class='classname' style='color:red'></div>", tag0: 'div', tag1: 'div', index: 1},
224+
{ html: "<div class='classname' style='color:red'></div> ", tag0: 'div', tag1: 'div', index: 1},
225+
{ html: "<div class='classname' style='color:red'></div><img>", tag0: 'img', tag1: 'div', index: 0},
226+
{ html: "<div class='classname' style='color:red'></div><img ", tag0: 'img', tag1: 'div', index: 0},
227+
{ html: "<div class='classname' style='color:red'></div><img></im", tag0: 'img', tag1: 'im', index: 1},
228+
{ html: "<div class='classname' style='color:red'></div><img></img ",tag0: 'img', tag1: 'img', index: 1},
229+
].forEach(function(testObj) {
230+
var p1 = new Parser(config);
231+
p1.contextualize(testObj.html);
232+
assert.equal(p1.getCurrentTag(0), testObj.tag0);
233+
assert.equal(p1.getCurrentTag(1), testObj.tag1);
234+
assert.equal(p1.getCurrentTagIndex(), testObj.index);
235+
});
236+
});
237+
});
238+
219239
describe('#Constructor', function(){
220240

221241
it('should support multiple instances', function(){

0 commit comments

Comments
 (0)