| // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| /** |
| * @fileoverview Jasmine test file for process_log.js. |
| */ |
| |
| describe('ProcessLog', function() { |
| var doc; |
| var managerDiv; |
| |
| beforeEach((function() { |
| doc = document; |
| managerDiv = doc.createElement('div'); |
| managerDiv.className = 'managers'; |
| var fileInput = document.createElement('input'); |
| fileInput.type = 'file'; |
| fileInput.id = 'file_name'; |
| managerDiv.appendChild(fileInput); |
| doc.body.appendChild(managerDiv); |
| })); |
| |
| afterEach((function() { |
| managerDiv.parentNode.removeChild(managerDiv); |
| doc = null; |
| managerDiv = null; |
| })); |
| |
| it('should properly clean up when a new file is selected', function() { |
| var checkDiv; |
| var child1 = doc.createElement('h2'); |
| managerDiv.appendChild(child1); |
| checkDiv = document.getElementsByClassName('managers'); |
| expect(checkDiv[0].childNodes.length).toBe(2); |
| |
| cleanupForNewFile(); |
| checkDiv = document.getElementsByClassName('managers'); |
| expect(checkDiv[0].hasChildNodes()).toBe(false); |
| }); |
| |
| it('should not process a log when a file is not selected', function() { |
| var readFileSpy = jasmine.createSpy('readFile'); |
| parseFile(); |
| expect(readFileSpy.calls.any()).toEqual(false); |
| }); |
| }); |