From: Patrick Nawracay Date: Mon, 15 Oct 2018 13:27:18 +0000 (+0200) Subject: mgr/dashboard: Simplify frontend test helper X-Git-Tag: v14.1.0~1083^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c98d5022b7bd83ea2f7dd514ea139b0e8b72a39e;p=ceph.git mgr/dashboard: Simplify frontend test helper Signed-off-by: Patrick Nawracay --- diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts index be0c6c333d50..e83975126aba 100644 --- a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts +++ b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts @@ -63,41 +63,31 @@ export class PermissionHelper { singleExecuting?: any; // uses 'single' if not defined multiple?: any; // uses 'empty' if not defined }) { - this.testSingleScenario( + this.testScenario( // 'multiple selections' [{}, {}], - 'multiple selections', fn, _.isUndefined(multiple) ? empty : multiple ); - this.testSingleScenario( + this.testScenario( // 'select executing item' [{ cdExecuting: 'someAction' }], - 'select executing item', fn, _.isUndefined(singleExecuting) ? single : singleExecuting ); - this.testSingleScenario([{}], 'select non-executing item', fn, single); - this.testSingleScenario([], 'no selection', fn, empty); + this.testScenario([{}], fn, single); // 'select non-executing item' + this.testScenario([], fn, empty); // 'no selection' } - private testSingleScenario( + private testScenario( selection: object[], - description: string, fn: () => any, expected: any ) { this.setSelection(selection); - this.readableExpect(description, fn, expected); + expect(fn()).toBe(expected); } setSelection(selection: object[]) { this.tableActions.selection.selected = selection; this.tableActions.selection.update(); } - - private readableExpect(task: string, fn: () => any, expected: any) { - expect({ task: task, expected: fn() }).toEqual({ - task: task, - expected: expected - }); - } }