diff --git a/pages/component/slider/slider.test.js b/pages/component/slider/slider.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2a84b5f4057459ef385f3fb35ead920ab974377d
--- /dev/null
+++ b/pages/component/slider/slider.test.js
@@ -0,0 +1,51 @@
+const PAGE_PATH = '/pages/component/slider/slider'
+
+describe('slider', () => {
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(500)
+ })
+ // it('change', async () => {})
+ it('value', async () => {
+ const slider = await page.$('.slider-custom-color-and-size')
+
+ const sliderValue = 80
+ await page.setData({
+ sliderValue: sliderValue,
+ })
+ await page.waitFor(100)
+ expect(await slider.property('value')).toBe(sliderValue)
+ })
+ it('color', async () => {
+ const slider = await page.$('.slider-custom-color-and-size')
+ expect(await slider.property('backgroundColor')).toBe('#000000')
+ expect(await slider.property('activeColor')).toBe('#FFCC33')
+ expect(await slider.property('blockColor')).toBe('#8A6DE9')
+
+ const backgroundColor = '#008000'
+ const activeColor = '#00FF00'
+ const blockColor = '#0000A0'
+
+ await page.setData({
+ sliderBackgroundColor: backgroundColor,
+ sliderActiveColor: activeColor,
+ sliderBlockColor: blockColor,
+ })
+ await page.waitFor(100)
+ expect(await slider.property('backgroundColor')).toBe(backgroundColor)
+ expect(await slider.property('activeColor')).toBe(activeColor)
+ expect(await slider.property('blockColor')).toBe(blockColor)
+ })
+ it('block-size', async () => {
+ const slider = await page.$('.slider-custom-color-and-size')
+ expect(await slider.property('blockSize')).toBe(20)
+
+ const blockSize = 18
+ await page.setData({
+ sliderBlockSize: blockSize,
+ })
+ await page.waitFor(100)
+ expect(await slider.property('blockSize')).toBe(blockSize)
+ })
+})
\ No newline at end of file
diff --git a/pages/component/slider/slider.uvue b/pages/component/slider/slider.uvue
index a988a9e5a48799ad46f7c37e419bbc01c89f608e..3cf2e957aaaef9175e64bb0b2bb5ca0012769934 100644
--- a/pages/component/slider/slider.uvue
+++ b/pages/component/slider/slider.uvue
@@ -18,8 +18,8 @@
不同颜色和大小的滑块
-
+
@@ -28,7 +28,12 @@
export default {
data() {
return {
- title: 'slider 滑块'
+ title: 'slider 滑块',
+ sliderValue: 50,
+ sliderBlockSize: 20,
+ sliderBackgroundColor: '#000000',
+ sliderActiveColor: '#FFCC33',
+ sliderBlockColor: '#8A6DE9',
}
},
methods: {
diff --git a/pages/component/switch/switch.test.js b/pages/component/switch/switch.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..65f9cc925963be0d21658f2911b11792dfec7460
--- /dev/null
+++ b/pages/component/switch/switch.test.js
@@ -0,0 +1,52 @@
+const PAGE_PATH = '/pages/component/switch/switch'
+
+describe('switch', () => {
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(500)
+ })
+ // TODO
+ // it('click', async () => {
+ // const switch_element = await page.$('.switch-checked')
+ // const switch_element_value = await page.$('.switch-checked-value')
+ // expect(await switch_element_value.text()).toBe('true')
+
+ // await page.waitFor(200)
+
+ // await switch_element.tap()
+ // await page.waitFor(200)
+ // expect(await switch_element_value.text()).toBe('false')
+
+ // await switch_element.tap()
+ // await page.waitFor(200)
+ // expect(await switch_element_value.text()).toBe('true')
+ // })
+ it('checked', async () => {
+ const switch_element = await page.$('.switch-checked')
+
+ await page.setData({
+ checked: false,
+ })
+ await page.waitFor(100)
+ expect(await switch_element.property('checked')).toBe(false)
+
+ await page.setData({
+ checked: true,
+ })
+ await page.waitFor(100)
+ expect(await switch_element.property('checked')).toBe(true)
+ })
+ it('color', async () => {
+ const switch_element = await page.$('.switch-color')
+ expect(await switch_element.property('color')).toBe('#FFCC33')
+
+ const color = '#00ff00'
+
+ await page.setData({
+ color: color
+ })
+ await page.waitFor(100)
+ expect(await switch_element.property('color')).toBe(color)
+ })
+})
\ No newline at end of file
diff --git a/pages/component/switch/switch.uvue b/pages/component/switch/switch.uvue
index 33d29b4676cbd0780c2d3eefe8bae32102b6fb95..1bedf3a11a5bf049536c708d579d13f170d7f666 100644
--- a/pages/component/switch/switch.uvue
+++ b/pages/component/switch/switch.uvue
@@ -3,13 +3,14 @@
默认样式
-
+
+
不同颜色和尺寸的switch
-
-
+
+
推荐展示样式
@@ -30,11 +31,15 @@
export default {
data() {
return {
- title: 'switch 开关'
+ title: 'switch 开关',
+ checked: true,
+ color: '#FFCC33',
+ clickCheckedValue: true
}
},
methods: {
switch1Change: function (e : SwitchChangeEvent) {
+ this.clickCheckedValue = e.detail.value
console.log('switch1 发生 change 事件,携带值为', e.detail.value)
},
switch2Change: function (e : SwitchChangeEvent) {