Files
panic-server/notes.js
Jesse Gibson e1fdf1d07b Move client code to separate project, fix context methods, remove express/axios
Major changes: panic client and server have been separated into two separate projects. This prevents a bunch of overhead if you're installing panic on each machine you're testing against. It also helps with separation of concerns and prevents assumptive tests.

Another major change: express was becoming complicated quick for what I needed. Instead of trying to re-implement websockets over http, I'm switching over to socket.io to allow for easier full duplex data streams.

Many of the patches weren't necessary when client code was removed (like Function.parse, Object.keys, Gun extensions, etc.)
2016-03-08 19:47:01 -07:00

148 lines
2.5 KiB
JavaScript

/*global test, Gun*/
test('Server push', function () {
'use strict';
var times = 50;
this.peer('server', function (server) {
var gun = new Gun('http://localhost:8080');
server.times(times, function (i, last, done) {
return gun.get('push').path(i).put('hey', done);
});
});
this.peer('server', function (server, done) {
server.timeout(10000);
var gun, num = 0;
gun = new Gun().get('push');
gun.map().val(function () {
num += 1;
done.when(num === times);
});
});
});
test('Client sync', function () {
'use strict';
var list = [
'test',
'potato',
'no',
'bar'
];
this.use(function () {
// universal selector?
});
this.peer('firefox', function () {
var gun = new Gun(location + 'gun');
this.times(list, function (name) {
gun.get(name).put({
name: name
});
});
});
this.peer('chrome', function (peer, done) {
var gun = new Gun(location + 'gun');
this.times(list, function (name) {
gun.get(name).path('name').val(function (val) {
});
});
});
this.use(function () {
this.env = new Gun(location + 'gun').get('potato');
});
this.browser(function () {
this.env.val(); // #potato
});
this.server(function () {
this.env.val(); // #potato
});
// "done" from runner env
this.chrome(function (browser, done) {
done.when(window.potato === 5);
});
// vote against argument injectors
this.firefox(function (five, ten) {
var expression = true;
this.finished();
this.finished.when(expression);
}, [5, 10]);
this.firefox(function (browser, done) {
//this.env.value == true
//this.env.data == "string"
browser.env.data = "string"; // yep
}, {
value: true,
data: "string"
});
});
test('Server push', function () {
'use strict';
var responses = 0;
this.ready(function (res) {
responses += 1;
return responses === 5;
});
this.all(function () {
this.env.gun = new Gun('localhost:8080/gun');
});
this.fail('Reason');
this.browser(function () {
this.times(20, function (val) {
return gun.path(val).put({
data: true
});
});
});
this.server(function () {
this.env.gun
});
});
var Context = require('./lib/framework/context');
// if the test succeeds
Context.prototype.success = function () {
var test, total = {};
test = this;
this.done(function (done) {
total[done.peer] = done.status;
var keys = Object.keys(total);
if (test.peers === keys.length) {
var success = !Object.values(total).find(function (win) {
return !win;
});
}
});
};