Unit Test case to check if localstorage is empty once I logout of the Web app I am trying to clear my localstorage when I am logging out of the application. I want to write a unit test case in Jasmine to check if this task is performed when logout function is run. I am writing test cases for the first time so got stuck in the approach.

In my compoment.ts file I have a logout function:

logout() {
    location.href = "/";
     localstorage.clear();
}


spec.ts file

beforeEach(function () {
        var store = {};
        spyOn(localStorage, 'getItem').andCallFake(function (key) {
            return null;
        });
    });


I don't know if this is a correct approach to write the test case for this particular requirement or which one among unit or integration test cases is actually valid for this situation.
If you are using any I/O (in this case, local storage), you must have fallen into an integration test. 


A unit test could be that when logout is executed, the call to
clearing the local storage is made (using an spy on localStorage). 
An integration test could be that you have data in the local storage and after you have logged out, you don't.