|
| 1 | +const {expect} = require('chai') |
| 2 | +const Page = require('../../../lib/pages/page') |
| 3 | +const Section = require('../../../lib/pages/section') |
| 4 | +const TextSetting = require('../../../lib/pages/text-setting') |
| 5 | + |
| 6 | +describe('text-setting', function () { |
| 7 | + let page = {} |
| 8 | + let section = {} |
| 9 | + |
| 10 | + beforeEach(() => { |
| 11 | + page = new Page('testPage') |
| 12 | + section = new Section(page, 'testSection') |
| 13 | + }) |
| 14 | + |
| 15 | + it('should set type to text', function () { |
| 16 | + const textSetting = new TextSetting(section, 'text').toJson() |
| 17 | + expect(textSetting.type).to.equal('TEXT') |
| 18 | + }) |
| 19 | + |
| 20 | + it('should set default description', function () { |
| 21 | + const textSetting = new TextSetting(section, 'text').toJson() |
| 22 | + expect(textSetting.description).to.equal('Tap to set') |
| 23 | + }) |
| 24 | + |
| 25 | + it('should set maxLength when specified', function () { |
| 26 | + const maxLength = 9 |
| 27 | + const textSetting = new TextSetting(section, 'text') |
| 28 | + .maxLength(maxLength) |
| 29 | + .toJson() |
| 30 | + |
| 31 | + expect(textSetting.maxLength).to.equal(maxLength) |
| 32 | + }) |
| 33 | + |
| 34 | + it('should set minLength when specified', function () { |
| 35 | + const minLength = 1 |
| 36 | + const textSetting = new TextSetting(section, 'text') |
| 37 | + .minLength(minLength) |
| 38 | + .toJson() |
| 39 | + |
| 40 | + expect(textSetting.minLength).to.equal(minLength) |
| 41 | + }) |
| 42 | + |
| 43 | + it('should set image when specified', function () { |
| 44 | + const imageUrl = 'https://test.local/image.png' |
| 45 | + const textSetting = new TextSetting(section, 'text') |
| 46 | + .image(imageUrl) |
| 47 | + .toJson() |
| 48 | + |
| 49 | + expect(textSetting.image).to.equal(imageUrl) |
| 50 | + }) |
| 51 | + |
| 52 | + it('should set postMessage when specified', function () { |
| 53 | + const postMessage = 'test' |
| 54 | + const textSetting = new TextSetting(section, 'text') |
| 55 | + .postMessage(postMessage) |
| 56 | + .toJson() |
| 57 | + |
| 58 | + expect(textSetting.postMessage).to.equal(postMessage) |
| 59 | + }) |
| 60 | +}) |
0 commit comments