Skip to content

Commit 2de9999

Browse files
authored
Merge pull request learn-co-students#14 from learn-co-curriculum/update-tests
fixed tests to conform to new browser pattern
2 parents 603eacb + d086f46 commit 2de9999

File tree

7 files changed

+65
-25
lines changed

7 files changed

+65
-25
lines changed

index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Mocha</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="node_modules/mocha/mocha.css" />
8+
</head>
9+
<body>
10+
<main id="main">
11+
</main>
12+
<script src="index.js"></script>
13+
<!-- Open this file and call `mocha.run()` in console to run tests -->
14+
<div id="mocha"></div>
15+
<script src="node_modules/mocha/mocha.js"></script>
16+
<script src="node_modules/expect/umd/expect.min.js"></script>
17+
<script src="node_modules/sinon/pkg/sinon.js"></script>
18+
<script>mocha.setup('bdd');</script>
19+
<script src="index.js"></script>
20+
<script src="test/index-test.js"></script>
21+
22+
</body>
23+
</html>

strings.js renamed to index.js

File renamed without changes.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
},
2323
"homepage": "https://github.com/learn-co-curriculum/javascript-strings-lab#readme",
2424
"devDependencies": {
25+
"expect": "^1.20.2",
2526
"jsdom": "^8.5.0",
26-
"mocha": "^2.4.5",
27+
"mocha": "^2.5.3",
2728
"mocha-jsdom": "^1.1.0",
2829
"mocha-multi": "^0.9.0"
2930
}

test/index-test.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*global concatenatedString, describe, interpolatedString, it, myString */
2+
3+
it('defines `greeting`', function() {
4+
assert.equal(greeting, "Hello, everybody!")
5+
})
6+
7+
it('concatenates strings to greet a special guest in `greetSpecialGuest`', function() {
8+
assert.equal(greetSpecialGuest, "Hello, " + specialGuest + "!")
9+
})
10+
11+
it('interpolates a string in `conversation`', function() {
12+
assert.equal(conversation, `Let's talk about ${topic}.`)
13+
})

test/mocha.opts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--timeout 10000

test/root.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
global.expect = require('expect');
2+
3+
const babel = require('babel-core');
4+
const jsdom = require('jsdom');
5+
const path = require('path');
6+
7+
8+
before(function(done) {
9+
const babelResult = babel.transformFileSync(path.resolve(__dirname, '..', 'index.js'), {
10+
presets: ['es2015']
11+
});
12+
13+
//const src = path.resolve(__dirname, '..', 'index.js');
14+
15+
jsdom.env('<div></div>', [], {src: babelResult.code}, (err, window) => {
16+
if (err) {
17+
return done(err);
18+
}
19+
20+
Object.keys(window).forEach(key => {
21+
global[key] = window[key];
22+
});
23+
24+
return done();
25+
});
26+
});

test/strings-test.js

-24
This file was deleted.

0 commit comments

Comments
 (0)