Add a bisect button to automatically schedule bisecting A/B tasks.
[WebKit-https.git] / Websites / perf.webkit.org / unit-tests / commit-log-tests.js
index 849b036..cc2dbbf 100644 (file)
@@ -95,6 +95,26 @@ function otherOwnerCommit()
     });
 }
 
+function ownedCommit()
+{
+    return new CommitLog(11, {
+        repository: MockModels.ownedRepository,
+        revision: 'owned-commit-0',
+        ownsCommits: true,
+        time: null
+    });
+}
+
+function anotherOwnedCommit()
+{
+    return new CommitLog(11, {
+        repository: MockModels.ownedRepository,
+        revision: 'owned-commit-1',
+        ownsCommits: true,
+        time: null
+    });
+}
+
 describe('CommitLog', function () {
     MockModels.inject();
 
@@ -181,6 +201,60 @@ describe('CommitLog', function () {
         });
     });
 
+    describe('hasOrdering', () => {
+        it('should return "true" when both commits have commit orders', () => {
+            assert.ok(CommitLog.hasOrdering(osxCommit(), oldOSXCommit()));
+        });
+
+        it('should return "true" when both commits have commit time', () => {
+            assert.ok(CommitLog.hasOrdering(webkitCommit(), oldWebKitCommit()));
+        });
+
+        it('should return "false" when neither commit time nor commit order exists', () => {
+            assert.ok(!CommitLog.hasOrdering(ownedCommit(), anotherOwnedCommit()));
+        });
+
+        it('should return "false" when one commit only has commit time and another only has commit order', () => {
+            assert.ok(!CommitLog.hasOrdering(webkitCommit(), osxCommit()));
+        });
+    });
+
+    describe('hasCommitOrder', () => {
+        it('should return "true" when a commit has commit order', () => {
+            assert.ok(osxCommit().hasCommitOrder());
+        });
+
+        it('should return "false" when a commit only has commit time', () => {
+            assert.ok(!webkitCommit().hasCommitOrder());
+        });
+    });
+
+    describe('hasCommitTime', () => {
+        it('should return "true" when a commit has commit order', () => {
+            assert.ok(!osxCommit().hasCommitTime());
+        });
+
+        it('should return "false" when a commit only has commit time', () => {
+            assert.ok(webkitCommit().hasCommitTime());
+        });
+    });
+
+    describe('orderTowCommits', () => {
+        it('should order by time when both commits have time', () => {
+            const startCommit = oldWebKitCommit();
+            const endCommit = webkitCommit();
+            assert.deepEqual(CommitLog.orderTwoCommits(endCommit, startCommit), [startCommit, endCommit]);
+            assert.deepEqual(CommitLog.orderTwoCommits(startCommit, endCommit), [startCommit, endCommit]);
+        });
+
+        it('should order by commit order when both commits only have commit order', () => {
+            const startCommit = oldOSXCommit();
+            const endCommit = osxCommit();
+            assert.deepEqual(CommitLog.orderTwoCommits(endCommit, startCommit), [startCommit, endCommit]);
+            assert.deepEqual(CommitLog.orderTwoCommits(startCommit, endCommit), [startCommit, endCommit]);
+        });
+    });
+
     describe('fetchOwnedCommits', () => {
         beforeEach(() => {
             MockRemoteAPI.inject();