
import {expect} from "chai"
import {escapeString} from "../../../source/types/regex.mjs"
import {initJSDOM} from "../../util/jsdom.mjs";


describe('escapeString', function () {

    before(function (done) {

        let promises = []
        promises.push(initJSDOM());
        if(!globalThis['crypto']) {
            promises.push(import("@peculiar/webcrypto").then(m => {
                globalThis['crypto'] = new m.Crypto();
                return true;
            }))
        }


        Promise.all(promises).then(() => {
            done()
        });

    });
    
    [
        ['test1', 'test1'],
        ['${', '\\$\\{'],
        ['i18n{', 'i18n\\{'],
        ['//', '//'],
        ['\\', '\\\\'],
       
    ].forEach(function (data) {

        let a = data.shift()
        let b = data.shift()

        it('escapeString(' + a + ') should return ' + b, function () {
            expect(escapeString(a)).is.equal(b)
        });
    });


});

