test.js 666 B

123456789101112131415161718192021222324
  1. var sep = require('path').sep || '/';
  2. var assert = require('assert');
  3. var uri2path = require('../');
  4. var tests = require('./tests.json');
  5. describe('file-uri-to-path', function () {
  6. Object.keys(tests).forEach(function (uri) {
  7. // the test cases were generated from Windows' PathCreateFromUrlA() function.
  8. // On Unix, we have to replace the path separator with the Unix one instead of
  9. // the Windows one.
  10. var expected = tests[uri].replace(/\\/g, sep);
  11. it('should convert ' + JSON.stringify(uri) + ' to ' + JSON.stringify(expected),
  12. function () {
  13. var actual = uri2path(uri);
  14. assert.equal(actual, expected);
  15. });
  16. });
  17. });