<commit_before>var assert = require('assert');
var cb = require('assert-called');
var getPrimus = require('./helpers/get-primus.js');
var PORT = 3459;
var ROOM = 'our-room';

var primus = getPrimus(PORT++);
var client;

function onConnected(spark) {
  var room;

  spark.join(ROOM);

  room = primus.room(ROOM);
  room.on('empty', cb(function () {
    assert.equal(room.sparks.length, 0, 'room should emit `empty` only when empty');

    primus.server.close();
    spark.end();
    client.end();<commit_msg>Test `leave` event<commit_after>var assert = require('assert');
var cb = require('assert-called');
var getPrimus = require('./helpers/get-primus.js');
var PORT = 3459;
var ROOM = 'our-room';

var primus = getPrimus(PORT++);
var client;

function onConnected(spark) {
  var room;

  spark.join(ROOM);

  room = primus.room(ROOM);

  primus.on('leave', cb(function (room_, spark_) {
    assert.equal(room, room_, '`leave` event should have correct `room` param');
    assert.equal(spark, spark_, '`leave` event should have correct `spark` param');
  }));

  room.on('empty', cb(function () {
    assert.equal(room.sparks.length, 0, 'room should emit `empty` only when empty');

    primus.server.close();
    spark.end();
    client.end();
{'fraction_non_alphanumeric': 0.17363344051446947, 'fraction_numerical': 0.008038585209003215, 'mean_word_length': 4.27542372881356, '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': '6566871', 'n_tokens_mistral': 436, 'n_tokens_neox': 418, 'n_words': 105}