{"size": 1713, "ext": "js", "max_stars_repo_path": "test/unit/lib/content-type-ids-in-plan.spec.js", "max_stars_repo_name": "piufop/telus-migration-tool", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unit/lib/content-type-ids-in-plan.spec.js", "max_issues_repo_name": "piufop/telus-migration-tool", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/lib/content-type-ids-in-plan.spec.js", "max_forks_repo_name": "piufop/telus-migration-tool", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5671641791, "max_line_length": 81, "alphanum_fraction": 0.4997081144}
const ROOT_DIR = process.cwd();
const { expect } = require('chai');

const contentTypeIdsInPlan = require(`${ROOT_DIR}/lib/content-type-ids-in-plan`);

describe('content-type-ids-in-plan', () => {
  it('get content type ids from plan', () => {
    const plan = [
      [
        {
          "type": "contentField/copy",
          "meta": {
            "contentTypeInstanceId": "content/song/0",
            "fieldInstanceId": "fields/song/track/0"
          },
          "payload": {
            "contentTypeId": "song",
            "fromId": "song",
            "toId": "track"
          }
        }
      ],
      [
        {
          "type": "contentField/copy",
          "meta": {
            "contentTypeInstanceId": "content/book/0",
            "fieldInstanceId": "fields/title/editor/0"
          },
          "payload": {
            "contentTypeId": "book",
            "fromId": "author",
            "toId": "editor"
          }
        }
      ]
    ];

    const contentTypeIds = contentTypeIdsInPlan(plan);

    expect(contentTypeIds).to.be.a('Array');
    expect(contentTypeIds).to.have.length(2);
    expect(contentTypeIds).to.deep.equal(['song', 'book']);
  });

  it('get content type ids from transformation plan', () => {
    const plan = [
      [
        {
          "type": "content/transform",
          "meta": {
            "contentTypeInstanceId": "content/song/0"
          },
          "payload": {
            "contentTypeId": "song"
          }
        }
      ]
    ];

    const contentTypeIds = contentTypeIdsInPlan(plan);

    expect(contentTypeIds).to.be.a('Array');
    expect(contentTypeIds).to.have.length(1);
    expect(contentTypeIds).to.deep.equal(['song']);
  });
});