Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Tools/GardeningServer/ui/test/ct-failure-analyzer-tests.html

Issue 462453002: Sheriff-O-Matic: Transition more unit tests to mocha. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase and fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6
7 <link rel="import" href="../ct-failure-analyzer.html">
8
9 <script>
10 (function () {
11
12 var assert = chai.assert;
13
14 describe('ct-failure-analyzer', function() {
15 describe('_failureComparator', function() {
16 it('should sort failures', function() {
17 var analyzer = document.createElement('ct-failure-analyzer');
18 var resultsByBuilder = {};
19 var failure1 = new CTFailure("step1", "reason1", resultsByBuilder, 123, 12 3);
20 var failure2 = new CTFailure("step1", "reason2", resultsByBuilder, 123, 12 3);
21 var failure3 = new CTFailure("step1", "reason3", resultsByBuilder, 123, 12 3);
22 var failure4 = new CTFailure("step2", "reason1", resultsByBuilder, 123, 12 3);
23
24 var failures = [failure4, failure3, failure2, failure1];
25 var expectedFailures = [failure1, failure2, failure3, failure4];
26 assert.deepEqual(failures.sort(analyzer._failureComparator), expectedFailu res);
27 });
28 });
29
30 describe('_failureListComparator', function() {
31 it('should compare failures correctly', function() {
32 var analyzer = document.createElement('ct-failure-analyzer');
33 var revision1 = {
34 'chromium': 1,
35 'blink': 2
36 };
37 var revision2 = {
38 'chromium': 2,
39 'blink': 1
40 };
41 var revision3 = {
42 'chromium': 2,
43 'blink': 2
44 };
45 var resultsByBuilder = {};
46 var failure1 = new CTFailure("step", "reason", resultsByBuilder, revision1 , revision1);
47 var failure2 = new CTFailure("step", "reason", resultsByBuilder, revision2 , revision2);
48 var failure3 = new CTFailure("step", "reason", resultsByBuilder, revision3 , revision3);
49 var failure4 = new CTFailure("step", "reason", resultsByBuilder, null, nul l);
50
51 // Sort by last revision first.
52 assert(analyzer._failureListComparator('chromium', [failure1], [failure2]) > 0);
53 assert(analyzer._failureListComparator('chromium', [failure2], [failure1]) < 0);
54 assert(analyzer._failureListComparator('chromium', [failure1], [failure1]) == 0);
55
56 // If the tree revisions are equal, take others.
57 assert(analyzer._failureListComparator('chromium', [failure2], [failure3]) > 0);
58
59 // Prioritize the given tree.
60 assert(analyzer._failureListComparator('chromium', [failure1], [failure2]) > 0);
61 assert(analyzer._failureListComparator('blink', [failure1], [failure2]) < 0);
62
63 // Default to 'chromium'.
64 assert(analyzer._failureListComparator(undefined, [failure1], [failure2]) > 0);
65
66 // Failures without a revision go to the end.
67 assert(analyzer._failureListComparator('chromium', [failure4], [failure1]) < 0);
68 });
69 });
70 });
71
72 })()
73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698