use oxfmt instead of prettier

This commit is contained in:
pa
2026-03-13 22:30:12 +09:00
parent 82122a4fab
commit 7b7c1b4568
155 changed files with 3467 additions and 1631 deletions

View File

@@ -47,7 +47,9 @@ describe('appActions utils', () => {
let consoleErrorSpy;
beforeEach(() => {
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
consoleErrorSpy = vi
.spyOn(console, 'error')
.mockImplementation(() => {});
vi.clearAllMocks();
mocks.searchStore.directAccessParse.mockReturnValue(false);
mocks.modalStore.confirm.mockResolvedValue({ ok: false });
@@ -131,7 +133,9 @@ describe('appActions utils', () => {
test('openDiscordProfile validates empty discord id', () => {
openDiscordProfile('');
expect(mocks.toast.error).toHaveBeenCalledWith('No Discord ID provided!');
expect(mocks.toast.error).toHaveBeenCalledWith(
'No Discord ID provided!'
);
});
test('openDiscordProfile shows error toast when api fails', async () => {

View File

@@ -43,7 +43,9 @@ describe('Invite Utils', () => {
});
test('returns true for public instance', () => {
expect(checkCanInvite('wrld_123:instance', defaultInviteDeps)).toBe(true);
expect(checkCanInvite('wrld_123:instance', defaultInviteDeps)).toBe(
true
);
});
test('returns true for group instance', () => {
@@ -56,45 +58,61 @@ describe('Invite Utils', () => {
});
test('returns true for own instance', () => {
expect(checkCanInvite('wrld_123:instance~private(usr_me)', defaultInviteDeps)).toBe(
true
);
expect(
checkCanInvite(
'wrld_123:instance~private(usr_me)',
defaultInviteDeps
)
).toBe(true);
});
test('returns false for invite-only instance owned by another', () => {
expect(checkCanInvite('wrld_123:instance~private(usr_other)', defaultInviteDeps)).toBe(
false
);
expect(
checkCanInvite(
'wrld_123:instance~private(usr_other)',
defaultInviteDeps
)
).toBe(false);
});
test('returns false for friends-only instance', () => {
expect(checkCanInvite('wrld_123:instance~friends(usr_other)', defaultInviteDeps)).toBe(
false
);
expect(
checkCanInvite(
'wrld_123:instance~friends(usr_other)',
defaultInviteDeps
)
).toBe(false);
});
test('returns true for friends+ instance if current location matches', () => {
const location = 'wrld_123:instance~hidden(usr_other)';
expect(checkCanInvite(location, {
...defaultInviteDeps,
lastLocationStr: location
})).toBe(true);
expect(
checkCanInvite(location, {
...defaultInviteDeps,
lastLocationStr: location
})
).toBe(true);
});
test('returns false for friends+ instance if not in that location', () => {
expect(checkCanInvite('wrld_123:instance~hidden(usr_other)', defaultInviteDeps)).toBe(
false
);
expect(
checkCanInvite(
'wrld_123:instance~hidden(usr_other)',
defaultInviteDeps
)
).toBe(false);
});
test('returns false for closed instance', () => {
const location = 'wrld_123:instance';
expect(checkCanInvite(location, {
...defaultInviteDeps,
cachedInstances: new Map([
[location, { closedAt: '2024-01-01' }]
])
})).toBe(false);
expect(
checkCanInvite(location, {
...defaultInviteDeps,
cachedInstances: new Map([
[location, { closedAt: '2024-01-01' }]
])
})
).toBe(false);
});
});
@@ -113,12 +131,17 @@ describe('Invite Utils', () => {
test('returns true for own instance', () => {
expect(
checkCanInviteSelf('wrld_123:instance~private(usr_me)', defaultSelfDeps)
checkCanInviteSelf(
'wrld_123:instance~private(usr_me)',
defaultSelfDeps
)
).toBe(true);
});
test('returns true for public instance', () => {
expect(checkCanInviteSelf('wrld_123:instance', defaultSelfDeps)).toBe(true);
expect(
checkCanInviteSelf('wrld_123:instance', defaultSelfDeps)
).toBe(true);
});
test('returns true for friends-only instance if user is a friend', () => {
@@ -132,23 +155,31 @@ describe('Invite Utils', () => {
test('returns false for friends-only instance if user is not a friend', () => {
expect(
checkCanInviteSelf('wrld_123:instance~friends(usr_other)', defaultSelfDeps)
checkCanInviteSelf(
'wrld_123:instance~friends(usr_other)',
defaultSelfDeps
)
).toBe(false);
});
test('returns false for closed instance', () => {
const location = 'wrld_123:instance';
expect(checkCanInviteSelf(location, {
...defaultSelfDeps,
cachedInstances: new Map([
[location, { closedAt: '2024-01-01' }]
])
})).toBe(false);
expect(
checkCanInviteSelf(location, {
...defaultSelfDeps,
cachedInstances: new Map([
[location, { closedAt: '2024-01-01' }]
])
})
).toBe(false);
});
test('returns true for invite instance (not owned, not closed)', () => {
expect(
checkCanInviteSelf('wrld_123:instance~private(usr_other)', defaultSelfDeps)
checkCanInviteSelf(
'wrld_123:instance~private(usr_other)',
defaultSelfDeps
)
).toBe(true);
});
});

View File

@@ -319,68 +319,92 @@ describe('User Utils', () => {
}
];
for (const { status, location, state, expected } of cases) {
const result = userStatusClass({
id: 'usr_friend',
isFriend: true,
status,
location,
state
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_friend',
isFriend: true,
status,
location,
state
},
false,
currentUser
);
expect(result[expected]).toBe(true);
}
});
test('returns offline style for location offline', () => {
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'offline',
state: ''
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'offline',
state: ''
},
false,
currentUser
);
expect(result.offline).toBe(true);
});
test('returns active style for state active', () => {
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: 'active'
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: 'active'
},
false,
currentUser
);
expect(result.active).toBe(true);
});
test('sets mobile flag for non-PC platform friend', () => {
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'wrld_1',
state: 'online',
$platform: 'android'
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'wrld_1',
state: 'online',
$platform: 'android'
},
false,
currentUser
);
expect(result.mobile).toBe(true);
});
test('no mobile flag for standalonewindows platform', () => {
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'wrld_1',
state: 'online',
$platform: 'standalonewindows'
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'active',
location: 'wrld_1',
state: 'online',
$platform: 'standalonewindows'
},
false,
currentUser
);
expect(result.mobile).toBeUndefined();
});
test('uses userId as fallback when id is not present', () => {
const result = userStatusClass({
userId: 'usr_me',
status: 'busy'
}, false, currentUser);
const result = userStatusClass(
{
userId: 'usr_me',
status: 'busy'
},
false,
currentUser
);
expect(result).toMatchObject({
'status-icon': true,
busy: true,
@@ -390,26 +414,34 @@ describe('User Utils', () => {
test('handles private location with empty state (temp fix branch)', () => {
currentUser.activeFriends = ['usr_f'];
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: ''
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: ''
},
false,
currentUser
);
// activeFriends includes usr_f → active
expect(result.active).toBe(true);
});
test('handles private location temp fix → offline branch', () => {
currentUser.activeFriends = [];
const result = userStatusClass({
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: ''
}, false, currentUser);
const result = userStatusClass(
{
id: 'usr_f',
isFriend: true,
status: 'busy',
location: 'private',
state: ''
},
false,
currentUser
);
expect(result.offline).toBe(true);
});
});
@@ -423,7 +455,9 @@ describe('User Utils', () => {
false,
false
);
expect(storeMocks.useAppearanceSettingsStore).not.toHaveBeenCalled();
expect(
storeMocks.useAppearanceSettingsStore
).not.toHaveBeenCalled();
});
test('returns empty string for falsy user', () => {
@@ -539,7 +573,9 @@ describe('User Utils', () => {
{ currentAvatarImageUrl: 'https://img.com/avatar' },
false
);
expect(storeMocks.useAppearanceSettingsStore).not.toHaveBeenCalled();
expect(
storeMocks.useAppearanceSettingsStore
).not.toHaveBeenCalled();
});
test('returns empty string for falsy user', () => {