Skip to content

Commit 79983de

Browse files
authored
test(text-setting): add initial coverage (#180)
1 parent ada869d commit 79983de

10 files changed

+70
-11
lines changed

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@
103103
},
104104
"overrides": [
105105
{
106-
"files": "examples/**/*.js",
106+
"files": "test/**",
107107
"rules": {
108-
"import/no-unresolved": 0
108+
"prefer-arrow-callback": 0
109109
}
110110
}
111+
],
112+
"envs": [
113+
"mocha"
111114
]
112115
},
113116
"snyk": false
114-
}
117+
}

test/unit/pages/boolean-setting-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-undef: "off" */
21
const {expect} = require('chai')
32
const Page = require('../../../lib/pages/page')
43
const Section = require('../../../lib/pages/section')

test/unit/pages/device-setting-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-undef: "off" */
21
const {expect} = require('chai')
32
const Page = require('../../../lib/pages/page')
43
const Section = require('../../../lib/pages/section')

test/unit/pages/enum-setting-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-undef: "off" */
21
const path = require('path')
32
const i18n = require('i18n')
43
const {expect} = require('chai')

test/unit/pages/section-setting-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-undef: "off" */
21
const {expect} = require('chai')
32
const Page = require('../../../lib/pages/page')
43
const Section = require('../../../lib/pages/section')
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
})

test/unit/util/authorizer-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef, no-unused-expressions */
1+
/* eslint-disable no-unused-expressions */
22
const fs = require('fs')
33
const path = require('path')
44
const nock = require('nock')

test/unit/util/configuration-error-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef, no-unused-expressions */
1+
/* eslint-disable no-unused-expressions */
22
const {expect} = require('chai')
33
const ConfigurationError = require('../../../lib/util/configuration-error')
44

test/unit/util/endpoint-context-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef, no-unused-expressions */
1+
/* eslint-disable no-unused-expressions */
22
const chai = require('chai')
33
const EndpointContext = require('../../../lib/util/smart-app-context')
44
const SmartApp = require('../../../lib/smart-app')

test/unit/util/log-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-undef, no-unused-expressions */
1+
/* eslint-disable no-unused-expressions */
22
const sinon = require('sinon')
33
const {expect} = require('chai')
44
const Log = require('../../../lib/util/log')

0 commit comments

Comments
 (0)