-
Notifications
You must be signed in to change notification settings - Fork 532
Add a is-checked
class to element where the input is checked to ease customisation
#141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lionel-bijaoui
merged 4 commits into
vue-generators:master
from
lionel-bijaoui:lb_is-checked
Mar 10, 2017
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ describe("FieldRadios.vue", function() { | |
let model = { skills: "Javascript" }; | ||
let radioList; | ||
let radios; | ||
let labelList; | ||
|
||
function isChecked(idx) { | ||
return(radios[idx].checked); | ||
|
@@ -41,6 +42,7 @@ describe("FieldRadios.vue", function() { | |
createField(this, schema, model, false); | ||
radioList = el.querySelector(".radio-list"); | ||
radios = radioList.querySelectorAll("input[type=radio]"); | ||
labelList = radioList.querySelectorAll("label"); | ||
}); | ||
|
||
it("should contain a checkbox element", () => { | ||
|
@@ -64,31 +66,77 @@ describe("FieldRadios.vue", function() { | |
expect(isChecked(6)).to.be.false; | ||
}); | ||
|
||
it("radioList value should be the model value after changed", (done) => { | ||
model.skills = "ReactJS"; | ||
vm.$nextTick( () => { | ||
expect(isChecked(0)).to.be.false; | ||
expect(isChecked(1)).to.be.false; | ||
expect(isChecked(2)).to.be.false; | ||
expect(isChecked(3)).to.be.false; | ||
expect(isChecked(4)).to.be.false; | ||
expect(isChecked(5)).to.be.true; | ||
expect(isChecked(6)).to.be.false; | ||
done(); | ||
it("label with checked input should have a 'is-checked' class", () =>{ | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
}); | ||
|
||
|
||
describe("test values reactivity to changes", () => { | ||
|
||
it("radioList value should be the model value after changed", (done) => { | ||
model.skills = "ReactJS"; | ||
vm.$nextTick( () => { | ||
expect(isChecked(0)).to.be.false; | ||
expect(isChecked(1)).to.be.false; | ||
expect(isChecked(2)).to.be.false; | ||
expect(isChecked(3)).to.be.false; | ||
expect(isChecked(4)).to.be.false; | ||
expect(isChecked(5)).to.be.true; | ||
expect(isChecked(6)).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
it("model value should be the radioList value if changed", (done) => { | ||
radios[0].click(); | ||
|
||
it("model value should be the radioList value if changed", (done) => { | ||
radios[0].click(); | ||
vm.$nextTick( () => { | ||
expect(model.skills).to.be.equal("HTML5"); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
vm.$nextTick( () => { | ||
expect(model.skills).to.be.equal("HTML5"); | ||
done(); | ||
describe("test 'is-checked' class attribution reactivity to changes", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing, grouping test for better readability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
it("label with checked input should have a 'is-checked' class after model value is changed", (done) =>{ | ||
model.skills = "ReactJS"; | ||
vm.$nextTick( () => { | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("label with checked input should have a 'is-checked' class after radioList value is changed", (done) =>{ | ||
radios[2].click(); | ||
|
||
vm.$nextTick( () => { | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
|
||
}); | ||
|
||
describe("check template with object array", () => { | ||
|
@@ -113,6 +161,7 @@ describe("FieldRadios.vue", function() { | |
let model = { skills: "CSS3-123" }; | ||
let radioList; | ||
let radios; | ||
let labelList; | ||
|
||
function isChecked(idx) { | ||
return(radios[idx].checked); | ||
|
@@ -122,6 +171,7 @@ describe("FieldRadios.vue", function() { | |
createField(this, schema, model, false); | ||
radioList = el.querySelector(".radio-list"); | ||
radios = radioList.querySelectorAll("input[type=radio]"); | ||
labelList = radioList.querySelectorAll("label"); | ||
}); | ||
|
||
it("should contain a checkbox element", () => { | ||
|
@@ -145,28 +195,71 @@ describe("FieldRadios.vue", function() { | |
expect(isChecked(6)).to.be.false; | ||
}); | ||
|
||
it("radioList value should be the model value after changed", (done) => { | ||
model.skills = "ReactJS-123"; | ||
vm.$nextTick( () => { | ||
expect(isChecked(0)).to.be.false; | ||
expect(isChecked(1)).to.be.false; | ||
expect(isChecked(2)).to.be.false; | ||
expect(isChecked(3)).to.be.false; | ||
expect(isChecked(4)).to.be.false; | ||
expect(isChecked(5)).to.be.true; | ||
expect(isChecked(6)).to.be.false; | ||
done(); | ||
}); | ||
it("label with checked input should have a 'is-checked' class", () =>{ | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
}); | ||
describe("test values reactivity to changes", () => { | ||
|
||
it("radioList value should be the model value after changed", (done) => { | ||
model.skills = "ReactJS-123"; | ||
vm.$nextTick( () => { | ||
expect(isChecked(0)).to.be.false; | ||
expect(isChecked(1)).to.be.false; | ||
expect(isChecked(2)).to.be.false; | ||
expect(isChecked(3)).to.be.false; | ||
expect(isChecked(4)).to.be.false; | ||
expect(isChecked(5)).to.be.true; | ||
expect(isChecked(6)).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("model value should be the radioList value if changed", (done) => { | ||
radios[0].click(); | ||
|
||
it("model value should be the radioList value if changed", (done) => { | ||
radios[0].click(); | ||
vm.$nextTick( () => { | ||
expect(model.skills).to.be.equal("HTML5-123"); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("test 'is-checked' class attribution reactivity to changes", () => { | ||
|
||
vm.$nextTick( () => { | ||
expect(model.skills).to.be.equal("HTML5-123"); | ||
done(); | ||
it("label with checked input should have a 'is-checked' class after model value is changed", (done) =>{ | ||
model.skills = "ReactJS-123"; | ||
vm.$nextTick( () => { | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("label with checked input should have a 'is-checked' class after radioList value is changed", (done) =>{ | ||
radios[2].click(); | ||
|
||
vm.$nextTick( () => { | ||
expect(labelList[0].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[1].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[2].classList.contains("is-checked")).to.be.true; | ||
expect(labelList[3].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[4].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[5].classList.contains("is-checked")).to.be.false; | ||
expect(labelList[6].classList.contains("is-checked")).to.be.false; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have grouped the test a little bit, is this okay, and can I do the same thing in
checklist
's tests ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Yes please!