How to use nodes method in mountebank

Best JavaScript code snippet using mountebank

sourceIndex.js

Source:sourceIndex.js Github

copy

Full Screen

1"use strict";2var _helpers = require("./util/helpers");3(0, _helpers.test)('universal selector', '*', function (t, tree) {4 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);5 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 1);6 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);7});8(0, _helpers.test)('lobotomized owl selector', ' * + * ', function (t, tree) {9 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 2);10 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 2);11 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 1);12 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 4);13 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 4);14 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 3);15 t.deepEqual(tree.nodes[0].nodes[2].source.start.column, 6);16 t.deepEqual(tree.nodes[0].nodes[2].source.end.column, 6);17 t.deepEqual(tree.nodes[0].nodes[2].sourceIndex, 5);18});19(0, _helpers.test)('comment', '/**\n * Hello!\n */', function (t, tree) {20 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);21 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 3);22 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);23});24(0, _helpers.test)('comment & universal selectors', '*/*test*/*', function (t, tree) {25 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);26 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 1);27 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);28 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 2);29 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 9);30 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 1);31 t.deepEqual(tree.nodes[0].nodes[2].source.start.column, 10);32 t.deepEqual(tree.nodes[0].nodes[2].source.end.column, 10);33 t.deepEqual(tree.nodes[0].nodes[2].sourceIndex, 9);34});35(0, _helpers.test)('tag selector', 'h1', function (t, tree) {36 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);37 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 2);38 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);39});40(0, _helpers.test)('id selector', '#id', function (t, tree) {41 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);42 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 3);43 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);44});45(0, _helpers.test)('tag selector followed by id selector', 'h1, #id', function (t, tree) {46 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);47 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 2);48 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);49 t.deepEqual(tree.nodes[1].nodes[0].source.start.column, 5);50 t.deepEqual(tree.nodes[1].nodes[0].source.end.column, 7);51 t.deepEqual(tree.nodes[1].nodes[0].sourceIndex, 4);52});53(0, _helpers.test)('multiple id selectors', '#one#two', function (t, tree) {54 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);55 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 4);56 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);57 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 5);58 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 8);59 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 4);60});61(0, _helpers.test)('multiple id selectors (2)', '#one#two#three#four', function (t, tree) {62 t.deepEqual(tree.nodes[0].nodes[2].source.start.column, 9);63 t.deepEqual(tree.nodes[0].nodes[2].source.end.column, 14);64 t.deepEqual(tree.nodes[0].nodes[2].sourceIndex, 8);65 t.deepEqual(tree.nodes[0].nodes[3].source.start.column, 15);66 t.deepEqual(tree.nodes[0].nodes[3].source.end.column, 19);67 t.deepEqual(tree.nodes[0].nodes[3].sourceIndex, 14);68});69(0, _helpers.test)('multiple id selectors (3)', '#one#two,#three#four', function (t, tree) {70 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 5);71 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 8);72 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 4);73 t.deepEqual(tree.nodes[1].nodes[1].source.start.column, 16);74 t.deepEqual(tree.nodes[1].nodes[1].source.end.column, 20);75 t.deepEqual(tree.nodes[1].nodes[1].sourceIndex, 15);76});77(0, _helpers.test)('multiple class selectors', '.one.two,.three.four', function (t, tree) {78 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 5);79 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 8);80 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 4);81 t.deepEqual(tree.nodes[1].nodes[1].source.start.column, 16);82 t.deepEqual(tree.nodes[1].nodes[1].source.end.column, 20);83 t.deepEqual(tree.nodes[1].nodes[1].sourceIndex, 15);84});85(0, _helpers.test)('attribute selector', '[name="james"]', function (t, tree) {86 t.deepEqual(tree.nodes[0].nodes[0].source.start.line, 1);87 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);88 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 14);89 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);90});91(0, _helpers.test)('multiple attribute selectors', '[name="james"][name="ed"],[name="snakeman"][name="a"]', function (t, tree) {92 t.deepEqual(tree.nodes[0].nodes[0].source.start.line, 1);93 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);94 t.deepEqual(tree.nodes[0].nodes[0].source.end.line, 1);95 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 14);96 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);97 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1);98 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 15);99 t.deepEqual(tree.nodes[0].nodes[1].source.end.line, 1);100 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 25);101 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 14);102 t.deepEqual(tree.nodes[1].nodes[0].source.start.line, 1);103 t.deepEqual(tree.nodes[1].nodes[0].source.start.column, 27);104 t.deepEqual(tree.nodes[1].nodes[0].source.end.line, 1);105 t.deepEqual(tree.nodes[1].nodes[0].source.end.column, 43);106 t.deepEqual(tree.nodes[1].nodes[0].sourceIndex, 26);107 t.deepEqual(tree.nodes[1].nodes[1].source.start.line, 1);108 t.deepEqual(tree.nodes[1].nodes[1].source.start.column, 44);109 t.deepEqual(tree.nodes[1].nodes[1].source.end.line, 1);110 t.deepEqual(tree.nodes[1].nodes[1].source.end.column, 53);111 t.deepEqual(tree.nodes[1].nodes[1].sourceIndex, 43);112});113(0, _helpers.test)('pseudo-class', 'h1:first-child', function (t, tree) {114 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1);115 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 3);116 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 14);117 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 2);118});119(0, _helpers.test)('pseudo-class with argument', 'h1:not(.strudel, .food)', function (t, tree) {120 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1);121 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 3);122 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 23);123 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 2);124});125(0, _helpers.test)('pseudo-element', 'h1::before', function (t, tree) {126 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1);127 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 3);128 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 10);129 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 2);130});131(0, _helpers.test)('multiple pseudos', 'h1:not(.food)::before, a:first-child', function (t, tree) {132 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1);133 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 3);134 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 13);135 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 2);136 t.deepEqual(tree.nodes[0].nodes[2].source.start.line, 1);137 t.deepEqual(tree.nodes[0].nodes[2].source.start.column, 14);138 t.deepEqual(tree.nodes[0].nodes[2].source.end.column, 21);139 t.deepEqual(tree.nodes[0].nodes[2].sourceIndex, 13);140 t.deepEqual(tree.nodes[1].nodes[1].source.start.line, 1);141 t.deepEqual(tree.nodes[1].nodes[1].source.start.column, 25);142 t.deepEqual(tree.nodes[1].nodes[1].source.end.column, 36);143 t.deepEqual(tree.nodes[1].nodes[1].sourceIndex, 24);144});145(0, _helpers.test)('combinators', 'div > h1 span', function (t, tree) {146 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1, "> start line");147 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 5, "> start column");148 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 5, "> end column");149 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 4, "> sourceIndex");150 t.deepEqual(tree.nodes[0].nodes[3].source.start.line, 1, "' ' start line");151 t.deepEqual(tree.nodes[0].nodes[3].source.start.column, 9, "' ' start column");152 t.deepEqual(tree.nodes[0].nodes[3].source.end.column, 9, "' ' end column");153 t.deepEqual(tree.nodes[0].nodes[3].sourceIndex, 8, "' ' sourceIndex");154});155(0, _helpers.test)('combinators surrounded by superfluous spaces', 'div > h1 ~ span a', function (t, tree) {156 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1, "> start line");157 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 7, "> start column");158 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 7, "> end column");159 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 6, "> sourceIndex");160 t.deepEqual(tree.nodes[0].nodes[3].source.start.line, 1, "~ start line");161 t.deepEqual(tree.nodes[0].nodes[3].source.start.column, 13, "~ start column");162 t.deepEqual(tree.nodes[0].nodes[3].source.end.column, 13, "~ end column");163 t.deepEqual(tree.nodes[0].nodes[3].sourceIndex, 12, "~ sourceIndex");164 t.deepEqual(tree.nodes[0].nodes[5].source.start.line, 1, "' ' start line");165 t.deepEqual(tree.nodes[0].nodes[5].source.start.column, 21, "' ' start column");166 t.deepEqual(tree.nodes[0].nodes[5].source.end.column, 23, "' ' end column");167 t.deepEqual(tree.nodes[0].nodes[5].sourceIndex, 20, "' ' sourceIndex");168});169(0, _helpers.test)('multiple id selectors on different lines', '#one,\n#two', function (t, tree) {170 t.deepEqual(tree.nodes[0].nodes[0].source.start.line, 1);171 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1);172 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 4);173 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0);174 t.deepEqual(tree.nodes[1].nodes[0].source.start.line, 2);175 t.deepEqual(tree.nodes[1].nodes[0].source.start.column, 1);176 t.deepEqual(tree.nodes[1].nodes[0].source.end.column, 4);177 t.deepEqual(tree.nodes[1].nodes[0].sourceIndex, 6);178});179(0, _helpers.test)('multiple id selectors on different CRLF lines', '#one,\r\n#two,\r\n#three', function (t, tree) {180 t.deepEqual(tree.nodes[0].nodes[0].source.start.line, 1, '#one start line');181 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 1, '#one start column');182 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 4, '#one end column');183 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 0, '#one sourceIndex');184 t.deepEqual(tree.nodes[1].nodes[0].source.start.line, 2, '#two start line');185 t.deepEqual(tree.nodes[1].nodes[0].source.start.column, 1, '#two start column');186 t.deepEqual(tree.nodes[1].nodes[0].source.end.column, 4, '#two end column');187 t.deepEqual(tree.nodes[1].nodes[0].sourceIndex, 7, '#two sourceIndex');188 t.deepEqual(tree.nodes[2].nodes[0].source.start.line, 3, '#three start line');189 t.deepEqual(tree.nodes[2].nodes[0].source.start.column, 1, '#three start column');190 t.deepEqual(tree.nodes[2].nodes[0].source.end.column, 6, '#three end column');191 t.deepEqual(tree.nodes[2].nodes[0].sourceIndex, 14, '#three sourceIndex');192});193(0, _helpers.test)('id, tag, pseudo, and class selectors on different lines with indentation', '\t#one,\n\th1:after,\n\t\t.two', function (t, tree) {194 t.deepEqual(tree.nodes[0].nodes[0].source.start.line, 1, '#one start line');195 t.deepEqual(tree.nodes[0].nodes[0].source.start.column, 2, '#one start column');196 t.deepEqual(tree.nodes[0].nodes[0].source.end.column, 5, '#one end column');197 t.deepEqual(tree.nodes[0].nodes[0].sourceIndex, 1, '#one sourceIndex');198 t.deepEqual(tree.nodes[1].nodes[0].source.start.line, 2, 'h1 start line');199 t.deepEqual(tree.nodes[1].nodes[0].source.start.column, 2, 'h1 start column');200 t.deepEqual(tree.nodes[1].nodes[0].source.end.column, 3, 'h1 end column');201 t.deepEqual(tree.nodes[1].nodes[0].sourceIndex, 8, 'h1 sourceIndex');202 t.deepEqual(tree.nodes[1].nodes[1].source.start.line, 2, ':after start line');203 t.deepEqual(tree.nodes[1].nodes[1].source.start.column, 4, ':after start column');204 t.deepEqual(tree.nodes[1].nodes[1].source.end.column, 9, ':after end column');205 t.deepEqual(tree.nodes[1].nodes[1].sourceIndex, 10, ':after sourceIndex');206 t.deepEqual(tree.nodes[2].nodes[0].source.start.line, 3, '.two start line');207 t.deepEqual(tree.nodes[2].nodes[0].source.start.column, 3, '.two start column');208 t.deepEqual(tree.nodes[2].nodes[0].source.end.column, 6, '.two end column');209 t.deepEqual(tree.nodes[2].nodes[0].sourceIndex, 20, '.two sourceIndex');210});211(0, _helpers.test)('pseudo with arguments spanning multiple lines', 'h1:not(\n\t.one,\n\t.two\n)', function (t, tree) {212 t.deepEqual(tree.nodes[0].nodes[1].source.start.line, 1, ':not start line');213 t.deepEqual(tree.nodes[0].nodes[1].source.start.column, 3, ':not start column');214 t.deepEqual(tree.nodes[0].nodes[1].source.end.line, 4, ':not end line');215 t.deepEqual(tree.nodes[0].nodes[1].source.end.column, 1, ':not end column');216 t.deepEqual(tree.nodes[0].nodes[1].sourceIndex, 2, ':not sourceIndex');217 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].source.start.line, 2, '.one start line');218 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].source.start.column, 2, '.one start column');219 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].source.end.line, 2, '.one end line');220 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].source.end.column, 5, '.one end column');221 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].sourceIndex, 9, '.one sourceIndex');222 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].source.start.line, 3, '.two start line');223 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].source.start.column, 2, '.two start column');224 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].source.end.line, 3, '.two end line');225 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].source.end.column, 5, '.two end column');226 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].sourceIndex, 16, '.two sourceIndex');...

