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.

77 lines
2.0 KiB

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