"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const internal_1 = require("../../../internal");
const CdmCollectionHelperFunctions_1 = require("./CdmCollectionHelperFunctions");
describe('Cdm/CdmCollection/CdmImportCollection', () => {
    it('TestImportCollectionAdd', () => {
        const document = (0, CdmCollectionHelperFunctions_1.generateManifest)();
        document.isDirty = false;
        expect(document.isDirty)
            .toEqual(false);
        const imp = new internal_1.CdmImport(document.ctx, 'corpusPath', 'moniker');
        const addedImp = document.imports.push(imp);
        expect(document.isDirty)
            .toEqual(true);
        expect(document.imports.length)
            .toEqual(1);
        expect(addedImp)
            .toEqual(imp);
        expect(document.imports.allItems[0])
            .toEqual(imp);
        expect(imp.corpusPath)
            .toEqual('corpusPath');
        expect(imp.moniker)
            .toEqual('moniker');
        expect(imp.ctx)
            .toEqual(document.ctx);
    });
    it('TestCdmImportCollectionAddCorpusPath', () => {
        const document = (0, CdmCollectionHelperFunctions_1.generateManifest)();
        document.isDirty = false;
        const imp = document.imports.push('corpusPath');
        expect(document.isDirty)
            .toEqual(true);
        expect(document.imports.length)
            .toEqual(1);
        expect(document.imports.allItems[0])
            .toEqual(imp);
        expect(imp.corpusPath)
            .toEqual('corpusPath');
        expect(imp.moniker)
            .toBeUndefined();
        expect(imp.ctx)
            .toEqual(document.ctx);
    });
    it('TestCdmImportCollectionAddCorpusPathAndMoniker', () => {
        const document = (0, CdmCollectionHelperFunctions_1.generateManifest)();
        document.isDirty = false;
        const imp = document.imports.push('corpusPath', 'moniker');
        expect(document.isDirty)
            .toEqual(true);
        expect(document.imports.length)
            .toEqual(1);
        expect(document.imports.allItems[0])
            .toEqual(imp);
        expect(imp.corpusPath)
            .toEqual('corpusPath');
        expect(imp.moniker)
            .toEqual('moniker');
        expect(imp.ctx)
            .toEqual(document.ctx);
    });
    it('TestCdmImportCollectionAddRange', () => {
        const document = (0, CdmCollectionHelperFunctions_1.generateManifest)();
        document.isDirty = false;
        const importList = [
            new internal_1.CdmImport(document.ctx, 'corpusPath1', 'moniker1'),
            new internal_1.CdmImport(document.ctx, 'corpusPath2', 'moniker2'),
            new internal_1.CdmImport(document.ctx, 'corpusPath3', undefined)
        ];
        document.imports.concat(importList);
        expect(document.isDirty)
            .toBeTruthy();
        expect(document.imports.length)
            .toEqual(3);
        expect(document.imports.allItems[0])
            .toEqual(importList[0]);
        expect(document.imports.allItems[1])
            .toEqual(importList[1]);
        expect(document.imports.allItems[0].corpusPath)
            .toEqual('corpusPath1');
        expect(document.imports.item('corpusPath1', 'moniker1').moniker)
            .toEqual('moniker1');
        expect(document.imports.item('corpusPath1', 'moniker1').ctx)
            .toEqual(document.ctx);
        expect(document.imports.allItems[1].corpusPath)
            .toEqual('corpusPath2');
        expect(document.imports.item('corpusPath2'))
            .toBeUndefined();
        expect(document.imports.item('corpusPath2', undefined, false))
            .not.toBeUndefined();
        expect(document.imports.item('corpusPath2', undefined, true))
            .toBeUndefined();
        expect(document.imports.item('corpusPath2', 'moniker2', true))
            .not.toBeUndefined();
        expect(document.imports.item('corpusPath2', 'moniker3', false))
            .not.toBeUndefined();
        expect(document.imports.item('corpusPath2', 'moniker2').moniker)
            .toEqual('moniker2');
        expect(document.imports.item('corpusPath2', 'moniker2').ctx)
            .toEqual(document.ctx);
        expect(document.imports.item('corpusPath3'))
            .toEqual(importList[2]);
    });
});
//# sourceMappingURL=CdmImportCollection.test.js.map