Full Screen

Full Screen

id.js

Source:id.js Github

copy

Full Screen

1"use strict";2var _helpers = require("./util/helpers");3(0, _helpers.test)('id selector', '#one', function (t, tree) {4 t.deepEqual(tree.nodes[0].nodes[0].value, 'one');5 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');6});7(0, _helpers.test)('id selector with universal', '*#z98y ', function (t, tree) {8 t.deepEqual(tree.nodes[0].nodes[0].value, '*');9 t.deepEqual(tree.nodes[0].nodes[0].type, 'universal');10 t.deepEqual(tree.nodes[0].nodes[1].value, 'z98y');11 t.deepEqual(tree.nodes[0].nodes[1].type, 'id');12});13(0, _helpers.test)('id hack', '#one#two', function (t, tree) {14 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');15 t.deepEqual(tree.nodes[0].nodes[1].type, 'id');16});17(0, _helpers.test)('id and class names mixed', '#one.two.three', function (t, tree) {18 t.deepEqual(tree.nodes[0].nodes[0].value, 'one');19 t.deepEqual(tree.nodes[0].nodes[1].value, 'two');20 t.deepEqual(tree.nodes[0].nodes[2].value, 'three');21 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');22 t.deepEqual(tree.nodes[0].nodes[1].type, 'class');23 t.deepEqual(tree.nodes[0].nodes[2].type, 'class');24});25(0, _helpers.test)('qualified id', 'button#one', function (t, tree) {26 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');27 t.deepEqual(tree.nodes[0].nodes[1].type, 'id');28});29(0, _helpers.test)('qualified id & class name', 'h1#one.two', function (t, tree) {30 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');31 t.deepEqual(tree.nodes[0].nodes[1].type, 'id');32 t.deepEqual(tree.nodes[0].nodes[2].type, 'class');33});34(0, _helpers.test)('extraneous non-combinating whitespace', ' #h1 , #h2 ', function (t, tree) {35 t.deepEqual(tree.nodes[0].nodes[0].value, 'h1');36 t.deepEqual(tree.nodes[0].nodes[0].spaces.before, ' ');37 t.deepEqual(tree.nodes[0].nodes[0].spaces.after, ' ');38 t.deepEqual(tree.nodes[1].nodes[0].value, 'h2');39 t.deepEqual(tree.nodes[1].nodes[0].spaces.before, ' ');40 t.deepEqual(tree.nodes[1].nodes[0].spaces.after, ' ');41});42(0, _helpers.test)('Sass interpolation within a class', '.#{foo}', function (t, tree) {43 t.deepEqual(tree.nodes[0].nodes.length, 1);44 t.deepEqual(tree.nodes[0].nodes[0].type, 'class');45 t.deepEqual(tree.nodes[0].nodes[0].value, '#{foo}');46});47(0, _helpers.test)('Sass interpolation within an id', '#foo#{bar}', function (t, tree) {48 t.deepEqual(tree.nodes[0].nodes.length, 1);49 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');50 t.deepEqual(tree.nodes[0].nodes[0].value, 'foo#{bar}');51});52(0, _helpers.test)('Less interpolation within an id', '#foo@{bar}', function (t, tree) {53 t.deepEqual(tree.nodes[0].nodes.length, 1);54 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');55 t.deepEqual(tree.nodes[0].nodes[0].value, 'foo@{bar}');56});57(0, _helpers.test)('id selector with escaping', '#\\#test', function (t, tree) {58 t.deepEqual(tree.nodes[0].nodes[0].value, '#test');59 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');60 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\#test');61});62(0, _helpers.test)('id selector with escaping (2)', '#-a-b-c-', function (t, tree) {63 t.deepEqual(tree.nodes[0].nodes[0].value, '-a-b-c-');64 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');65});66(0, _helpers.test)('id selector with escaping (3)', '#u-m\\00002b', function (t, tree) {67 t.deepEqual(tree.nodes[0].nodes[0].value, 'u-m+');68 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');69 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'u-m\\00002b');70});71(0, _helpers.test)('id selector with escaping (4)', '#♥', function (t, tree) {72 t.deepEqual(tree.nodes[0].nodes[0].value, '♥');73 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');74});75(0, _helpers.test)('id selector with escaping (5)', '#©', function (t, tree) {76 t.deepEqual(tree.nodes[0].nodes[0].value, '©');77 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');78});79(0, _helpers.test)('id selector with escaping (6)', '#“‘’”', function (t, tree) {80 t.deepEqual(tree.nodes[0].nodes[0].value, '“‘’”');81 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');82});83(0, _helpers.test)('id selector with escaping (7)', '#☺☃', function (t, tree) {84 t.deepEqual(tree.nodes[0].nodes[0].value, '☺☃');85 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');86});87(0, _helpers.test)('id selector with escaping (8)', '#⌘⌥', function (t, tree) {88 t.deepEqual(tree.nodes[0].nodes[0].value, '⌘⌥');89 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');90});91(0, _helpers.test)('id selector with escaping (9)', '#𝄞♪♩♫♬', function (t, tree) {92 t.deepEqual(tree.nodes[0].nodes[0].value, '𝄞♪♩♫♬');93 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');94});95(0, _helpers.test)('id selector with escaping (10)', '#💩', function (t, tree) {96 t.deepEqual(tree.nodes[0].nodes[0].value, '💩');97 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');98});99(0, _helpers.test)('id selector with escaping (11)', '#\\?', function (t, tree) {100 t.deepEqual(tree.nodes[0].nodes[0].value, '?');101 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');102 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\?');103});104(0, _helpers.test)('id selector with escaping (12)', '#\\@', function (t, tree) {105 t.deepEqual(tree.nodes[0].nodes[0].value, '@');106 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');107 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\@');108});109(0, _helpers.test)('id selector with escaping (13)', '#\\.', function (t, tree) {110 t.deepEqual(tree.nodes[0].nodes[0].value, '.');111 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');112 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\.');113});114(0, _helpers.test)('id selector with escaping (14)', '#\\3A \\)', function (t, tree) {115 t.deepEqual(tree.nodes[0].nodes[0].value, ':)');116 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');117 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\3A \\)');118});119(0, _helpers.test)('id selector with escaping (15)', '#\\3A \\`\\(', function (t, tree) {120 t.deepEqual(tree.nodes[0].nodes[0].value, ':`(');121 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');122 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\3A \\`\\(');123});124(0, _helpers.test)('id selector with escaping (16)', '#\\31 23', function (t, tree) {125 t.deepEqual(tree.nodes[0].nodes[0].value, '123');126 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');127 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\31 23');128});129(0, _helpers.test)('id selector with escaping (17)', '#\\31 a2b3c', function (t, tree) {130 t.deepEqual(tree.nodes[0].nodes[0].value, '1a2b3c');131 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');132 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\31 a2b3c');133});134(0, _helpers.test)('id selector with escaping (18)', '#\\<p\\>', function (t, tree) {135 t.deepEqual(tree.nodes[0].nodes[0].value, '<p>');136 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');137 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\<p\\>');138});139(0, _helpers.test)('id selector with escaping (19)', '#\\<\\>\\<\\<\\<\\>\\>\\<\\>', function (t, tree) {140 t.deepEqual(tree.nodes[0].nodes[0].value, '<><<<>><>');141 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');142 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\<\\>\\<\\<\\<\\>\\>\\<\\>');143});144(0, _helpers.test)('id selector with escaping (20)', '#\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\[\\>\\+\\+\\+\\+\\+\\+\\+\\>\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\>\\+\\+\\+\\>\\+\\<\\<\\<\\<\\-\\]\\>\\+\\+\\.\\>\\+\\.\\+\\+\\+\\+\\+\\+\\+\\.\\.\\+\\+\\+\\.\\>\\+\\+\\.\\<\\<\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\.\\>\\.\\+\\+\\+\\.\\-\\-\\-\\-\\-\\-\\.\\-\\-\\-\\-\\-\\-\\-\\-\\.\\>\\+\\.\\>\\.', function (t, tree) {145 t.deepEqual(tree.nodes[0].nodes[0].value, '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.');146 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');147 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\[\\>\\+\\+\\+\\+\\+\\+\\+\\>\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\>\\+\\+\\+\\>\\+\\<\\<\\<\\<\\-\\]\\>\\+\\+\\.\\>\\+\\.\\+\\+\\+\\+\\+\\+\\+\\.\\.\\+\\+\\+\\.\\>\\+\\+\\.\\<\\<\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\+\\.\\>\\.\\+\\+\\+\\.\\-\\-\\-\\-\\-\\-\\.\\-\\-\\-\\-\\-\\-\\-\\-\\.\\>\\+\\.\\>\\.');148});149(0, _helpers.test)('id selector with escaping (21)', '#\\#', function (t, tree) {150 t.deepEqual(tree.nodes[0].nodes[0].value, '#');151 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');152 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\#');153});154(0, _helpers.test)('id selector with escaping (22)', '#\\#\\#', function (t, tree) {155 t.deepEqual(tree.nodes[0].nodes[0].value, '##');156 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');157 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\#\\#');158});159(0, _helpers.test)('id selector with escaping (23)', '#\\#\\.\\#\\.\\#', function (t, tree) {160 t.deepEqual(tree.nodes[0].nodes[0].value, '#.#.#');161 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');162 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\#\\.\\#\\.\\#');163});164(0, _helpers.test)('id selector with escaping (24)', '#\\_', function (t, tree) {165 t.deepEqual(tree.nodes[0].nodes[0].value, '_');166 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');167 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\_');168});169(0, _helpers.test)('id selector with escaping (25)', '#\\{\\}', function (t, tree) {170 t.deepEqual(tree.nodes[0].nodes[0].value, '{}');171 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');172 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\{\\}');173});174(0, _helpers.test)('id selector with escaping (26)', '#\\.fake\\-class', function (t, tree) {175 t.deepEqual(tree.nodes[0].nodes[0].value, '.fake-class');176 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');177 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\.fake\\-class');178});179(0, _helpers.test)('id selector with escaping (27)', '#foo\\.bar', function (t, tree) {180 t.deepEqual(tree.nodes[0].nodes[0].value, 'foo.bar');181 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');182 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'foo\\.bar');183});184(0, _helpers.test)('id selector with escaping (28)', '#\\3A hover', function (t, tree) {185 t.deepEqual(tree.nodes[0].nodes[0].value, ':hover');186 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');187 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\3A hover');188});189(0, _helpers.test)('id selector with escaping (29)', '#\\3A hover\\3A focus\\3A active', function (t, tree) {190 t.deepEqual(tree.nodes[0].nodes[0].value, ':hover:focus:active');191 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');192 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\3A hover\\3A focus\\3A active');193});194(0, _helpers.test)('id selector with escaping (30)', '#\\[attr\\=value\\]', function (t, tree) {195 t.deepEqual(tree.nodes[0].nodes[0].value, '[attr=value]');196 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');197 t.deepEqual(tree.nodes[0].nodes[0].raws.value, '\\[attr\\=value\\]');198});199(0, _helpers.test)('id selector with escaping (31)', '#f\\/o\\/o', function (t, tree) {200 t.deepEqual(tree.nodes[0].nodes[0].value, 'f/o/o');201 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');202 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\/o\\/o');203});204(0, _helpers.test)('id selector with escaping (32)', '#f\\\\o\\\\o', function (t, tree) {205 t.deepEqual(tree.nodes[0].nodes[0].value, 'f\\o\\o');206 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');207 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\\\o\\\\o');208});209(0, _helpers.test)('id selector with escaping (33)', '#f\\*o\\*o', function (t, tree) {210 t.deepEqual(tree.nodes[0].nodes[0].value, 'f*o*o');211 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');212 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\*o\\*o');213});214(0, _helpers.test)('id selector with escaping (34)', '#f\\!o\\!o', function (t, tree) {215 t.deepEqual(tree.nodes[0].nodes[0].value, 'f!o!o');216 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');217 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\!o\\!o');218});219(0, _helpers.test)('id selector with escaping (35)', '#f\\\'o\\\'o', function (t, tree) {220 t.deepEqual(tree.nodes[0].nodes[0].value, 'f\'o\'o');221 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');222 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\\'o\\\'o');223});224(0, _helpers.test)('id selector with escaping (36)', '#f\\~o\\~o', function (t, tree) {225 t.deepEqual(tree.nodes[0].nodes[0].value, 'f~o~o');226 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');227 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\~o\\~o');228});229(0, _helpers.test)('id selector with escaping (37)', '#f\\+o\\+o', function (t, tree) {230 t.deepEqual(tree.nodes[0].nodes[0].value, 'f+o+o');231 t.deepEqual(tree.nodes[0].nodes[0].type, 'id');232 t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'f\\+o\\+o');...

Full Screen

Full Screen

pseudos.js

Source:pseudos.js Github

copy

Full Screen

1"use strict";2var _helpers = require("./util/helpers");3(0, _helpers.test)('pseudo element (single colon)', 'h1:after', function (t, tree) {4 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');5 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');6 t.deepEqual(tree.nodes[0].nodes[1].value, ':after');7});8(0, _helpers.test)('pseudo element (double colon)', 'h1::after', function (t, tree) {9 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');10 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');11 t.deepEqual(tree.nodes[0].nodes[1].value, '::after');12});13(0, _helpers.test)('multiple pseudo elements', '*:target::before, a:after', function (t, tree) {14 t.deepEqual(tree.nodes[0].nodes[0].value, '*');15 t.deepEqual(tree.nodes[0].nodes[1].value, ':target');16 t.deepEqual(tree.nodes[0].nodes[2].value, '::before');17 t.deepEqual(tree.nodes[1].nodes[1].value, ':after');18});19(0, _helpers.test)('negation pseudo element', 'h1:not(.heading)', function (t, tree) {20 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');21 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading');22});23(0, _helpers.test)('negation pseudo element (2)', 'h1:not(.heading, .title, .content)', function (t, tree) {24 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');25 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading');26 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].value, 'title');27 t.deepEqual(tree.nodes[0].nodes[1].nodes[2].nodes[0].value, 'content');28});29(0, _helpers.test)('negation pseudo element (3)', 'h1:not(.heading > .title) > h1', function (t, tree) {30 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading');31 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[1].value, '>');32 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[2].value, 'title');33 t.deepEqual(tree.nodes[0].nodes[2].value, '>');34 t.deepEqual(tree.nodes[0].nodes[3].value, 'h1');35});36(0, _helpers.test)('negation pseudo element (4)', 'h1:not(h2:not(h3))', function (t, tree) {37 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[1].nodes[0].nodes[0].value, 'h3');38 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[1].nodes[0].nodes[0].parent.type, 'selector');39});40(0, _helpers.test)('pseudo class in the middle of a selector', 'a:link.external', function (t, tree) {41 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');42 t.deepEqual(tree.nodes[0].nodes[0].value, 'a');43 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');44 t.deepEqual(tree.nodes[0].nodes[1].value, ':link');45 t.deepEqual(tree.nodes[0].nodes[2].type, 'class');46 t.deepEqual(tree.nodes[0].nodes[2].value, 'external');47});48(0, _helpers.test)('extra whitespace inside parentheses', 'a:not( h2 )', function (t, tree) {49 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'h2');50 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].spaces.after, ' ');51 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].spaces.before, ' ');52});53(0, _helpers.test)('escaped numbers in class name with pseudo', 'a:before.\\31\\ 0', function (t, tree) {54 t.deepEqual(tree.nodes[0].nodes[2].type, 'class');55 t.deepEqual(tree.nodes[0].nodes[2].value, '1 0');56 t.deepEqual(tree.nodes[0].nodes[2].raws.value, '\\31\\ 0');57});58(0, _helpers.test)('nested pseudo', '.btn-group>.btn:last-child:not(:first-child)', function (t, tree) {59 t.deepEqual(tree.nodes[0].nodes[4].value, ':not');60});61(0, _helpers.test)('extraneous non-combinating whitespace', ' h1:after , h2:after ', function (t, tree) {62 t.deepEqual(tree.nodes[0].nodes[0].spaces.before, ' ');63 t.deepEqual(tree.nodes[0].nodes[1].value, ':after');64 t.deepEqual(tree.nodes[0].nodes[1].spaces.after, ' ');65 t.deepEqual(tree.nodes[0].nodes[0].spaces.before, ' ');66 t.deepEqual(tree.nodes[1].nodes[1].value, ':after');67 t.deepEqual(tree.nodes[1].nodes[1].spaces.after, ' ');68});69(0, _helpers.test)('negation pseudo element with quotes', 'h1:not(".heading")', function (t, tree) {70 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');71 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, '".heading"');72});73(0, _helpers.test)('negation pseudo element with single quotes', "h1:not('.heading')", function (t, tree) {74 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');75 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, "'.heading'");76});77(0, _helpers.test)('Issue #116', "svg:not(:root)", function (t, tree) {78 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');79 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, ':root');80});81(0, _helpers.test)('alone pseudo class', ':root', function (t, tree) {82 t.deepEqual(tree.nodes[0].nodes[0].type, 'pseudo');83 t.deepEqual(tree.nodes[0].nodes[0].value, ':root');84});85(0, _helpers.test)('non standard pseudo (@custom-selector)', ":--foobar, a", function (t, tree) {86 t.deepEqual(tree.nodes[0].nodes[0].value, ':--foobar');87 t.deepEqual(tree.nodes[0].nodes[0].type, 'pseudo');88 t.deepEqual(tree.nodes[1].nodes[0].value, 'a');89 t.deepEqual(tree.nodes[1].nodes[0].type, 'tag');90});91(0, _helpers.test)('non standard pseudo (@custom-selector) (1)', "a, :--foobar", function (t, tree) {92 t.deepEqual(tree.nodes[0].nodes[0].value, 'a');93 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');94 t.deepEqual(tree.nodes[1].nodes[0].value, ':--foobar');95 t.deepEqual(tree.nodes[1].nodes[0].type, 'pseudo');96});97(0, _helpers.test)('current pseudo class', ':current(p, li, dt, dd)', function (t, tree) {98 t.deepEqual(tree.nodes[0].nodes[0].type, 'pseudo');99 t.deepEqual(tree.nodes[0].nodes[0].value, ':current');100 t.deepEqual(tree.nodes[0].nodes[0].nodes[0].nodes[0].type, 'tag');101 t.deepEqual(tree.nodes[0].nodes[0].nodes[0].nodes[0].value, 'p');102 t.deepEqual(tree.nodes[0].nodes[0].nodes[1].nodes[0].type, 'tag');103 t.deepEqual(tree.nodes[0].nodes[0].nodes[1].nodes[0].value, 'li');104 t.deepEqual(tree.nodes[0].nodes[0].nodes[2].nodes[0].type, 'tag');105 t.deepEqual(tree.nodes[0].nodes[0].nodes[2].nodes[0].value, 'dt');106 t.deepEqual(tree.nodes[0].nodes[0].nodes[3].nodes[0].type, 'tag');107 t.deepEqual(tree.nodes[0].nodes[0].nodes[3].nodes[0].value, 'dd');108});109(0, _helpers.test)('is pseudo class', ':is(p, li, dt, dd)', function (t, tree) {110 t.deepEqual(tree.nodes[0].nodes[0].type, 'pseudo');111 t.deepEqual(tree.nodes[0].nodes[0].value, ':is');112 t.deepEqual(tree.nodes[0].nodes[0].nodes[0].nodes[0].type, 'tag');113 t.deepEqual(tree.nodes[0].nodes[0].nodes[0].nodes[0].value, 'p');114 t.deepEqual(tree.nodes[0].nodes[0].nodes[1].nodes[0].type, 'tag');115 t.deepEqual(tree.nodes[0].nodes[0].nodes[1].nodes[0].value, 'li');116 t.deepEqual(tree.nodes[0].nodes[0].nodes[2].nodes[0].type, 'tag');117 t.deepEqual(tree.nodes[0].nodes[0].nodes[2].nodes[0].value, 'dt');118 t.deepEqual(tree.nodes[0].nodes[0].nodes[3].nodes[0].type, 'tag');119 t.deepEqual(tree.nodes[0].nodes[0].nodes[3].nodes[0].value, 'dd');120});121(0, _helpers.test)('is pseudo class with namespace', '*|*:is(:hover, :focus) ', function (t, tree) {122 t.deepEqual(tree.nodes[0].nodes[0].type, 'universal');123 t.deepEqual(tree.nodes[0].nodes[0].namespace, '*');124 t.deepEqual(tree.nodes[0].nodes[0].value, '*');125 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');126 t.deepEqual(tree.nodes[0].nodes[1].value, ':is');127 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].type, 'pseudo');128 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, ':hover');129 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].type, 'pseudo');130 t.deepEqual(tree.nodes[0].nodes[1].nodes[1].nodes[0].value, ':focus');131});132(0, _helpers.test)('has pseudo class', 'a:has(> img)', function (t, tree) {133 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');134 t.deepEqual(tree.nodes[0].nodes[0].value, 'a');135 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');136 t.deepEqual(tree.nodes[0].nodes[1].value, ':has');137 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].type, 'combinator');138 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, '>');139 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[1].type, 'tag');140 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[1].value, 'img');141});142(0, _helpers.test)('where pseudo class', 'a:where(:not(:hover))', function (t, tree) {143 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');144 t.deepEqual(tree.nodes[0].nodes[0].value, 'a');145 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');146 t.deepEqual(tree.nodes[0].nodes[1].value, ':where');147 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].type, 'pseudo');148 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, ':not');149 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[0].nodes[0].type, 'pseudo');150 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[0].nodes[0].value, ':hover');151});152(0, _helpers.test)('nested pseudo classes', "section:not( :has(h1, h2 ) )", function (t, tree) {153 t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');154 t.deepEqual(tree.nodes[0].nodes[0].value, 'section');155 t.deepEqual(tree.nodes[0].nodes[1].type, 'pseudo');156 t.deepEqual(tree.nodes[0].nodes[1].value, ':not');157 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].type, 'pseudo');158 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, ':has');159 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[0].nodes[0].type, 'tag');160 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[0].nodes[0].value, 'h1');161 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[1].nodes[0].type, 'tag');162 t.deepEqual(tree.nodes[0].nodes[1].nodes[0].nodes[0].nodes[1].nodes[0].value, 'h2');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({3}, function () {4 mb.post('/imposters', {5 stubs: [{6 responses: [{7 is: {8 headers: {9 },10 body: JSON.stringify({11 })12 }13 }]14 }]15 }, function () {16 console.log('Imposter created');17 });18});19mb.del('/imposters', function () {20 console.log('Imposter deleted');21});22mb.get('/imposters', function (data) {23 console.log('Imposter data', data);24});25mb.get('/imposters/3000', function (data) {26 console.log('Imposter data', data);27});28mb.get('/imposters/3000/requests', function (data) {29 console.log('Imposter data', data);30});31mb.create({32}, function () {33 mb.post('/imposters', {34 stubs: [{35 responses: [{36 is: {37 headers: {38 },39 body: JSON.stringify({40 })41 }42 }]43 }]44 }, function () {45 console.log('Imposter created');46 });47});48mb.del('/imposters', function () {49 console.log('Imposter deleted');50});51mb.get('/imposters', function (data) {52 console.log('Imposter data', data);53});54mb.get('/imposters/3000', function (data) {55 console.log('Imposter data',

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var logger = require('winston');3var port = 2525;4mb.create({port: port, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function (error) {5 if (error) {6 logger.error(error);7 }8 else {9 logger.info('Running on port ' + port);10 }11});12{13 {14 {15 "is": {16 "headers": {17 },18 "body": "{\"id\": 1, \"name\": \"John\"}"19 }20 }21 }22}23{"id": 1, "name": "John"}

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const port = 2525;3mb.create(port)4 .then(() => {5 console.log(`Running on port ${port}`);6 return mb.get('/imposters');7 })8 .then((response) => {9 console.log(response.body);10 })11 .catch((error) => {12 console.error(error);13 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const mbHelper = require('mountebank-helper');3const mbPort = 2525;4mbHelper.mbStart(mbPort, () => {5 mbHelper.mbDeleteAllImposters(mbPort, () => {6 mbHelper.mbCreateImposter(mbPort, 3000, 'http', () => {7 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/', 200, { message: 'Hello World' }, () => {8 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test', 200, { message: 'Hello Test' }, () => {9 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test2', 200, { message: 'Hello Test 2' }, () => {10 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test3', 200, { message: 'Hello Test 3' }, () => {11 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test4', 200, { message: 'Hello Test 4' }, () => {12 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test5', 200, { message: 'Hello Test 5' }, () => {13 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test6', 200, { message: 'Hello Test 6' }, () => {14 mbHelper.mbCreateStub(mbPort, 3000, 'GET', '/test7', 200, { message: 'Hello Test 7' }, () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2mb.start()3 .then(function(){4 console.log('mountebank started');5 })6 .catch(function(err){7 console.log('error starting mountebank', err);8 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const assert = require('assert');3const fetch = require('node-fetch');4const createImposter = (port, stubs) => {5 const imposter = {6 };7 return mb.create(imposter);8};9const deleteImposter = (port) => {10 return mb.delete(port);11};12const createStub = (predicate, response) => {13 return {14 {15 is: {16 headers: {17 },18 },19 },20 {21 equals: {22 },23 },24 };25};26const test = async (port, predicate, response) => {27 const res = await fetch(url);28 const json = await res.json();29 assert.deepEqual(json, response);30};31createImposter(3000, [32 createStub('/test', { msg: 'test' }),33 createStub('/test1', { msg: 'test1' }),34 createStub('/test2', { msg: 'test2' }),35]).then(() => {36 test(3000, '/test', { msg: 'test' })37 .then(() => {38 return test(3000, '/test1', { msg: 'test1' });39 })40 .then(() => {41 return test(3000, '/test2', { msg: 'test2' });42 })43 .then(() => {44 return deleteImposter(3000);45 })46 .catch((err) => {47 console.error(err);48 });49});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful