module.exports = process.atomBinding 'protocol'
+
+module.exports.RequestStringJob =
+class RequestStringJob
+ constructor: ({mimeType, charset, data}) ->
+ if typeof data isnt 'string' and not data instanceof Buffer
+ throw new TypeError('Data should be string or Buffer')
+
+ @mimeType = mimeType ? 'text/plain'
+ @charset = charset ? 'UTF-8'
+ @data = String data
protocol.unregisterProtocol 'test1'
it 'calls the callback when scheme is visited', (done) ->
- protocol.registerProtocol 'test2', -> done()
+ protocol.registerProtocol 'test2', (url) ->
+ assert.equal url, 'test2://test2'
+ done()
$.get 'test2://test2', ->
protocol.unregisterProtocol 'test2'
assert.equal data, 'atom-string://something'
done()
error: (xhr, errorType, error) ->
- console.log xhr, errorType, error
+ assert false, 'Got error: ' + errorType + ' ' + error
+
+ it 'returns RequestStringJob should send string', (done) ->
+ $.ajax
+ url: 'atom-string-job://something'
+ success: (data) ->
+ assert.equal data, 'atom-string-job://something'
+ done()
+ error: (xhr, errorType, error) ->
+ assert false, 'Got error: ' + errorType + ' ' + error
protocol.registerProtocol('atom-string', function(url) {
return url;
});
+
+ protocol.registerProtocol('atom-string-job', function(url) {
+ return new protocol.RequestStringJob({mimeType: 'text/html', data: url});
+ });
});
app.on('finish-launching', function() {