Revision cf5c689d9414c7ba5b6300e44178b2735faf8c06 authored by Florian Thomas on 25 January 2018, 15:43:56 UTC, committed by jekyllbot on 25 January 2018, 15:43:56 UTC
Merge pull request 6697
1 parent c9d2da8
test_coffeescript.rb
# frozen_string_literal: true
require "helper"
class TestCoffeeScript < JekyllUnitTest
context "converting CoffeeScript" do
setup do
External.require_with_graceful_fail("jekyll-coffeescript")
@site = fixture_site
@site.process
@test_coffeescript_file = dest_dir("js/coffeescript.js")
@js_output = <<-JS
(function() {
$(function() {
var cube, cubes, list, num, square;
list = [1, 2, 3, 4, 5];
square = function(x) {
return x * x;
};
cube = function(x) {
return square(x) * x;
};
cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();
if (typeof elvis !== "undefined" && elvis !== null) {
return alert("I knew it!");
}
});
}).call(this);
JS
end
should "write a JS file in place" do
assert_exist @test_coffeescript_file
end
should "produce JS" do
assert_equal @js_output, File.read(@test_coffeescript_file)
end
end
end
Computing file changes ...