Created
June 27, 2013 14:15
-
-
Save veer66/5876765 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
describe('StreeCorrCreator', function() { | |
var streeCorrCreator; | |
beforeEach(function() { | |
module('annotedw'); | |
inject(function($injector) { | |
streeCorrCreator = $injector.get('StreeCorrCreator'); | |
}); | |
}); | |
it("should convert unit stree", function() { | |
var snodeCorr = [{source: [{s:0,e:1}], | |
target: [{s:0,e:1}]}]; | |
var source_tree = {text: "A", snode: [{s:0,e:1}], stree:[{s:0,e:1}], children: []}; | |
var target_tree = {text: "B", snode: [{s:0,e:1}], stree:[{s:0,e:1}], children: []}; | |
var ssstc = {source: {string: "A", tree: source_tree}, | |
target: {string: "B", tree: target_tree}, | |
alignment: {snode: snodeCorr, stree: null}}; | |
streeCorrCreator.create(ssstc); | |
expect(ssstc.alignment.stree).toEqual([{source: [{s:0, e:1}], target: [{s:0, e:1}]}]); | |
}); | |
it("should convert unit stree alter", function() { | |
var snodeCorr = [{source: [{s:0,e:3}], | |
target: [{s:0,e:4}]}]; | |
var source_tree = {text: "ABC", snode: [{s:0,e:3}], stree:[{s:0,e:3}], children: []}; | |
var target_tree = {text: "1234", snode: [{s:0,e:4}], stree:[{s:0,e:4}], children: []}; | |
var ssstc = {source: {string: "ABC", tree: source_tree}, | |
target: {string: "1234", target: target_tree}, | |
alignment: {snode: snodeCorr, stree: null}}; | |
streeCorrCreator.create(ssstc); | |
expect(ssstc.alignment.stree).toEqual([{source: [{s:0, e:3}], target: [{s:0, e:4}]}]); | |
}); | |
it("should convert empty snode", function() { | |
var snodeCorr = []; | |
var source_tree = {text: "A", snode: [{s:0,e:1}], stree:[{s:0,e:1}], children: []}; | |
var target_tree = {text: "B", snode: [{s:0,e:1}], stree:[{s:0,e:1}], children: []}; | |
var ssstc = {source: {string: "A", tree: source_tree}, | |
target: {string: "B", tree: target_tree}, | |
alignment: {snode: snodeCorr, stree: null}}; | |
streeCorrCreator.create(ssstc); | |
expect(ssstc.alignment.stree).toEqual([]); | |
}); | |
it("should convert 2 level stree", function() { | |
var snodeCorr = [{source: [{s:0,e:1}], target: [{s:0,e:2}]}, | |
{source: [{s:1,e:2}], target: [{s:2,e:4}]} | |
]; | |
var source_tree = {text: "A", snode: [{s:0,e:1}], stree:[{s:0,e:3}], | |
children: [ | |
{text: "BC", snode: [{s:1,e:2}], stree:[{s:1,e:2}], children: []} | |
]}; | |
var target_tree = {text: "12", snode: [{s:0,e:2}], stree:[{s:0,e:4}], children: [ | |
{text: "34", snode: [{s:2,e:4}], stree:[{s:2,e:4}], children: []} | |
]}; | |
var ssstc = {source: {string: "ABC", tree: source_tree}, | |
target: {string: "1234", target: target_tree}, | |
alignment: {snode: snodeCorr, stree: null}}; | |
streeCorrCreator.create(ssstc); | |
expect(ssstc.alignment.stree).toEqual([{source: [{s:0, e:3}], target: [{s:0, e:4}]}, | |
{source: [{s:1, e:2}], target: [{s:2, e:4}]} | |
]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment