1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/test/test-tmp-file.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,27 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + "use strict"; 1.8 + 1.9 +const tmp = require("sdk/test/tmp-file"); 1.10 +const file = require("sdk/io/file"); 1.11 + 1.12 +const testFolderURL = module.uri.split('test-tmp-file.js')[0]; 1.13 + 1.14 +exports.testCreateFromString = function (assert) { 1.15 + let expectedContent = "foo"; 1.16 + let path = tmp.createFromString(expectedContent); 1.17 + let content = file.read(path); 1.18 + assert.equal(content, expectedContent, 1.19 + "Temporary file contains the expected content"); 1.20 +} 1.21 + 1.22 +exports.testCreateFromURL = function (assert) { 1.23 + let url = testFolderURL + "test-tmp-file.txt"; 1.24 + let path = tmp.createFromURL(url); 1.25 + let content = file.read(path); 1.26 + assert.equal(content, "foo", 1.27 + "Temporary file contains the expected content"); 1.28 +} 1.29 + 1.30 +require("sdk/test").run(exports);