Skip to content

Commit

Permalink
Updates test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Kellye Greene committed Apr 19, 2019
1 parent a770987 commit 187c3fe
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
39 changes: 9 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<title>JavaScript Basics Control Flow Lab </title>
<meta name="description" content="Introduction to JavaScript Basics Control Flow Lab in the Learn.co curriculum">
<meta name="author" content="Flatiron School">

<link rel="stylesheet" href="node_modules/mocha/mocha.css">
</head>

<body>
<!-- <div> for Mocha to display test results. -->
<div id="mocha"></div>

<!-- Include Mocha and set it up for BDD-style testing. -->
<script src="node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd');</script>

<!-- Include Chai as the matcher library. -->
<script src="node_modules/chai/chai.js"></script>

<!-- Include the student's JavaScript file. -->
<script src="index.js"></script>

<!-- Include the JavaScript file containing the tests. -->
<script src="test/indexTest.js"></script>

<!-- Include Flatiron School's test runner to push results to Learn. -->
<script src="node_modules/learn-browser/learnBrowser.min.js"></script>
</body>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JavaScript Lab</title>
</head>
<body>
hello
</body>
</html>
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "JavaScript Control Flow Lab for Learn.co",
"main": "index.js",
"scripts": {
"postinstall": "gem install learn-co",
"test": "node_modules/browser-sync/bin/browser-sync.js start --config node_modules/learn-browser/bs-config.js"
"test": "mocha -R mocha-multi --reporter-options spec=-,json=.results.json"
},
"repository": {
"type": "git",
Expand All @@ -27,6 +26,13 @@
},
"homepage": "https://github.com/learn-co-curriculum/js-basics-flow-control#readme",
"devDependencies": {
"learn-browser": "^0.1.13"
"babel-core": "6.26.3",
"babel-preset-env": "1.7.0",
"chai": "4.1.2",
"file-system": "2.2.2",
"jsdom": "9.2.1",
"mocha": "5.2.0",
"mocha-jsdom": "~1.1.0",
"mocha-multi": "1.0.1"
}
}
20 changes: 20 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const chai = require('chai')
global.expect = chai.expect
const fs = require('file-system')
const jsdom = require('mocha-jsdom')
const path = require('path')
const babel = require('babel-core');

const html = fs.readFileSync(path.resolve(__dirname, '..', 'index.html'), 'utf-8')

const babelResult = babel.transformFileSync(
path.resolve(__dirname, '..', 'index.js'), {
presets: ['env']
}
);

const src = babelResult.code

jsdom({
html, src
});
2 changes: 0 additions & 2 deletions test/indexTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const expect = chai.expect;

describe('index.js', function () {
describe('scuberGreetingForFeet()', function () {
it('gives customers a free sample if the ride is less than or equal to 400 feet', function () {
Expand Down

0 comments on commit 187c3fe

Please sign in to comment.