mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import {test, stub} from 'supertape';
|
|
import {getCSSVar, goToDirectory} from '#dom';
|
|
|
|
globalThis.CloudCmd = {};
|
|
|
|
test('cloudcmd: client: dom: goToDirectory', async (t) => {
|
|
const path = '';
|
|
const changeDir = stub();
|
|
const prompt = stub().returns([null, path]);
|
|
|
|
await goToDirectory({
|
|
prompt,
|
|
changeDir,
|
|
});
|
|
|
|
t.calledWith(changeDir, [path]);
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: client: dom: getCSSVar', (t) => {
|
|
const body = {};
|
|
const getPropertyValue = stub().returns(0);
|
|
|
|
globalThis.getComputedStyle = stub().returns({
|
|
getPropertyValue,
|
|
});
|
|
const result = getCSSVar('hello', {
|
|
body,
|
|
});
|
|
|
|
delete globalThis.getComputedStyle;
|
|
|
|
t.notOk(result);
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: client: dom: getCSSVar: 1', (t) => {
|
|
const body = {};
|
|
const getPropertyValue = stub().returns(1);
|
|
|
|
globalThis.getComputedStyle = stub().returns({
|
|
getPropertyValue,
|
|
});
|
|
const result = getCSSVar('hello', {
|
|
body,
|
|
});
|
|
|
|
delete globalThis.getComputedStyle;
|
|
|
|
t.ok(result);
|
|
t.end();
|
|
});
|