import * as data from 'data';

const USERNAME_LOCAL_STORAGE_KEY = 'signed-in-user-username',
    AUTH_KEY_LOCAL_STORAGE_KEY = 'signed-in-user-auth-key';

const clearLocalStorage = () => {
    localStorage.removeItem(USERNAME_LOCAL_STORAGE_KEY);
    localStorage.removeItem(AUTH_KEY_LOCAL_STORAGE_KEY);
};

describe('Data Layer Tests', () => {
    beforeEach(clearLocalStorage);
    afterEach(clearLocalStorage);
    describe('isLoggedIn Tests', () => {
        it('Expect isLoggedIn() to return false when AUTH_KEY_LOCAL_STORAGE_KEY is not stored on localhost',
            () => {
                expect(data.isLoggedIn()).to.be.false;
            });
        it('Expect isLoggedIn() to return true when AUTH_KEY_LOCAL_STORAGE_KEY is stored on localhost',
            () => {
                localStorage.setItem(AUTH_KEY_LOCAL_STORAGE_KEY, "valid auth key");
                expect(data.isLoggedIn()).to.be.true;
            });
    });

});

mocha.run();

@@ -933,16 +933,892 @@
    %7D);%0A%0A
+    describe('getLoggedInUser Tests', () =%3E %7B%0A%0A        it('Expect getLoggedInUser() to return unknown when non user is logged in',%0A            () =%3E %7B%0A                //  const isLoggedInStub = sinon.stub(data, 'isLoggedIn').returns(false);%0A                expect(data.getLoggedInUser()).to.be.equal('unknown');%0A                //  isLoggedInStub.restore();%0A            %7D);%0A        it('Expect getLoggedInUser() to return the username when user is logged in',%0A            () =%3E %7B%0A                //  const isLoggedInStub = sinon.stub(data, 'isLoggedIn').returns(true);%0A                localStorage.setItem(AUTH_KEY_LOCAL_STORAGE_KEY, 'valid-auth-key');%0A                localStorage.setItem(USERNAME_LOCAL_STORAGE_KEY, 'validuser');%0A%0A                expect(data.getLoggedInUser()).to.be.equal('validuser');%0A                //  isLoggedInStub.restore();%0A            %7D);%0A    %7D);%0A%0A
 %7D);%0A%0Amoc

add getLoggedInUser tests