'use strict';

const userUtils = require('./../../dev-tools/users-utils');
const User = userUtils.User;

describe('Learn', function () {
	describe('Past gen variants', function () {
		it('should be independent of previous commands', function (done) {
			const room = Rooms('staff');

			const user = new User();
			user.forceRename("Staff Member", false);
			user.group = '%';
			user.isStaff = true;
			user.joinRoom(room);
			room.update();

			const cmdText1 = '!learn nidoking, counter';
			const cmdText2 = '!gsclearn nidoking, counter';
			const cmdP = CommandParser.parse(cmdText1, room, user, user.connections[0]).then(() => {
				return CommandParser.parse(cmdText2, room, user, user.connections[0]);
			});

			(cmdP || {then: function () {}}).then(() => {
				room.update();
				const logEntry = room.log[room.log.length - 1];
				user.disconnectAll();
				user.destroy();
				if (logEntry.includes('cannotlearn')) return done(new Error("/gsclearn failed after /learn"));
				return done();
			});
		});
	});
});

@@ -528,32 +528,72 @@
 king, counter';%0A
+%09%09%09const noop = %7Bthen: function () %7B%7D%7D;%0A
 %09%09%09const cmdP = 
@@ -589,16 +589,17 @@
 nst cmdP
+1
  = Comma
@@ -655,16 +655,50 @@
 ions%5B0%5D)
+;%0A%09%09%09const cmdP2 = (cmdP1 %7C%7C noop)
 .then(()
@@ -798,34 +798,17 @@
 cmdP
+2
  %7C%7C 
-%7Bthen: function () %7B%7D%7D
+noop
 ).th

Fix crash in datasearch test