<commit_before>
const chai = require('chai');
const chaiBattles = require('../../helpers/chai-battles.js');
const RG = require('../../../client/src/battles');
const RGTest = require('../../roguetest');

chai.use(chaiBattles);
const expect = chai.expect;
const Actor = RG.Actor.Rogue;
const Item = RG.Item.Base;

describe('How items are typed, physical entities', () => {

    it('has a type', () => {
        Object.keys(RG.Item).forEach(item => {
            if (!(/Container/).test(item)) {
                const newItem = new RG.Item[item]();
                expect(newItem.getType(), 'RG.Item.' + item).not.to.be.empty;
            }
        });
    });

    it('Has weight and size', () => {
        const item = new Item('TestItem');
        expect(item.has('Physical')).to.equal(true);

        item.setWeight(3.0);
        expect(item.get('Physical').getWeight()).to.equal(3.0);
        expect(item.getWeight()).to.equal(3.0);

        const clonedItem = item.clone();
        expect(item.equals(clonedItem)).to.equal(true);
        expect(clonedItem.equals(item)).to.equal(true);

    });

    it('can be compared', () => {
        Object.keys(RG.Item).forEach(item => {
            if (!(/Container/).test(item)) {
                const newItem = new RG.Item[item]();
                expect(newItem.equals(newItem),<commit_msg>Added a test to check that toString() for item does not contain NaN or undefined.<commit_after>
const chai = require('chai');
const chaiBattles = require('../../helpers/chai-battles.js');
const RG = require('../../../client/src/battles');
const RGTest = require('../../roguetest');

chai.use(chaiBattles);
const expect = chai.expect;
const Actor = RG.Actor.Rogue;
const Item = RG.Item.Base;

describe('How items are typed, physical entities', () => {

    it('has a type', () => {
        Object.keys(RG.Item).forEach(item => {
            if (!(/Container/).test(item)) {
                const newItem = new RG.Item[item]();
                expect(newItem.getType(), 'RG.Item.' + item).not.to.be.empty;
            }
        });
    });

    it('Has weight and size', () => {
        const item = new Item('TestItem');
        expect(item.has('Physical')).to.equal(true);

        item.setWeight(3.0);
        expect(item.get('Physical').getWeight()).to.equal(3.0);
        expect(item.getWeight()).to.equal(3.0);

        const clonedItem = item.clone();
        expect(item.equals(clonedItem)).to.equal(true);
        expect(clonedItem.equals(item)).to.equal(true);

    });

    it('can be converted to human-readable string', () => {
        const arrows = new RG.Item.Ammo('arrow');
        arrows.setCount(15);
        const arrStr = arrows.toString();
        expect(arrStr).to.not.match(/NaN/);
        expect(arrStr).to.not.match(/undefined/);
        expect(arrStr).to.match(/15 x arrow/);
    });

    it('can be compared', () => {
        Object.keys(RG.Item).forEach(item => {
            if (!(/Container/).test(item)) {
                const newItem = new RG.Item[item]();
                expect(newItem.equals(newItem),
{'fraction_non_alphanumeric': 0.19264562316954117, 'fraction_numerical': 0.005206638464041653, 'mean_word_length': 2.3966850828729283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '945103', 'n_tokens_mistral': 1001, 'n_tokens_neox': 956, 'n_words': 172}