@enonic/mock-xp
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-RC1 • Public • Published

@enonic/mock-xp

Library to mock Enonic XP API's and state.

Used to run tests in node, without the need to run Enonic XP.

Usage

import {deepStrictEqual} from 'assert';
import {
  LibNode,
  Server
} from '@enonic/mock-xp';


const APP_NAME = 'com.enonic.app.example';

const server = new Server().createRepo({id: APP_NAME});

const libNode = new LibNode({
	server
});


describe('whatever', () => {
  it(`is correct`, () => {
    const connection = libNode.connect({
      repoId: APP_NAME,
      branch: 'master'
    });
    const FOLDER_NAME = 'folderName';
    const createdNode = connection.create({
      _name: FOLDER_NAME
    });
    deepStrictEqual(
      {
        _id: createdNode._id,
        _indexConfig: {
          configs: [],
          default: {
            decideByType: true,
            enabled: true,
            fulltext: false,
            includeInAllText: false,
            indexValueProcessors: [],
            languages: [],
            nGram: false,
            path: false,
          },
        },
        _name: FOLDER_NAME,
        _path: createdNode._path,
        _nodeType: 'default',
        _state: 'DEFAULT',
        _ts: createdNode._ts,
        _versionKey: createdNode._versionKey,
      },
      createdNode
    );
  });
});

Enonic logo


Package Sidebar

Install

npm i @enonic/mock-xp

Weekly Downloads

262

Version

1.0.0-RC1

License

GPL-3.0

Unpacked Size

365 kB

Total Files

181

Last publish

Collaborators

  • edloidas
  • sigdestad
  • cwe_at_enonic.com
  • alansemenov