Chapter 8: verify
This commit is contained in:
@@ -7,3 +7,4 @@ module.exports.getGitHubUser = (username) => {
|
||||
return json;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -32,3 +32,4 @@ module.exports = {
|
||||
created_at: "2013-01-30T18:13:42Z",
|
||||
updated_at: "2020-06-09T20:53:23Z",
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ test("Get GitHub user by username", async function (t) {
|
||||
|
||||
sinon.stub(github, "getGitHubUser").returns(octokitUserData);
|
||||
|
||||
const githubUser = await github.getGitHubUser("bethgriggs");
|
||||
const githubUser = await github.getGitHubUser("octokit");
|
||||
|
||||
t.equal(githubUser.id, 3430433);
|
||||
t.equal(githubUser.login, "octokit");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<coverage generated="1593565286083" clover="3.2.0">
|
||||
<project timestamp="1593565286083" name="All files">
|
||||
<coverage generated="1593571875155" clover="3.2.0">
|
||||
<project timestamp="1593571875155" name="All files">
|
||||
<metrics statements="2" coveredstatements="2" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="1" elements="3" coveredelements="3" complexity="0" loc="2" ncloc="2" packages="1" files="1" classes="1"/>
|
||||
<file name="uppercase.js" path="/Users/bethgriggs/Node-Cookbook/Chapter08/testing-with-jest/uppercase.js">
|
||||
<metrics statements="2" coveredstatements="2" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="1"/>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
||||
at Wed Jul 01 2020 02:01:26 GMT+0100 (British Summer Time)
|
||||
at Wed Jul 01 2020 03:51:15 GMT+0100 (British Summer Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
|
||||
@@ -60,12 +60,15 @@
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">module.exports = (string) => {
|
||||
return string.toUpperCase();
|
||||
};
|
||||
|
||||
</pre></td></tr></table></pre>
|
||||
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
@@ -73,7 +76,7 @@
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
||||
at Wed Jul 01 2020 02:01:26 GMT+0100 (British Summer Time)
|
||||
at Wed Jul 01 2020 03:51:15 GMT+0100 (British Summer Time)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
let uppercase = require("./../uppercase");
|
||||
const uppercase = require("./../uppercase");
|
||||
|
||||
describe("uppercase", () => {
|
||||
test("uppercase hello returns HELLO", () => {
|
||||
uppercase = jest.fn(() => "HELLO");
|
||||
const result = uppercase("hello");
|
||||
expect(uppercase).toHaveBeenCalledWith("hello");
|
||||
expect(result).toBe("HELLO");
|
||||
expect(uppercase("hello")).toBe("HELLO");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
module.exports = (string) => {
|
||||
return string.toUpperCase();
|
||||
};
|
||||
|
||||
|
||||
@@ -13,3 +13,4 @@ module.exports.multiply = (number1, number2) => {
|
||||
module.exports.divide = (number1, number2) => {
|
||||
return number1 / number2;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "testing-with-mocha",
|
||||
"name": "Chapter08",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
{
|
||||
"name": "testing-with-mocha",
|
||||
"name": "Chapter08",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "./node_modules/mocha/bin/mocha"
|
||||
"test": "mocha"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"mocha": "^8.0.1"
|
||||
|
||||
@@ -5,8 +5,8 @@ async function runTest() {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto("https://example.com");
|
||||
|
||||
const title = await page.$eval("h1", (el) => el.innerText);
|
||||
|
||||
console.log("Title value:", title);
|
||||
assert.equal(title, "Example Domain");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user