Skip to content

(#463) Changed clipboard methods to setContent and getContent #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/clipboard.class.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Clipboard class", () => {

const textToCopy = "bar";

SUT.copy(textToCopy);
await expect(SUT.paste()).resolves.toEqual(textToCopy);
SUT.setContent(textToCopy);
await expect(SUT.getContent()).resolves.toEqual(textToCopy);
});
});
4 changes: 2 additions & 2 deletions lib/clipboard.class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Clipboard class", () => {
const textToCopy = "bar";

// WHEN
SUT.copy(textToCopy);
SUT.setContent(textToCopy);

// THEN
expect(copyMock).toHaveBeenCalledTimes(1);
Expand All @@ -45,7 +45,7 @@ describe("Clipboard class", () => {
providerRegistryMock.getLogProvider = () => new NoopLogProvider();

// WHEN
SUT.paste();
SUT.getContent();

// THEN
expect(pasteMock).toHaveBeenCalledTimes(1);
Expand Down
8 changes: 4 additions & 4 deletions lib/clipboard.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ export class ClipboardClass {
constructor(private providerRegistry: ProviderRegistry) {}

/**
* {@link copy} copies a given text to the system clipboard
* {@link setContent} copies a given text to the system clipboard
* @param text The text to copy
*/
public copy(text: string): Promise<void> {
public setContent(text: string): Promise<void> {
this.providerRegistry.getLogProvider().debug(`Saving to clipboard`);
return this.providerRegistry.getClipboard().copy(text);
}

/**
* {@link paste} returns the current content of the system clipboard (limited to text)
* {@link getContent} returns the current content of the system clipboard (limited to text)
*/
public paste(): Promise<string> {
public getContent(): Promise<string> {
this.providerRegistry.getLogProvider().debug(`Fetching clipboard content`);
return this.providerRegistry.getClipboard().paste();
}
Expand Down