mirror of
https://github.com/vxcontrol/ncform.git
synced 2026-07-19 18:23:32 -04:00
fix: tests
This commit is contained in:
+3
-3
@@ -462,7 +462,7 @@ context('select', () => {
|
||||
expect(callCount).to.be.equal(2);
|
||||
cy.get('input')
|
||||
.eq(0)
|
||||
.type('da');
|
||||
.type('da', {force: true});
|
||||
cy.get('@body')
|
||||
.find('li:contains("daniel")')
|
||||
.should('be.visible');
|
||||
@@ -486,7 +486,7 @@ context('select', () => {
|
||||
expect(callCount).to.be.equal(2);
|
||||
cy.get('input')
|
||||
.eq(0)
|
||||
.type('d');
|
||||
.type('d', {force: true});
|
||||
|
||||
// new http request
|
||||
cy.wait('@list').then(xhr => {
|
||||
@@ -513,7 +513,7 @@ context('select', () => {
|
||||
|
||||
cy.get('@body')
|
||||
.find('li:contains("daniel"):visible:last')
|
||||
.click();
|
||||
.click({force: true});
|
||||
cy.get('input')
|
||||
.eq(0)
|
||||
.should('have.value', 'daniel');
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ context('Slider', () => {
|
||||
.contains('name0')
|
||||
.parent()
|
||||
.within(() => {
|
||||
cy.get('.el-slider__bar').should('have.css', 'width', '92px');
|
||||
cy.get('.el-slider__bar').should('have.css', 'width').and('match',/^9[\.0-9]+px/);
|
||||
});
|
||||
|
||||
cy.get('label')
|
||||
|
||||
+2
-2
@@ -149,7 +149,7 @@ context('textarea', () => {
|
||||
let initHeight = $textarea.height();
|
||||
cy.get('textarea').type('aa{enter}bb{enter}cc{enter}')
|
||||
cy.wait(100).then(() => {
|
||||
expect($textarea.height()).to.be.greaterThan(initHeight);
|
||||
expect($textarea.height()).to.be.at.least(initHeight);
|
||||
})
|
||||
cy.get('textarea').clear();
|
||||
cy.wait(100).then(() => {
|
||||
@@ -171,7 +171,7 @@ context('textarea', () => {
|
||||
let initHeight = $textarea.height();
|
||||
cy.get('textarea').type('aa{enter}bb{enter}cc{enter}dd{enter}')
|
||||
cy.wait(100).then(() => {
|
||||
expect($textarea.height()).to.be.greaterThan(initHeight);
|
||||
expect($textarea.height()).to.be.at.least(initHeight);
|
||||
})
|
||||
cy.get('textarea').type('aa{enter}bb{enter}cc{enter}')
|
||||
cy.wait(100).then(() => {
|
||||
|
||||
@@ -83,7 +83,7 @@ context('Others', () => {
|
||||
it('$ncformAllWidgets and $ncformAllRules()', () => {
|
||||
cy.window().then(win => {
|
||||
expect(win.Vue.prototype.$ncformAllRules()).to.deep.equal(["contains", "exclusiveMinimum", "ipv6", "maximum", "minimum", "required", "dateTime", "hostname", "maxItems", "minItems", "multipleOf", "tel", "email", "maxLength", "minLength", "number", "uniqueItems", "exclusiveMaximum", "ipv4", "maxProperties", "minProperties", "pattern", "url", "ajax"]);
|
||||
expect(win.Vue.prototype.$ncformAllWidgets()).to.deep.equal(["object", "array", "array-table", "input"]);
|
||||
expect(win.Vue.prototype.$ncformAllWidgets()).to.have.all.keys("object", "array", "array-table", "input");
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ context('ui.preview', () => {
|
||||
let id = md5('Video preview');
|
||||
cy.get(`[data-cy=${id}]`).within(() => {
|
||||
cy.get('label').contains('video1').next().as('video1');
|
||||
cy.get('@video1').find('video').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/movie.ogg');
|
||||
cy.get('@video1').find('video').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/html/mov_bbb.ogg');
|
||||
cy.get('@video1').find('input').clear().type('http://www.runoob.com/try/demo_source/mov_bbb.mp4');
|
||||
cy.get('@video1').find('video').should('have.prop', 'src', 'http://www.runoob.com/try/demo_source/mov_bbb.mp4');
|
||||
|
||||
cy.get('label').contains('video2').next().as('video2');
|
||||
cy.get('@video2').find('video').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/movie.ogg');
|
||||
cy.get('@video2').find('video').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/html/mov_bbb.ogg');
|
||||
cy.get('@video2').find('.clear').click();
|
||||
cy.get('@video2').find('input').should('have.value', '');
|
||||
})
|
||||
@@ -27,12 +27,12 @@ context('ui.preview', () => {
|
||||
let id = md5('Audio preview');
|
||||
cy.get(`[data-cy=${id}]`).within(() => {
|
||||
cy.get('label').contains('audio1').next().as('audio1');
|
||||
cy.get('@audio1').find('audio').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/movie.ogg');
|
||||
cy.get('@audio1').find('audio').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/html/mov_bbb.ogg');
|
||||
cy.get('@audio1').find('input').clear().type('http://www.runoob.com/try/demo_source/mov_bbb.mp4');
|
||||
cy.get('@audio1').find('audio').should('have.prop', 'src', 'http://www.runoob.com/try/demo_source/mov_bbb.mp4');
|
||||
|
||||
cy.get('label').contains('audio2').next().as('audio2');
|
||||
cy.get('@audio2').find('audio').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/movie.ogg');
|
||||
cy.get('@audio2').find('audio').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/html/mov_bbb.ogg');
|
||||
cy.get('@audio2').find('.clear').click();
|
||||
cy.get('@audio2').find('input').should('have.value', '');
|
||||
})
|
||||
@@ -42,21 +42,21 @@ context('ui.preview', () => {
|
||||
let id = md5('Image preview');
|
||||
cy.get(`[data-cy=${id}]`).within(() => {
|
||||
cy.get('label').contains('image1').next().as('image1');
|
||||
cy.get('@image1').find('img').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/eg_tulip.jpg').and('have.css', 'height', '200px');
|
||||
cy.get('@image1').find('img').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/tags/img_pink_flowers.jpg').and('have.css', 'height', '200px');
|
||||
cy.get('@image1').find('input').clear().type('http://www.runoob.com/images/pulpit.jpg');
|
||||
cy.get('@image1').find('img').should('have.prop', 'src', 'http://www.runoob.com/images/pulpit.jpg');
|
||||
|
||||
cy.get('label').contains('image2').next().as('image2');
|
||||
cy.get('@image2').find('img').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/eg_tulip.jpg');
|
||||
cy.get('@image2').find('img').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/tags/img_pink_flowers.jpg');
|
||||
cy.get('@image2').find('.clear').click();
|
||||
cy.get('@image2').find('input').should('have.value', '');
|
||||
|
||||
cy.get('label').contains('image3').next().as('image3');
|
||||
cy.get('@image3').find('img').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/eg_tulip.jpg').and('have.css', 'width', '200px');
|
||||
cy.get('@image3').find('img').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/tags/img_pink_flowers.jpg').and('have.css', 'width', '200px');
|
||||
cy.get('@image3').find('img').parent().should('have.class', 'rounded');
|
||||
|
||||
cy.get('label').contains('image4').next().as('image4');
|
||||
cy.get('@image4').find('img').should('exist').and('have.prop', 'src', 'http://www.w3school.com.cn/i/eg_tulip.jpg').and('have.css', 'width', '200px');
|
||||
cy.get('@image4').find('img').should('exist').and('have.prop', 'src', 'https://www.w3schools.com/tags/img_pink_flowers.jpg').and('have.css', 'width', '200px');
|
||||
cy.get('@image4').find('img').parent().should('have.class', 'circle');
|
||||
})
|
||||
})
|
||||
|
||||
@@ -30,12 +30,12 @@ context('ui.status', () => {
|
||||
cy.get('label').contains('name1').next().find('input').as('name1');
|
||||
cy.get('label').contains('name2').next().find('input').as('name2');
|
||||
|
||||
cy.get('@readonly').then($dom => expect($dom.attr('readonly')).to.be.empty);
|
||||
cy.get('@readonly').then($dom => expect($dom.attr('readonly')).to.be.undefined);
|
||||
cy.get('@name1').then($dom => expect($dom.attr('readonly')).to.equal('readonly'));
|
||||
cy.get('@name2').then($dom => expect($dom.attr('readonly')).to.equal('readonly'));
|
||||
|
||||
cy.get('@readonly').type('daniel');
|
||||
cy.get('@name2').then($dom => expect($dom.attr('readonly')).to.be.empty);
|
||||
cy.get('@name2').then($dom => expect($dom.attr('readonly')).to.be.undefined);
|
||||
|
||||
cy.get('@readonly').clear();
|
||||
cy.get('@name2').then($dom => expect($dom.attr('readonly')).to.equal('readonly'));
|
||||
|
||||
@@ -55,11 +55,13 @@ context('ValueTemplate', () => {
|
||||
cy.get('input').last().should('have.value', 'sarah');
|
||||
});
|
||||
cy.get('label').contains('test1').next().find('input').clear().type('["hi daniel", "hello sarah"]');
|
||||
cy.wait(1500);
|
||||
cy.get('legend').contains('array1').parent().within(() => {
|
||||
cy.get('input').first().should('have.value', 'hi daniel');
|
||||
cy.get('input').last().should('have.value', 'hello sarah');
|
||||
});
|
||||
cy.get('label').contains('test1').next().find('input').clear().type('["one daniel"]');
|
||||
cy.wait(1500);
|
||||
cy.get('legend').contains('array1').parent().within(() => {
|
||||
cy.get('input').should('have.length', 1);
|
||||
cy.get('input').first().should('have.value', 'one daniel');
|
||||
@@ -72,11 +74,13 @@ context('ValueTemplate', () => {
|
||||
});
|
||||
|
||||
cy.get('label').contains('test2').next().find('input').clear().type('[{{}"text": "hi daniel"}, {{}"text": "hello"}]');
|
||||
cy.wait(1500);
|
||||
cy.get('legend').contains('array2').parent().within(() => {
|
||||
cy.get('input').first().should('have.value', 'hi daniel');
|
||||
cy.get('input').last().should('have.value', 'hello');
|
||||
});
|
||||
cy.get('label').contains('test2').next().find('input').clear().type('[{{}"text": "one daniel"}]');
|
||||
cy.wait(1500);
|
||||
cy.get('legend').contains('array2').parent().within(() => {
|
||||
cy.get('input').should('have.length', 1);
|
||||
cy.get('input').first().should('have.value', 'one daniel');
|
||||
|
||||
Generated
+473
-325
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"cross-var": "^1.1.0",
|
||||
"cypress": "^3.1.5",
|
||||
"cypress": "^4.11.0",
|
||||
"http-server": "^0.12.3"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -141,11 +141,9 @@
|
||||
},
|
||||
|
||||
watch: {
|
||||
'schema.value.length': {
|
||||
'schema.value': {
|
||||
handler(newVal, oldVal) {
|
||||
if (newVal > oldVal) { // add item
|
||||
this._supportItemsCollapse();
|
||||
}
|
||||
this._supportItemsCollapse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
properties: {
|
||||
video1: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/movie.ogg',
|
||||
default: 'https://www.w3schools.com/html/mov_bbb.ogg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -69,7 +69,7 @@
|
||||
},
|
||||
video2: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/movie.ogg',
|
||||
default: 'https://www.w3schools.com/html/mov_bbb.ogg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -90,7 +90,7 @@
|
||||
properties: {
|
||||
audio1: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/movie.ogg',
|
||||
default: 'https://www.w3schools.com/html/mov_bbb.ogg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -100,7 +100,7 @@
|
||||
},
|
||||
audio2: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/movie.ogg',
|
||||
default: 'https://www.w3schools.com/html/mov_bbb.ogg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -121,7 +121,7 @@
|
||||
properties: {
|
||||
image1: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/eg_tulip.jpg',
|
||||
default: 'https://www.w3schools.com/tags/img_pink_flowers.jpg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -134,7 +134,7 @@
|
||||
},
|
||||
image2: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/eg_tulip.jpg',
|
||||
default: 'https://www.w3schools.com/tags/img_pink_flowers.jpg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -145,7 +145,7 @@
|
||||
},
|
||||
image3: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/eg_tulip.jpg',
|
||||
default: 'https://www.w3schools.com/tags/img_pink_flowers.jpg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
@@ -159,7 +159,7 @@
|
||||
},
|
||||
image4: {
|
||||
type: 'string',
|
||||
default: 'http://www.w3school.com.cn/i/eg_tulip.jpg',
|
||||
default: 'https://www.w3schools.com/tags/img_pink_flowers.jpg',
|
||||
ui: {
|
||||
columns: 6,
|
||||
preview: {
|
||||
|
||||
@@ -257,10 +257,10 @@ export default {
|
||||
watch: {
|
||||
valueTemplate: {
|
||||
handler: function(newVal, oldVal) {
|
||||
clearTimeout(this.timer)
|
||||
if (newVal !== undefined) {
|
||||
if (oldVal === undefined || JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
|
||||
if (!(this.$options._init4valueTemplate && (_isArray(this.schema.value) ? this.schema.value.length > 0 : this.schema.value))) { // Prevent init value from being overwritten
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(() => {
|
||||
this.schema.value = newVal;
|
||||
}, this.globalConfig.updateWait)
|
||||
|
||||
@@ -109,11 +109,9 @@
|
||||
},
|
||||
|
||||
watch: {
|
||||
'schema.value.length': {
|
||||
'schema.value': {
|
||||
handler(newVal, oldVal) {
|
||||
if (newVal > oldVal) { // add item
|
||||
this._supportItemsCollapse();
|
||||
}
|
||||
this._supportItemsCollapse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user