Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.3 KiB

  1. diff --git a/test/settings.js b/test/settings.js
  2. index 7b28d66..642688f 100644
  3. --- a/test/settings.js
  4. +++ b/test/settings.js
  5. @@ -1,14 +1,20 @@
  6. 'use strict';
  7. /*jshint asi: true*/
  8. -var test = require('tap').test
  9. - , path = require('path')
  10. - , fs = require('fs')
  11. - , settings = require('../settings')
  12. - , existsSync = fs.existsSync || path.existsSync
  13. +var test = require('tap').test
  14. + , path = require('path')
  15. + , fs = require('fs')
  16. , hideSemicolonsTheme = require('../themes/hide-semicolons')
  17. , home = path.join(__dirname, 'fixtures', 'home')
  18. , rcpath = path.join(home, '.cardinalrc')
  19. + , existsSync = fs.existsSync || path.existsSync
  20. + , settingsResolve = require.resolve('../settings')
  21. + , settings
  22. +
  23. +function setup () {
  24. + delete require.cache[settingsResolve]
  25. + settings = require(settingsResolve)
  26. +}
  27. function writerc(config) {
  28. fs.writeFileSync(rcpath, JSON.stringify(config), 'utf-8')
  29. @@ -25,22 +31,47 @@ function resolveTheme (config) {
  30. return result;
  31. }
  32. +function getSettings (config) {
  33. + writerc(config)
  34. + var result = settings.getSettings(home)
  35. + removerc()
  36. + return result;
  37. +}
  38. +
  39. if (!existsSync(home)) fs.mkdirSync(home);
  40. test('no .cardinalrc in home', function (t) {
  41. + setup()
  42. var theme = settings.resolveTheme(home)
  43. t.equals(theme, undefined, 'resolves no theme')
  44. t.end()
  45. })
  46. test('.cardinalrc with theme "hide-semicolons" in home', function (t) {
  47. + setup()
  48. var theme = resolveTheme({ theme: "hide-semicolons" })
  49. t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
  50. t.end()
  51. })
  52. test('.cardinalrc with full path to "hide-semicolons.js" in home', function (t) {
  53. + setup()
  54. var theme = resolveTheme({ theme: path.join(__dirname, '..', 'themes', 'hide-semicolons.js') })
  55. t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
  56. t.end()
  57. })
  58. +
  59. +test('.cardinalrc with linenos: true', function (t) {
  60. + setup()
  61. + var opts = { linenos: true }
  62. + t.deepEquals(getSettings(opts), opts)
  63. + t.end()
  64. +})
  65. +
  66. +test('.cardinalrc with linenos: true and theme', function (t) {
  67. + setup()
  68. + var opts = { linenos: true, theme: 'some theme' }
  69. + t.deepEquals(getSettings(opts), opts)
  70. + t.end()
  71. +})
  72. +