"use strict";

import {expect} from "chai"
import {LocalStorage} from "../../../../../source/data/datasource/storage/localstorage.mjs";
import {createStorage} from "../../../../util/localstorage.mjs";


let localStorageReference;

describe('LocalStorage', function () {

    afterEach(() => {
        globalThis['localStorage'] = localStorageReference;
    });

    beforeEach(function () {

        localStorageReference = globalThis['localStorage']
        globalThis['localStorage'] = createStorage();

    })

    it('should instance of LocalStorage ', function () {
        expect(new LocalStorage('mykey')).to.be.instanceof(LocalStorage)
    });

    describe('rw', function () {

        it('read should return object', function (done) {
            const ds = new LocalStorage('mykey')
            ds.read().then(data => {
                done();
            }).catch(e => done(e));
        });

        it('write should ', function (done) {
            const ds = new LocalStorage('mykey')
            ds.write().then(data => {
                done();
            }).catch(e => done(e));
        });


    })


})