-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathcompiler_test.exs
More file actions
49 lines (39 loc) · 1.44 KB
/
compiler_test.exs
File metadata and controls
49 lines (39 loc) · 1.44 KB
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
46
47
48
49
defmodule ElixirScript.Compiler.Test do
use ExUnit.Case
test "Can compile one entry module" do
result = ElixirScript.Compiler.compile(Version)
assert is_binary(result)
end
test "Can compile multiple entry modules" do
result = ElixirScript.Compiler.compile([Atom, String, Agent])
assert is_binary(result)
end
test "Error on unknown module" do
assert_raise ElixirScript.CompileError, fn ->
ElixirScript.Compiler.compile(SomeModule)
end
end
test "Output format: es" do
result = ElixirScript.Compiler.compile(Atom, [format: :es, js_modules: [{React, "react"}, {ReactDOM, "react-dom", default: false}]])
assert result =~ "export default Elixir"
end
test "Output format: umd" do
result = ElixirScript.Compiler.compile(Atom, [format: :umd, js_modules: [{React, "react"}]])
assert result =~ "factory"
end
test "Output format: common" do
result = ElixirScript.Compiler.compile(Atom, [format: :common, js_modules: [{React, "react"}]])
assert result =~ "module.exports = Elixir"
end
test "Output file with default name" do
path = System.tmp_dir()
result = ElixirScript.Compiler.compile(Atom, [output: path])
assert File.exists?(Path.join([path, "Elixir.App.js"]))
end
test "Output file with custom name" do
path = System.tmp_dir()
path = Path.join([path, "myfile.js"])
result = ElixirScript.Compiler.compile(Atom, [output: path])
assert File.exists?(path)
end
end