Update match specification
Change-Id: Ifa4f5069d4ccefef6bc453f5aa3e943d13e8a163
diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index 80f1de8..2d1b49f 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -341,7 +341,7 @@
it('should fail to load a table async', function (done) {
expect(info).toBeTruthy();
- info.getTable([], function (tablen) {
+ info.getTableData([], function (tablen) {
table1 = tablen;
done();
});
@@ -355,7 +355,7 @@
it('should load a working table async', function(done) {
expect(info).toBeTruthy();
- info.getTable(undefined, function (tablem) {
+ info.getTableData(undefined, function (tablem) {
table2 = tablem;
done();
});
@@ -401,28 +401,30 @@
expect(matchElement.children[0].children[1]).toBe(undefined);
var info = matchClass.create(matchElement).info();
- info.toggle();
+ info.showTable();
// Match
expect(matchElement.children[0].tagName).toEqual('DIV');
// snippet
expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
+
expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
+
expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
// reference
- expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
- expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
+ expect(matchElement.lastChild.classList.contains('ref')).toBeTruthy();
+ expect(matchElement.lastChild.firstChild.nodeValue).toEqual('me');
// now
- var infotable = matchElement.children[2];
+ var infotable = matchElement.children[1];
expect(infotable.tagName).toEqual('DIV');
expect(infotable.classList.contains('matchinfo')).toBeTruthy();
expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
- expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
+ // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
});
@@ -430,7 +432,7 @@
it('should parse into a tree (async) 1', function (done) {
var info = matchClass.create(match).info();
expect(info).toBeTruthy();
- info.getTree(undefined, undefined, "spans", function (treem) {
+ info.getTreeData(undefined, undefined, "spans", function (treem) {
tree = treem;
done();
});
@@ -444,13 +446,14 @@
var matchElement, info;
+
// var info, matchElement;
it('should parse into a tree view', function () {
matchElement = matchElementFactory();
expect(matchElement.tagName).toEqual('LI');
info = matchClass.create(matchElement).info();
- info.toggle();
+ info.showTable();
// Match
expect(matchElement.children[0].tagName).toEqual('DIV');
@@ -461,21 +464,21 @@
expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
// reference
- expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
- expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
+ expect(matchElement.lastChild.classList.contains('ref')).toBeTruthy();
+ expect(matchElement.lastChild.firstChild.nodeValue).toEqual('me');
// now
- var infotable = matchElement.children[2];
+ var infotable = matchElement.children[1];
expect(infotable.tagName).toEqual('DIV');
expect(infotable.classList.contains('matchinfo')).toBeTruthy();
expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
- expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
+ // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
});
it('should add a tree view async 1', function (done) {
expect(info).toBeTruthy();
- info.addTree('mate', 'beebop', "spans", function () {
+ info.showTree('mate', 'beebop', "spans", function () {
done();
});
});
@@ -483,7 +486,8 @@
it('should add a tree view async 2', function () {
// With added tree
- var infotable = matchElement.children[2];
+ var infotable = matchElement.children[1];
+
expect(infotable.tagName).toEqual('DIV');
expect(infotable.classList.contains('matchinfo')).toBeTruthy();
expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
@@ -511,15 +515,15 @@
it('should be retrieved async', function (done) {
var info = matchClass.create(match).info();
expect(info).toBeTruthy();
- info.getTable(undefined, function (x) {
+ info.getTableData(undefined, function (x) {
table = x;
done();
});
});
it('should be rendered async', function () {
- var e = table.element();
-
+
+ var e = table.element().firstChild;
expect(e.nodeName).toBe('TABLE');
expect(e.children[0].nodeName).toBe('THEAD');
var tr = e.children[0].children[0];
@@ -569,7 +573,7 @@
it('should be rendered async 1', function (done) {
var info = matchClass.create(match).info();
expect(info).toBeTruthy();
- info.getTree(undefined, undefined, "spans", function (y) {
+ info.getTreeData(undefined, undefined, "spans", function (y) {
tree = y;
done();
});
@@ -637,7 +641,7 @@
var matchTreeItem = require('match/treeitem');
it('should be initializable', function () {
- var menu = matchTreeMenu.create(undefined, [
+ var menu = matchTreeMenu.create([
['cnx/c', 'cnx', 'c'],
['xip/c', 'xip', 'c']
]);
diff --git a/dev/js/src/match/info.js b/dev/js/src/match/info.js
index 4d8ea9d..a54c8a0 100644
--- a/dev/js/src/match/info.js
+++ b/dev/js/src/match/info.js
@@ -325,9 +325,6 @@
if (table !== null) {
matchtable.appendChild(table.element());
};
-
- // Load data
- matchtable.classList.remove('loading');
});
// Add button
diff --git a/dev/js/src/match/table.js b/dev/js/src/match/table.js
index 7aec5ad..4f8abcc 100644
--- a/dev/js/src/match/table.js
+++ b/dev/js/src/match/table.js
@@ -186,7 +186,8 @@
// There are multiple values to add
c.classList.add('matchkeyvalues');
for (var n = 0; n < value.length; n++) {
- var e = c.addE('div').addT(value[n]);
+ var e = c.addE('div');
+ e.addT(value[n]);
var anno = ah.getDesc(key, value[n]);