Skip to content

Commit fcca1e3

Browse files
committed
Test elixirscript through executed js
1 parent 4ca5201 commit fcca1e3

7 files changed

Lines changed: 332 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ src/elixirscript
1919
priv/**/*.js
2020
stdlib_state.bin
2121
*.log
22+
test/app/build

test/app/convert-exjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cd ../../
2+
3+
mix elixirscript test/app/src/ -f common -o test/app/build/

test/app/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "elixirscript-js-app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "npm run test-unit",
8+
"test-unit": "./convert-exjs && NODE_ENV=test mocha --require co-mocha -R spec --ui bdd 'spec/*.spec.js'"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"devDependencies": {
13+
"chai": "^3.5.0",
14+
"co-mocha": "^1.2.0",
15+
"mocha": "^3.2.0",
16+
"sinon": "^1.17.7",
17+
"sinon-chai": "^2.8.0"
18+
}
19+
}

test/app/spec/main.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const expect = require('chai').expect;
2+
const sinon = require('sinon');
3+
4+
const Elixir = require('../build/Elixir.App');
5+
6+
describe('Elixir.start', function () {
7+
it('calls the modules start function', function () {
8+
const callback = sinon.spy();
9+
10+
Elixir.start(Elixir.Main, callback);
11+
12+
expect(callback).to.have.been.calledWith('started');
13+
});
14+
});
15+
16+
describe('Elixir.load', function () {
17+
it('loads the modules exports', function () {
18+
const main = Elixir.load(Elixir.Main);
19+
20+
expect(main).to.have.property('start');
21+
expect(main).to.have.property('hello');
22+
expect(main.hello()).to.eq('Hello!');
23+
});
24+
});

test/app/spec/setup.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const sinon = require('sinon');
2+
const chai = require('chai');
3+
const sinonChai = require('sinon-chai');
4+
5+
before(function () {
6+
chai.use(sinonChai);
7+
});
8+
9+
beforeEach(function () {
10+
this.sandbox = sinon.sandbox.create();
11+
});
12+
13+
afterEach(function () {
14+
this.sandbox.restore();
15+
});

test/app/src/main.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Main do
2+
def start(:normal, callback) do
3+
callback.("started")
4+
end
5+
6+
def hello do
7+
"Hello!"
8+
end
9+
end

