From 572990b7f45bfe5a2960013b2ffa1c7872be66df Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 24 Aug 2018 15:47:26 +0000 Subject: [PATCH] tests: Add set_up() helper for input_pill tests. --- frontend_tests/node_tests/input_pill.js | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js index 0326728929..b9a6d66b0c 100644 --- a/frontend_tests/node_tests/input_pill.js +++ b/frontend_tests/node_tests/input_pill.js @@ -90,7 +90,7 @@ run_test('basics', () => { assert.deepEqual(widget.items(), [item]); }); -run_test('insert_remove', () => { +function set_up() { set_global('$', global.make_zjquery()); var items = { blue: { @@ -112,11 +112,6 @@ run_test('insert_remove', () => { var pill_input = $.create('pill_input'); - var inserted_html = []; - pill_input.before = function (elem) { - inserted_html.push(elem.html()); - }; - var create_item_from_text = function (text) { return items[text]; }; @@ -132,8 +127,27 @@ run_test('insert_remove', () => { id_seq = 0; + return { + config: config, + pill_input: pill_input, + items: items, + container: container, + }; +} + +run_test('insert_remove', () => { + const info = set_up(); + + const config = info.config; + const pill_input = info.pill_input; + const items = info.items; + const container = info.container; + + var inserted_html = []; + pill_input.before = function (elem) { + inserted_html.push(elem.html()); + }; - // FINALLY CREATE THE WIDGET!! var widget = input_pill.create(config); var created;