Files
panic-server/notes.js
Jesse Gibson 3e4946951a Test coverage, imperative instead of declarative test syntax
After discussing the goals for panic more with Mark and Sean, I decided to take panic in a different direction. Previously, the interface used an options object to do test setup, and was completely declarative in nature. In order to do more complex things with the framework, it would have needed new features hacked into the existing one, without a solid, well tested foundation to build on. That was a bit frightening. As radical as it was, I decided to mostly rewrite the framework to be similar to a traditional test framework (such as jasmine or mocha), with a major twist - it will send your tests out to the connected clients to be run, and you can filter which platforms/peer IDs to run on. Since the approach is more imperative, it will be more verbose, but it also allows for faster scaling, ease of adding new features, more expressive/flexible tests, greater coverage, and approachable syntax.

With luck, panic will be around for quite some time. If that's the case, it really, really needs high test coverage, so I began with jasmine from the start. In addition, who's going to trust results from an untested test framework?
2016-03-03 14:40:51 -07:00

94 lines
1.7 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"
});
});