Last active
December 22, 2018 22:00
-
-
Save marcelmokos/6aa09a8c73b225c5923633825e10d4d7 to your computer and use it in GitHub Desktop.
test two elements have same classes
This file contains 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
/*-------- Promise.then() syntax ---------*/ | |
// when expect() is in Promise.then() method body | |
// we have to use callback function done() | |
it("test two inputs to have labels with same classes using Promise.then() ", (done) => { | |
getInputsLabelElement(input1).then((label1) => { | |
getInputsLabelElement(input2).then((label2) => { | |
label1.getAttribute("class").then((label1Classes) => { | |
label2.getAttribute("class").then((label2Classes) => { | |
expect(label1Classes).toBe(label2Classes); | |
done(); | |
}); | |
}); | |
}); | |
}); | |
}); | |
/*-------- async await syntax ------------*/ | |
// once you use async await we do not have to use callback function | |
// and we have more controle over test | |
it("test two inputs to have labels with same classes using async await", async () => { | |
const label1 = await getInputsLabelElement(input1); | |
const label2 = await getInputsLabelElement(input1); | |
expect(await label1.getAttribute("class")).toBe(await label2.getAttribute("class")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think L24 should be
input2