<commit_before><commit_msg>Started adding tests for pure browser WebSockets<commit_after>var test = require('tape');
var signaller = require('..');
var url = require('url');
var parts = url.parse(location.origin);
var wsUrl = 'ws' + parts.protocol.slice(4) + '//' + parts.host + '/primus';
var socket;
var sig;

test('can create a new websocket connection to test server', function(t) {
  t.plan(1);
  socket = new WebSocket(wsUrl);
  t.ok(socket instanceof WebSocket, 'websocket created');
});

test('socket opens successfully', function(t) {
  t.plan(1);
  socket.onopen = t.pass.bind(t, 'opened');
});

test('close the socket', function(t) {
  t.plan(1);
  socket.close();
  t.pass('socket closed');
});

test('create a new socket', function(t) {
  t.plan(1);
  socket = new WebSocket(wsUrl);
  t.ok(socket instanceof WebSocket, 'websocket created');
});

test('create a new signaller wrapping the socket, wait for open', function(t) {
  t.plan(1);
  sig = signaller(socket);
  sig.once('open', t.pass.bind(t, 'signaller ready'));
});

test('close the socket', function(t) {
  t.plan(1);
  socket.close();
  t.pass('socket closed');
});
{'fraction_non_alphanumeric': 0.18349429323968394, 'fraction_numerical': 0.006145741878841089, 'mean_word_length': 4.786802030456853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5186909', 'n_tokens_mistral': 392, 'n_tokens_neox': 390, 'n_words': 103}