Fakultas Ilmu Komputer UI

Commit 3345a9cb authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140655219] #20 Add test on new library methods

parent dfc575b6
......@@ -94,6 +94,11 @@ describe('Server get test', () => {
Server.sendRequest('/test', 'GET', {}, true).then((data) => { expect(data).to.exist; });
});
it('Check submit method', () => {
fetchMock.get('*', {hue : "hue", hui : "hui"});
Server.submit('/test', {}, 'GET', true).then((data) => { expect(data).to.exist; });
});
it('Check isloggedin method', () => {
expect(Server.isLoggedIn()).to.not.exist;
});
......
/* eslint-disable no-unused-expressions */
/* eslint-disable */
import Storage from './../../lib/Storage';
describe('Storage get key', () => {
......@@ -30,4 +30,21 @@ describe('Storage clear key', () => {
expect(Storage.clear()).to.be.not.exist;
expect(Storage.get('test')).to.be.not.exist;
});
});
\ No newline at end of file
});
describe('Storage getUserData test', () => {
const fetchMock = require('fetch-mock');
it('Check Storage when there is no userdata', () => {
fetchMock.get('*', 'hue');
Storage.set('user-data', null); // clear to make sure storage empty
expect(Storage.get('user-data')).to.equal(null);
Storage.getUserData().then(r => {expect(r).to.equal('hue');}); // Storage call
});
it('Check Storage when there is already userdata', () => {
Storage.set('user-data','hue'); // set to make sure storage not empty
Storage.getUserData().then(r => {expect(r).to.equal('hue');});
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment