forked from basicallydan/interfake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluent-web-page-test.js
43 lines (40 loc) · 1.4 KB
/
fluent-web-page-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var Interfake = require('..');
var assert = require('assert');
var path = require('path');
var filePath = path.join(__dirname, './');
console.log('Gonna open', filePath);
var interfake = new Interfake();
// var browser = new Browser();
// Serve up this folder as a website so we can test it
interfake.serveStatic('/static', filePath);
// Create the /update endpoint
interfake.get('/update').body({ text : 'Updated text!'});
// Start the server
interfake.listen(3000);
// Zombie is annoyingly buggy and unreliable but if you can get it to work you can use this script below...
// Use zombie to visit the page
// browser.visit('http://localhost:3000/static/fluent-web-page-test.html')
// .then(function() {
// // When we start, the text of the #target element is 'Not updated!'
// assert.equal(browser.text("#target"), 'Not updated!');
// })
// .then(function() {
// // The 'Update' link will trigger an XHR call to /update and update the text with the response data
// return browser.clickLink('Update');
// })
// .then(function () {
// // Give it a sec...
// return browser.wait(150);
// })
// .then(function () {
// // Voila! It has updated. Magic.
// assert.equal(browser.text('#target'), 'Updated text!');
// })
// .fail(function(error) {
// console.log('Error', error);
// browser.close();
// })
// .done(function() {
// console.log('All asserts passed just fine!');
// browser.close();
// });