testCommonality: function(test) {
			var comp = new Comparator(this.diffArchiveA, this.diffArchiveB),
				differences = comp.calculateDifferences();
			test.strictEqual(differences.common[differences.common.length - 1], "pad 4",
				"Common history should end with padding");
			test.done();
		},
		testDifferencesCount: function(test) {
			var comp = new Comparator(this.diffArchiveA, this.diffArchiveB),
				differences = comp.calculateDifferences();
			// expected lengths are +1 because of the common commands in the base array (comment)
			test.strictEqual(differences.original.length, 4 + 1, "Archive A should have 4 different commands");
			test.strictEqual(differences.secondary.length, 5 + 1, "Archive B should have 5 different commands");
			test.done();
		}
Пример #3
0
			.then(function(stagedArchive) {
				var comparator = new Comparator(mainArchive, stagedArchive),
					differences = comparator.calculateDifferences();
				var newHistoryMain = stripDestructiveCommands(differences.original),
					newHistoryStaged = stripDestructiveCommands(differences.secondary),
					base = differences.common;
				var newArchive = new Archive();
				newArchive._getWestley().clear();
				base.concat(newHistoryStaged).concat(newHistoryMain).forEach(function(command) {
					newArchive._getWestley().execute(command);
				});
				workspace.setArchive(newArchive);
				return newArchive;
			});
Пример #4
0
			.then(function(stagedArchive) {
				var comparator = new Comparator(mainArchive, stagedArchive);
				return comparator.archivesDiffer();
			});
		testSame: function(test) {
			var comp = new Comparator(this.archiveA, this.archiveC);
			test.ok(comp.archivesDiffer() === false, "Archives should be the same");
			test.done();
		}
		testDifferent: function(test) {
			var comp = new Comparator(this.archiveA, this.archiveB);
			test.ok(comp.archivesDiffer() === true, "Archives should differ");
			test.done();
		},