| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2017 The LUCI Authors. All rights reserved. | 2 Copyright 2017 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <!doctype html> | 7 <!doctype html> |
| 8 <html lang="en"> | 8 <html lang="en"> |
| 9 <head> | 9 <head> |
| 10 <meta charset="utf-8"> | 10 <meta charset="utf-8"> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 assert.equal(front_page.searchResults.length, 0); | 83 assert.equal(front_page.searchResults.length, 0); |
| 84 }); | 84 }); |
| 85 | 85 |
| 86 test('checks that isLoading property is true by default', function() { | 86 test('checks that isLoading property is true by default', function() { |
| 87 assert.equal(front_page.isLoading, true); | 87 assert.equal(front_page.isLoading, true); |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 test('gets iron-ajax response', function () { | 90 test('gets iron-ajax response', function () { |
| 91 request = ajax.generateRequest(); | 91 request = ajax.generateRequest(); |
| 92 server.respond(); | 92 server.respond(); |
| 93 expect(request.response).to.be.ok; | 93 expect(request.status).to.be.equal(200); |
| 94 expect(request.response).to.be.an('object'); | 94 expect(request.response).to.be.an('object'); |
| 95 expect(request.response.event).to.be.an('object'); | 95 expect(request.response.event).to.be.an('object'); |
| 96 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically | 96 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically |
| 97 front_page._onGotConfigSets(request.response.event); | 97 front_page._onGotConfigSets(request.response.event); |
| 98 assert.equal(front_page.isLoading, false); | 98 assert.equal(front_page.isLoading, false); |
| 99 assert.equal(front_page.configSetList.length, 2); | 99 assert.equal(front_page.configSetList.length, 2); |
| 100 assert.deepEqual(front_page.configSetList, | 100 var sortedResults = front_page.configSetList.slice(); |
| 101 sortedResults.sort(function(a, b) { |
| 102 return front_page._formatName(a.config_set).localeCompare(front_page
._formatName(b.config_set)); |
| 103 }.bind(front_page)); |
| 104 assert.deepEqual(sortedResults, |
| 101 front_page.searchResults); | 105 front_page.searchResults); |
| 102 assert.equal(front_page.configSetList[0].last_import_attempt.success, | 106 assert.equal(front_page.configSetList[0].last_import_attempt.success, |
| 103 true); | 107 true); |
| 104 assert.equal(front_page.configSetList[1].last_import_attempt.success, | 108 assert.equal(front_page.configSetList[1].last_import_attempt.success, |
| 105 false); | 109 false); |
| 106 }); | 110 }); |
| 107 | 111 |
| 108 test('query does not match any results', function () { | 112 test('query does not match any results', function () { |
| 109 request = ajax.generateRequest(); | 113 request = ajax.generateRequest(); |
| 110 server.respond(); | 114 server.respond(); |
| 111 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically | 115 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically |
| 112 front_page._onGotConfigSets(request.response.event); | 116 front_page._onGotConfigSets(request.response.event); |
| 113 front_page.query = "service"; | 117 front_page.query = "service"; |
| 114 assert.notEqual(front_page.configSetList, | 118 assert.notEqual(front_page.configSetList, |
| 115 front_page.searchResults); | 119 front_page.searchResults); |
| 116 assert.equal(front_page.searchResults.length, 0); | 120 assert.equal(front_page.searchResults.length, 0); |
| 117 }); | 121 }); |
| 118 | 122 |
| 119 test('query matches all results', function () { | 123 test('query matches all results', function () { |
| 120 request = ajax.generateRequest(); | 124 request = ajax.generateRequest(); |
| 121 server.respond(); | 125 server.respond(); |
| 122 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically | 126 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically |
| 123 front_page._onGotConfigSets(request.response.event); | 127 front_page._onGotConfigSets(request.response.event); |
| 124 front_page.query = "project"; | 128 front_page.query = "project"; |
| 125 assert.deepEqual(front_page.configSetList, | 129 var sortedResults = front_page.configSetList.slice(); |
| 130 sortedResults.sort(function(a, b) { |
| 131 return front_page._formatName(a.config_set).localeCompare(front_page
._formatName(b.config_set)); |
| 132 }.bind(front_page)); |
| 133 assert.deepEqual(sortedResults, |
| 126 front_page.searchResults); | 134 front_page.searchResults); |
| 127 assert.equal(front_page.searchResults.length, 2); | 135 assert.equal(front_page.searchResults.length, 2); |
| 128 }); | 136 }); |
| 129 | 137 |
| 130 test('query matches one result', function () { | 138 test('query matches one result', function () { |
| 131 request = ajax.generateRequest(); | 139 request = ajax.generateRequest(); |
| 132 server.respond(); | 140 server.respond(); |
| 133 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically | 141 // TODO(crbug.com/740768): make the element call on-response handler a
utomatically |
| 134 front_page._onGotConfigSets(request.response.event); | 142 front_page._onGotConfigSets(request.response.event); |
| 135 front_page.query = "valid-project"; | 143 front_page.query = "invalid-project"; |
| 136 assert.notEqual(front_page.configSetList, | 144 assert.notEqual(front_page.configSetList, |
| 137 front_page.searchResults); | 145 front_page.searchResults); |
| 138 assert.equal(front_page.searchResults[0].config_set, "valid-project"); | 146 assert.equal(front_page.searchResults[0].config_set, "invalid-project"
); |
| 139 }); | 147 }); |
| 140 | |
| 141 }); | 148 }); |
| 142 | |
| 143 </script> | 149 </script> |
| 144 </body> | 150 </body> |
| 145 </html> | 151 </html> |
| OLD | NEW |