Files
NapCatQQ/.pnpm-store/v3/files/f0/82f0f6998491607f706e7052704500005dfc3a6cb16171a67307b23871c510a6de225b2480ebf9ecfbbbffe6824f66e9ffb3be07746061ea96d427e8a72310
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

53 lines
1.7 KiB
Plaintext

import test from 'tape';
import isNonLiteralProperty from '../../../src/util/isNonLiteralProperty';
import IdentifierMock from '../../../__mocks__/IdentifierMock';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
import JSXSpreadAttributeMock from '../../../__mocks__/JSXSpreadAttributeMock';
import JSXTextMock from '../../../__mocks__/JSXTextMock';
import LiteralMock from '../../../__mocks__/LiteralMock';
const theProp = 'theProp';
const spread = JSXSpreadAttributeMock('theSpread');
test('isNonLiteralProperty', (t) => {
t.equal(
isNonLiteralProperty([], theProp),
false,
'does not identify them as non-literal role elements',
);
t.equal(
isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
false,
'does not identify elements with a literal property as non-literal role elements without spread operator',
);
t.equal(
isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
false,
'does not identify elements with a literal property as non-literal role elements with spread operator',
);
t.equal(
isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp),
false,
'identifies elements with a JSXText property as non-literal role elements',
);
t.equal(
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('undefined'))], theProp),
false,
'does not identify elements with a property of undefined as non-literal role elements',
);
t.equal(
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('theIdentifier'))], theProp),
true,
'identifies elements with an expression property as non-literal role elements',
);
t.end();
});