"use strict";

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


let storageReference;

describe('SessionStorage', function () {

    afterEach(() => {
        globalThis['sessionStorage'] = storageReference;
    });

    beforeEach(function () {

        storageReference = globalThis['sessionStorage']
        globalThis['sessionStorage'] = createStorage();

    })

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

    describe('rw', function () {

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

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


    })


})