Commit db450183 authored by François Degros's avatar François Degros Committed by Commit Bot

[Files app] Added a unit test

Change-Id: I3e22e420bd7281dae51cbc7432712a60d6b608ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626057
Commit-Queue: François Degros <fdegros@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Auto-Submit: François Degros <fdegros@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662517}
parent 1d548a44
......@@ -2,6 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Asserts that promise gets rejected.
* @param {Promise} promise
*/
async function assertRejected(promise) {
let triggeredError = false;
try {
await promise;
} catch (e) {
triggeredError = true;
}
if (!triggeredError) {
throw new Error('Assertion Failed: Expected promise to be rejected');
}
}
/**
* Invokes a callback function depending on the result of promise.
*
......
......@@ -425,3 +425,11 @@ function testDriveMountedDuringInitialization(callback) {
reportPromise(test(), callback);
}
function testErrorPropagatedDuringInitialization(done) {
chrome.fileManagerPrivate.getVolumeMetadataList = () => {
throw new Error('Dummy error for test purpose');
};
reportPromise(assertRejected(volumeManagerFactory.getInstance()), done);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment