progamertj
New Coder
Summary:
Hi guys its a very simple easy question but i can't seem to figure out. For my uni work they are using JS to test our code. I usually program as i go in my own style but it has to be done their way and i can't figure out why it wont pass the test:
Problem:
The HTML page is below and the task is to create a simple H1 Tag following the java script test (at the bottom of the page) my H1 Tag is working just find i'm trying to figure out why the test won't pass
Many thanks
TJ
P.S rough code trying to think of solutions for example the script tag
[CODE lang="html" title="HTML Page"]<!DOCTYPE html>
<html lang="en">
<head>
<title>Temperature Monitor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<style type="text/css">
.background: #ffff99;
.H1 {
}
</style>
<script>
$(window).on("load", function() {
// Your JS code goes here.
}
</script>
</head>
<body>
<!-- Do not edit this section. -->
<div id="mocha" style="background-color: #fff"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('tdd');
mocha.checkLeaks();
</script>
<script src="COMP3006_CW1_Tests.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
<div id="monitor">
<div id="heading"><H1>Temperature Monitor</H1>
<form action="/action_page.php">
<label for="temperature">Enter Temperature</label>
<input type="text" id="temperature" name="temperature"><br><br>
<input type="submit" value="Submit">
</form>
</div>
</div>
<!-- Your HTML code goes here. -->
</body>
</html>
<script
[/CODE]
[CODE lang="javascript" title="Javascript test"]test("#Unit test 3 testing for heading presence", function(){
chai.assert.equal($("#heading").prop("tagName"), "H1", "Checking h1 element exists.");
chai.assert.equal($("#heading").html(), "Temperature Monitor", "Checking heading has the correct value");[/CODE]
Hi guys its a very simple easy question but i can't seem to figure out. For my uni work they are using JS to test our code. I usually program as i go in my own style but it has to be done their way and i can't figure out why it wont pass the test:
Problem:
The HTML page is below and the task is to create a simple H1 Tag following the java script test (at the bottom of the page) my H1 Tag is working just find i'm trying to figure out why the test won't pass
Many thanks
TJ
P.S rough code trying to think of solutions for example the script tag
[CODE lang="html" title="HTML Page"]<!DOCTYPE html>
<html lang="en">
<head>
<title>Temperature Monitor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<style type="text/css">
.background: #ffff99;
.H1 {
}
</style>
<script>
$(window).on("load", function() {
// Your JS code goes here.
}
</script>
</head>
<body>
<!-- Do not edit this section. -->
<div id="mocha" style="background-color: #fff"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('tdd');
mocha.checkLeaks();
</script>
<script src="COMP3006_CW1_Tests.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
<div id="monitor">
<div id="heading"><H1>Temperature Monitor</H1>
<form action="/action_page.php">
<label for="temperature">Enter Temperature</label>
<input type="text" id="temperature" name="temperature"><br><br>
<input type="submit" value="Submit">
</form>
</div>
</div>
<!-- Your HTML code goes here. -->
</body>
</html>
<script
[/CODE]
[CODE lang="javascript" title="Javascript test"]test("#Unit test 3 testing for heading presence", function(){
chai.assert.equal($("#heading").prop("tagName"), "H1", "Checking h1 element exists.");
chai.assert.equal($("#heading").html(), "Temperature Monitor", "Checking heading has the correct value");[/CODE]