aboutsummaryrefslogtreecommitdiff
path: root/.vim/test/ftdetect_test.rb
blob: b28326ef6a964ea772d9c144d0369e978e0d5131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require_relative "./helper"

describe "Ftdetect" do
  [
    "#!/usr/bin/env node",
    "#!/usr/bin/env node --harmony-generators",
    "#!/usr/local/bin/env node",
    "#!/usr/local/bin/env node --harmony-generators",
    "#!/usr/bin/node",
    "#!/usr/bin/node --harmony-generators",
    "#!/usr/local/bin/node",
    "#!/usr/local/bin/node --harmony-generators",

  ].each do |shebang|
    it %(must detect a file with "#{shebang}" shebang as JavaScript) do
      file = Tempfile.new("bang")
      file.write shebang + $/
      file.close
      $vim.edit file.path
      $vim.echo("&ft").must_equal "javascript"
    end
  end

  [
    "#!/usr/bin/env noder",
    "#!/usr/bin/noder",

  ].each do |shebang|
    it %(must not detect a file with "#{shebang}" shebang as JavaScript) do
      file = Tempfile.new("bang")
      file.write shebang + $/
      file.close
      $vim.edit file.path
      $vim.echo("&ft").wont_equal "javascript"
    end
  end

  it "must not detect a .c file as JavaScript even with Node's shebang" do
    file = Tempfile.new(%w[tea .c])
    file.write "#!/usr/bin/node" + $/
    file.close
    $vim.edit file.path
    $vim.echo("&ft").wont_equal "javascript"
  end
end