mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	If you call mock_template(fn, true), we will call the actual template code and pass it to your stub for verification. We make this opt-in to prevent false positives on template line coverage. We special-case our handling of static/js/templates.js, since it's important that all of our tests have the Zulip-specific handlers for Handlebars pre-registered. This runs in roughly the same amount of time as the previous commit.
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
"use strict";
 | 
						|
 | 
						|
const {strict: assert} = require("assert");
 | 
						|
 | 
						|
const {run_test} = require("../zjsunit/test");
 | 
						|
 | 
						|
/*
 | 
						|
    Note that the test runner automatically registers
 | 
						|
    all of our handlers.
 | 
						|
*/
 | 
						|
 | 
						|
run_test("and", () => {
 | 
						|
    const args = {
 | 
						|
        last: true,
 | 
						|
    };
 | 
						|
 | 
						|
    const html = require("./templates/and.hbs")(args);
 | 
						|
    assert.equal(html, "<p>empty and</p>\n<p>last and</p>\n\n");
 | 
						|
});
 | 
						|
 | 
						|
run_test("or", () => {
 | 
						|
    const args = {
 | 
						|
        last: true,
 | 
						|
    };
 | 
						|
 | 
						|
    const html = require("./templates/or.hbs")(args);
 | 
						|
    assert.equal(html, "\n<p>last or</p>\n<p>true or</p>\n");
 | 
						|
});
 | 
						|
 | 
						|
run_test("rendered_markdown", () => {
 | 
						|
    const html = require("./templates/rendered_markdown.hbs")();
 | 
						|
    const expected_html =
 | 
						|
        '<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a>\n';
 | 
						|
    assert.equal(html, expected_html);
 | 
						|
});
 | 
						|
 | 
						|
run_test("numberFormat", () => {
 | 
						|
    const args = {
 | 
						|
        number: 1000000,
 | 
						|
    };
 | 
						|
 | 
						|
    const html = require("./templates/numberFormat.hbs")(args);
 | 
						|
    assert.equal(html, "1,000,000\n");
 | 
						|
});
 |