test_advanceValidate.js (1021B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Tests the advanceValidate function from rule-view.js. 7 8 const { 9 advanceValidate, 10 } = require("resource://devtools/client/inspector/shared/utils.js"); 11 const { KeyCodes } = require("resource://devtools/client/shared/keycodes.js"); 12 13 // 1 2 3 14 // 0123456789012345678901234567890 15 const sampleInput = '\\symbol "string" url(somewhere)'; 16 17 function testInsertion(where, result, testName) { 18 info(testName); 19 equal( 20 advanceValidate(KeyCodes.DOM_VK_SEMICOLON, sampleInput, where), 21 result, 22 "testing advanceValidate at " + where 23 ); 24 } 25 26 function run_test() { 27 testInsertion(4, true, "inside a symbol"); 28 testInsertion(1, false, "after a backslash"); 29 testInsertion(8, true, "after whitespace"); 30 testInsertion(11, false, "inside a string"); 31 testInsertion(24, false, "inside a URL"); 32 testInsertion(31, true, "at the end"); 33 }