test/app/yarn.lock

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
assertion-error@^1.0.1:
6+
version "1.0.2"
7+
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
8+
9+
balanced-match@^0.4.1:
10+
version "0.4.2"
11+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
12+
13+
brace-expansion@^1.0.0:
14+
version "1.1.6"
15+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9"
16+
dependencies:
17+
balanced-match "^0.4.1"
18+
concat-map "0.0.1"
19+
20+
browser-stdout@1.3.0:
21+
version "1.3.0"
22+
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f"
23+
24+
chai@^3.5.0:
25+
version "3.5.0"
26+
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
27+
dependencies:
28+
assertion-error "^1.0.1"
29+
deep-eql "^0.1.3"
30+
type-detect "^1.0.0"
31+
32+
co-mocha@^1.2.0:
33+
version "1.2.0"
34+
resolved "https://registry.yarnpkg.com/co-mocha/-/co-mocha-1.2.0.tgz#d9be35a2a2d16f4b1b0e83f6973401ca4b6660af"
35+
dependencies:
36+
co "^4.0.0"
37+
is-generator "^1.0.1"
38+
39+
co@^4.0.0:
40+
version "4.6.0"
41+
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
42+
43+
commander@2.9.0:
44+
version "2.9.0"
45+
resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
46+
dependencies:
47+
graceful-readlink ">= 1.0.0"
48+
49+
concat-map@0.0.1:
50+
version "0.0.1"
51+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
52+
53+
debug@2.2.0:
54+
version "2.2.0"
55+
resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da"
56+
dependencies:
57+
ms "0.7.1"
58+
59+
deep-eql@^0.1.3:
60+
version "0.1.3"
61+
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2"
62+
dependencies:
63+
type-detect "0.1.1"
64+
65+
diff@1.4.0:
66+
version "1.4.0"
67+
resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf"
68+
69+
escape-string-regexp@1.0.5:
70+
version "1.0.5"
71+
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
72+
73+
formatio@1.1.1:
74+
version "1.1.1"
75+
resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9"
76+
dependencies:
77+
samsam "~1.1"
78+
79+
fs.realpath@^1.0.0:
80+
version "1.0.0"
81+
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
82+
83+
glob@7.0.5:
84+
version "7.0.5"
85+
resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95"
86+
dependencies:
87+
fs.realpath "^1.0.0"
88+
inflight "^1.0.4"
89+
inherits "2"
90+
minimatch "^3.0.2"
91+
once "^1.3.0"
92+
path-is-absolute "^1.0.0"
93+
94+
"graceful-readlink@>= 1.0.0":
95+
version "1.0.1"
96+
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
97+
98+
growl@1.9.2:
99+
version "1.9.2"
100+
resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f"
101+
102+
has-flag@^1.0.0:
103+
version "1.0.0"
104+
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
105+
106+
inflight@^1.0.4:
107+
version "1.0.6"
108+
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
109+
dependencies:
110+
once "^1.3.0"
111+
wrappy "1"
112+
113+
inherits@2, inherits@2.0.1:
114+
version "2.0.1"
115+
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
116+
117+
is-generator@^1.0.1:
118+
version "1.0.3"
119+
resolved "https://registry.yarnpkg.com/is-generator/-/is-generator-1.0.3.tgz#c14c21057ed36e328db80347966c693f886389f3"
120+
121+
json3@3.3.2:
122+
version "3.3.2"
123+
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
124+
125+
lodash._baseassign@^3.0.0:
126+
version "3.2.0"
127+
resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
128+
dependencies:
129+
lodash._basecopy "^3.0.0"
130+
lodash.keys "^3.0.0"
131+
132+
lodash._basecopy@^3.0.0:
133+
version "3.0.1"
134+
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
135+
136+
lodash._basecreate@^3.0.0:
137+
version "3.0.3"
138+
resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821"
139+
140+
lodash._getnative@^3.0.0:
141+
version "3.9.1"
142+
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
143+
144+
lodash._isiterateecall@^3.0.0:
145+
version "3.0.9"
146+
resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c"
147+
148+
lodash.create@3.1.1:
149+
version "3.1.1"
150+
resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7"
151+
dependencies:
152+
lodash._baseassign "^3.0.0"
153+
lodash._basecreate "^3.0.0"
154+
lodash._isiterateecall "^3.0.0"
155+
156+
lodash.isarguments@^3.0.0:
157+
version "3.1.0"
158+
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
159+
160+
lodash.isarray@^3.0.0:
161+
version "3.0.4"
162+
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"
163+
164+
lodash.keys@^3.0.0:
165+
version "3.1.2"
166+
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
167+
dependencies:
168+
lodash._getnative "^3.0.0"
169+
lodash.isarguments "^3.0.0"
170+
lodash.isarray "^3.0.0"
171+
172+
lolex@1.3.2:
173+
version "1.3.2"
174+
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31"
175+
176+
minimatch@^3.0.2:
177+
version "3.0.3"
178+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
179+
dependencies:
180+
brace-expansion "^1.0.0"
181+
182+
minimist@0.0.8:
183+
version "0.0.8"
184+
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
185+
186+
mkdirp@0.5.1:
187+
version "0.5.1"
188+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
189+
dependencies:
190+
minimist "0.0.8"
191+
192+
mocha@^3.2.0:
193+
version "3.2.0"
194+
resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.2.0.tgz#7dc4f45e5088075171a68896814e6ae9eb7a85e3"
195+
dependencies:
196+
browser-stdout "1.3.0"
197+
commander "2.9.0"
198+
debug "2.2.0"
199+
diff "1.4.0"
200+
escape-string-regexp "1.0.5"
201+
glob "7.0.5"
202+
growl "1.9.2"
203+
json3 "3.3.2"
204+
lodash.create "3.1.1"
205+
mkdirp "0.5.1"
206+
supports-color "3.1.2"
207+
208+
ms@0.7.1:
209+
version "0.7.1"
210+
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
211+
212+
once@^1.3.0:
213+
version "1.4.0"
214+
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
215+
dependencies:
216+
wrappy "1"
217+
218+
path-is-absolute@^1.0.0:
219+
version "1.0.1"
220+
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
221+
222+
samsam@1.1.2, samsam@~1.1:
223+
version "1.1.2"
224+
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567"
225+
226+
sinon-chai@^2.8.0:
227+
version "2.8.0"
228+
resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-2.8.0.tgz#432a9bbfd51a6fc00798f4d2526a829c060687ac"
229+
230+
sinon@^1.17.7:
231+
version "1.17.7"
232+
resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf"
233+
dependencies:
234+
formatio "1.1.1"
235+
lolex "1.3.2"
236+
samsam "1.1.2"
237+
util ">=0.10.3 <1"
238+
239+
supports-color@3.1.2:
240+
version "3.1.2"
241+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5"
242+
dependencies:
243+
has-flag "^1.0.0"
244+
245+
type-detect@0.1.1:
246+
version "0.1.1"
247+
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
248+
249+
type-detect@^1.0.0:
250+
version "1.0.0"
251+
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
252+
253+
"util@>=0.10.3 <1":
254+
version "0.10.3"
255+
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
256+
dependencies:
257+
inherits "2.0.1"
258+
259+
wrappy@1:
260+
version "1.0.2"
261+
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

0 commit comments

Comments
 (0)