-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request atom#19016 from atom/wl-clipboard-line-endings
Convert line endings when copy and pasting
- Loading branch information
Showing
3 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,41 @@ | ||
describe('Clipboard', () => | ||
describe('write(text, metadata) and read()', function() { | ||
it('writes and reads text to/from the native clipboard', function() { | ||
describe('Clipboard', () => { | ||
describe('write(text, metadata) and read()', () => { | ||
it('writes and reads text to/from the native clipboard', () => { | ||
expect(atom.clipboard.read()).toBe('initial clipboard content'); | ||
atom.clipboard.write('next'); | ||
expect(atom.clipboard.read()).toBe('next'); | ||
}); | ||
|
||
return it('returns metadata if the item on the native clipboard matches the last written item', function() { | ||
it('returns metadata if the item on the native clipboard matches the last written item', () => { | ||
atom.clipboard.write('next', { meta: 'data' }); | ||
expect(atom.clipboard.read()).toBe('next'); | ||
expect(atom.clipboard.readWithMetadata().text).toBe('next'); | ||
expect(atom.clipboard.readWithMetadata().metadata).toEqual({ | ||
meta: 'data' | ||
}); | ||
}); | ||
})); | ||
}); | ||
|
||
describe('line endings', () => { | ||
let originalPlatform = process.platform; | ||
|
||
const eols = new Map([ | ||
['win32', '\r\n'], | ||
['darwin', '\n'], | ||
['linux', '\n'] | ||
]); | ||
for (let [platform, eol] of eols) { | ||
it(`converts line endings to the OS's native line endings on ${platform}`, () => { | ||
Object.defineProperty(process, 'platform', { value: platform }); | ||
|
||
atom.clipboard.write('next\ndone\r\n\n', { meta: 'data' }); | ||
expect(atom.clipboard.readWithMetadata()).toEqual({ | ||
text: `next${eol}done${eol}${eol}`, | ||
metadata: { meta: 'data' } | ||
}); | ||
|
||
Object.defineProperty(process, 'platform', { value: originalPlatform }); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters