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.

42 lines
2.4 KiB

  1. 'use strict'
  2. /* eslint-disable no-path-concat */
  3. var test = require('tape')
  4. var path = require('path')
  5. var customTheme = require('./fixtures/custom')
  6. var cardinal = require('..')
  7. var file = path.join(__dirname, 'fixtures/foo.js')
  8. var fileWithErrors = path.join(__dirname, 'fixtures/foo-with-errors.js')
  9. test('supplying custom theme', function(t) {
  10. cardinal.highlightFile(file, { theme: customTheme }, function(err, highlighted) {
  11. t.equals(null, err, 'no error')
  12. t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
  13. t.end()
  14. })
  15. })
  16. test('not supplying custom theme', function(t) {
  17. cardinal.highlightFile(file, function(err, highlighted) {
  18. t.equals(null, err, 'no error')
  19. t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
  20. t.end()
  21. })
  22. })
  23. test('syntactically invalid code', function(t) {
  24. cardinal.highlightFile(fileWithErrors, function(err, highlighted) {
  25. t.equals(null, err, 'no error')
  26. t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m\n')
  27. t.end()
  28. })
  29. })
  30. test('non existing file', function(t) {
  31. cardinal.highlightFile('./not/existing', function(err, highlighted) {
  32. t.ok((/ENOENT. .*not.existing/).test(err.message))
  33. t.end()
  34. })
  35. })