pulsar/spec/app/pasteboard-spec.coffee
Nathan Sobo fd4b6c85ce Add a global pasteboard object which supports metadata
This metadata will be used to record the indentation level of the first line when copying multiple lines of text to the pasteboard. The pasteboard takes the md5 of the pasted content when writing, then when reading it associates the last written metadata only when the signature matches the previously written value.
2012-10-24 17:42:58 -06:00

18 lines
751 B
CoffeeScript

describe "Pasteboard", ->
nativePasteboard = null
beforeEach ->
nativePasteboard = 'first'
spyOn($native, 'writeToPasteboard').andCallFake (text) -> nativePasteboard = text
spyOn($native, 'readFromPasteboard').andCallFake -> nativePasteboard
describe "write(text, metadata) and read()", ->
it "writes and reads text to/from the native pasteboard", ->
expect(pasteboard.read()).toEqual ['first']
pasteboard.write('next')
expect(nativePasteboard).toBe 'next'
it "returns metadata if the item on the native pasteboard matches the last written item", ->
pasteboard.write('next', {meta: 'data'})
expect(nativePasteboard).toBe 'next'
expect(pasteboard.read()).toEqual ['next', {meta: 'data'}]