From 11ac41de8742c32a27096678a4dad4eec673a341 Mon Sep 17 00:00:00 2001 From: rsercano Date: Tue, 16 Apr 2019 15:23:36 +0200 Subject: [PATCH] #480 connection tests --- client/imports/test/ui/connection.tests.js | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/client/imports/test/ui/connection.tests.js b/client/imports/test/ui/connection.tests.js index 49a2e02..7f78aff 100644 --- a/client/imports/test/ui/connection.tests.js +++ b/client/imports/test/ui/connection.tests.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ import sinon from 'sinon'; -import { expect } from 'chai'; +import chai, { expect } from 'chai'; import { FlowRouter } from 'meteor/kadira:flow-router'; import { Connection } from '/client/imports/ui'; import { ErrorHandler, SessionManager, Notification, UIComponents } from '/client/imports/modules'; @@ -10,6 +10,7 @@ import $ from 'jquery'; import Helper from '/client/imports/helpers/helper'; import ConnectionHelper from '/client/imports/ui/connection/helper'; +chai.use(require('chai-jquery')); require('/client/plugins/colorpicker/js/bootstrap-colorpicker.min'); describe('Connection', () => { @@ -925,4 +926,43 @@ describe('Connection', () => { expect(ErrorHandler.showMeteorFuncError.callCount).to.equal(0); }); }); + + describe('addServerField tests', () => { + const divHtml = ''; + + beforeEach(() => { + const body = $('body'); + const cloned = $(divHtml).clone(); + cloned.attr('id', 'secondOne'); + cloned.show(); + + body.append(divHtml); + body.append(cloned); + }); + + afterEach(() => { + while (document.body.firstChild) { + document.body.removeChild(document.body.firstChild); + } + }); + + it('addServerField', () => { + // prepare + const host = 'localhost'; + const port = '123123'; + + // execute + Connection.addServerField(host, port); + + // verify + const last = $('.divHostField:last'); + expect($('.divHostField').length).to.equal(3); + expect(last.find('.txtHostName').val()).to.equal(host); + expect(last.find('.txtPort').val()).to.equal(port); + expect(last).to.have.css('display', 'block'); + }); + }); }); -- GitLab