一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
45 行
1.3 KiB
TypeScript
45 行
1.3 KiB
TypeScript
import ShareService from '@joplin/lib/services/share/ShareService';
|
|
import mockShareService from '@joplin/lib/testing/share/mockShareService';
|
|
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
|
|
import waitFor from '@joplin/lib/testing/waitFor';
|
|
import { setupApplication, setupCommandForTesting } from './utils/testUtils';
|
|
import Note from '@joplin/lib/models/Note';
|
|
import Folder from '@joplin/lib/models/Folder';
|
|
const Command = require('./command-unpublish');
|
|
|
|
|
|
describe('command-unpublish', () => {
|
|
beforeEach(async () => {
|
|
await setupDatabaseAndSynchronizer(1);
|
|
await switchClient(1);
|
|
await setupApplication();
|
|
|
|
mockShareService({
|
|
getShares: async () => {
|
|
return { items: [{ id: 'test-id' }] };
|
|
},
|
|
postShares: async () => {
|
|
throw new Error('Unexpected call to postShares');
|
|
},
|
|
getShareInvitations: async () => null,
|
|
}, ShareService.instance());
|
|
});
|
|
|
|
test('should unpublish a note', async () => {
|
|
const command = setupCommandForTesting(Command, ()=>{});
|
|
|
|
const testFolder = await Folder.save({ title: 'Test' });
|
|
const testNote = await Note.save({ title: 'test', parent_id: testFolder.id, is_shared: 1 });
|
|
|
|
await command.action({
|
|
note: testNote.id,
|
|
});
|
|
|
|
await waitFor(async () => {
|
|
expect(await Note.load(testNote.id)).toMatchObject({
|
|
is_shared: 0,
|
|
});
|
|
});
|
|
});
|
|
});
|