add tests

This commit is contained in:
joshuaboud 2022-05-26 14:46:54 -03:00
parent ada824fd8e
commit cb5d07d343
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E
8 changed files with 2854 additions and 13 deletions

5
.gitignore vendored
View File

@ -1,6 +1,3 @@
# IDE
.vscode
# deb packaging
packaging/focal/cockpit-navigator
packaging/focal/cockpit-navigator.substvars
@ -10,4 +7,4 @@ packaging/focal/files
packaging/focal/.debhelper
# build output
dist
dist

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"jest.rootPath": "navigator"
}

View File

@ -75,7 +75,7 @@ $(VERSION_FILES): ./manifest.json
# build outputs
.SECONDEXPANSION:
$(OUTPUTS): %/dist/index.html: $$(shell find $$*/src -type f) $$(shell find $$*/public -type f) $$(shell find $$* -name 'yarn.lock' -o -name 'package.json' -not -path '*node_modules*') $$*/*.html $$*/*.js
$(OUTPUTS): %/dist/index.html: $$(shell find $$*/src -type f -not -name *.test.js) $$(shell find $$*/public -type f) $$(shell find $$* -name 'yarn.lock' -o -name 'package.json' -not -path '*node_modules*') $$*/*.html $$*/*.js
@echo -e $(call cyantext,Building $*)
$(NPM_PREFIX) $* install
ifeq ($(AUTO_UPGRADE_DEPS),1)
@ -120,6 +120,12 @@ plugin-install-remote-% : INSTALL_SUFFIX=-test
plugin-install-remote-% : SSH=ssh $(REMOTE_TEST_USER)@$(REMOTE_TEST_HOST)
plugin-install-remote-% : REMOTE_TEST_HOME=$(shell ssh $(REMOTE_TEST_USER)@$(REMOTE_TEST_HOST) 'echo $$HOME')
.SECONDEXPANSION:
test: default $$(addprefix test-, $$(PLUGIN_SRCS))
test-%:
$(NPM_PREFIX) $* test
clean: FORCE
rm $(dir $(OUTPUTS)) -rf

View File

@ -0,0 +1 @@
module.exports = { presets: ['@babel/preset-env'] };

View File

@ -0,0 +1,5 @@
module.exports = {
transform: {
"^.+\\.(js|jsx)$": "babel-jest",
},
};

View File

@ -5,7 +5,8 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "jest"
},
"dependencies": {
"@45drives/regex": "^0.1.0",
@ -15,12 +16,15 @@
"@45drives/cockpit-css": "^0.1.5",
"@45drives/cockpit-helpers": "^0.1.8",
"@45drives/cockpit-syntaxes": "^0.1.4",
"@babel/preset-env": "^7.18.2",
"@fontsource/red-hat-text": "^4.5.4",
"@headlessui/vue": "^1.5.0",
"@heroicons/vue": "^1.0.6",
"@tailwindcss/forms": "^0.5.0",
"@vitejs/plugin-vue": "^2.2.0",
"autoprefixer": "^10.4.2",
"babel-jest": "^28.1.0",
"jest": "^28.1.0",
"postcss": "^8.4.8",
"source-sans-pro": "^3.6.0",
"tailwindcss": "^3.0.23",

View File

@ -0,0 +1,35 @@
import assignObjectRecursive from "./assignObjectRecursive";
const defaultSource = {
str1: 'value1',
str2: 'value2',
num1: 1,
num2: 2,
bool1: true,
bool2: false,
obj1: {
str1: 'value1',
str2: 'value2',
num1: 1,
num2: 2,
bool1: true,
bool2: false,
}
};
test('basic assignment with no defaults', () => {
const settings = {};
assignObjectRecursive(settings, defaultSource);
expect(settings).toEqual(defaultSource);
});
test('ensure defaults do not overwrite source', () => {
const source = {
key1: 'value1',
key2: 'value2',
obj1: {
key1: 'value1',
key2: 'value2',
}
};
});

File diff suppressed because it is too large Load Diff