mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-26 00:49:10 +00:00
fix merge conflicts
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
1819f5042c
commit
37ea4d7e6d
4
.github/workflows/js-unittest.yml
vendored
4
.github/workflows/js-unittest.yml
vendored
@ -16,7 +16,9 @@ jobs:
|
||||
- name: Install apt updates
|
||||
run: sudo apt -y update; sudo apt -y upgrade;
|
||||
- name: Install prerequisites
|
||||
run: sudo apt install -y nodejs npm;
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
|
@ -1,8 +1,9 @@
|
||||
{
|
||||
"name": "food-journal",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "mocha --recursive './{,!(node_modules)/**}/*.test.js'",
|
||||
"test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'",
|
||||
"lint": "eslint '**/*.js'",
|
||||
"fix-style": "eslint --fix **/*.js",
|
||||
"lintHTML": "htmlhint '**/*.html'",
|
||||
@ -12,6 +13,7 @@
|
||||
"eslint": "^8.27.0",
|
||||
"htmlhint": "1.1.4",
|
||||
"mocha": "10",
|
||||
"mock-local-storage": "^1.1.23",
|
||||
"stylelint": "14.14.1",
|
||||
"stylelint-config-standard": "^29.0.0"
|
||||
}
|
||||
|
@ -58,25 +58,25 @@ table {
|
||||
}
|
||||
|
||||
input, select {
|
||||
vertical-align :middle;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
img, fieldset, object {
|
||||
border:none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
*, *:after, *:before {
|
||||
box-sizing:border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button, label {
|
||||
cursor:pointer;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height:100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
form {
|
||||
border
|
||||
border: solid;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
module.exports = {environment};
|
||||
|
||||
function environment () {
|
||||
const localStorageMock = (function () {
|
||||
let store = {};
|
||||
return {
|
||||
getItem(key) {
|
||||
return store[key];
|
||||
},
|
||||
setItem(key, value) {
|
||||
store[key] = value;
|
||||
},
|
||||
clear() {
|
||||
store = {};
|
||||
},
|
||||
removeItem(key) {
|
||||
delete store[key];
|
||||
},
|
||||
getAll() {
|
||||
return store;
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
let window = {};
|
||||
Object.defineProperty(window, "localStorage", { value: localStorageMock });
|
||||
return window;
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
const {environment} = require("./testenv.js");
|
||||
var assert = require("assert");
|
||||
var {describe, it, beforeEach} = require("mocha");
|
||||
var {saveToLocal, getFromLocal, removeFromLocal, clearLocal} = require("./testenv_helpers");
|
||||
|
||||
beforeEach(() => {
|
||||
window = environment();
|
||||
});
|
||||
|
||||
describe("test localStorage mock", () => {
|
||||
it("test save and fetch", () => {
|
||||
saveToLocal("testkey1", "testvalue1");
|
||||
saveToLocal("testkey2", "testvalue2");
|
||||
saveToLocal("testkey3", "testvalue3");
|
||||
saveToLocal("testkey4", "testvalue4");
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), "testvalue1");
|
||||
assert.equal(getFromLocal("testkey2"), "testvalue2");
|
||||
assert.equal(getFromLocal("testkey3"), "testvalue3");
|
||||
assert.equal(getFromLocal("testkey4"), "testvalue4");
|
||||
|
||||
saveToLocal("testkey6", "testvalue5");
|
||||
assert.equal(getFromLocal("testkey6"), "testvalue5");
|
||||
});
|
||||
|
||||
it("test window locality", () => {
|
||||
assert.equal(getFromLocal("testkey1"), null);
|
||||
assert.equal(getFromLocal("testkey2"), null);
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), null);
|
||||
});
|
||||
|
||||
it("test delete and fetch", () => {
|
||||
saveToLocal("testkey1", "testvalue1");
|
||||
saveToLocal("testkey2", "testvalue2");
|
||||
saveToLocal("testkey3", "testvalue3");
|
||||
saveToLocal("testkey4", "testvalue4");
|
||||
|
||||
removeFromLocal("testkey3");
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), "testvalue1");
|
||||
assert.equal(getFromLocal("testkey2"), "testvalue2");
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), "testvalue4");
|
||||
|
||||
removeFromLocal("testkey1");
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), null);
|
||||
assert.equal(getFromLocal("testkey2"), "testvalue2");
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), "testvalue4");
|
||||
|
||||
removeFromLocal("testkey4");
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), null);
|
||||
assert.equal(getFromLocal("testkey2"), "testvalue2");
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), null);
|
||||
|
||||
removeFromLocal("testkey2");
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), null);
|
||||
assert.equal(getFromLocal("testkey2"), null);
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), null);
|
||||
});
|
||||
|
||||
it("test clear and fetch", () => {
|
||||
saveToLocal("testkey1", "testvalue1");
|
||||
saveToLocal("testkey2", "testvalue2");
|
||||
saveToLocal("testkey3", "testvalue3");
|
||||
saveToLocal("testkey4", "testvalue4");
|
||||
|
||||
clearLocal();
|
||||
|
||||
assert.equal(getFromLocal("testkey1"), null);
|
||||
assert.equal(getFromLocal("testkey2"), null);
|
||||
assert.equal(getFromLocal("testkey3"), null);
|
||||
assert.equal(getFromLocal("testkey4"), null);
|
||||
});
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
module.exports = {saveToLocal, getFromLocal, removeFromLocal, clearLocal};
|
||||
|
||||
function saveToLocal (k, v) {
|
||||
window.localStorage.setItem(k, v);
|
||||
}
|
||||
|
||||
function getFromLocal (k) {
|
||||
return window.localStorage.getItem(k);
|
||||
}
|
||||
|
||||
function removeFromLocal (k) {
|
||||
window.localStorage.removeItem(k);
|
||||
}
|
||||
|
||||
function clearLocal () {
|
||||
window.localStorage.clear();
|
||||
}
|
Loading…
Reference in New Issue
Block a user