How to use enqueue method in wpt

Best JavaScript code snippet using wpt

transaction.js

Source:transaction.js Github

copy

Full Screen

1var request = require("request");2var qs = require("querystring");3var uuid = require("uuid");4var should = require("should");5var sinon = require("sinon");6var url = require("url");7var ua = require("../lib/index.js");8var utils = require("../lib/utils.js")9var config = require("../lib/config.js")10describe("ua", function () {11 describe("#transaction", function () {12 var _enqueue;13 beforeEach(function () {14 _enqueue = sinon.stub(ua.Visitor.prototype, "_enqueue", function (type, params, fn) {15 if (fn) {16 (typeof fn).should.equal('function', "#_enqueue should receive a callback")17 fn();18 }19 return this;20 });21 });22 afterEach(function () {23 _enqueue.restore()24 });25 it("should be available via the #t shortcut", function () {26 var visitor = ua()27 visitor.t.should.equal(visitor.transaction)28 });29 it("should accept arguments (transaction)", function () {30 var transaction = Math.random().toString();31 var visitor = ua()32 var result = visitor.transaction(transaction);33 visitor._context = result._context;34 result.should.eql(visitor, "should return a visitor that is identical except for the context");35 result.should.be.instanceof(ua.Visitor);36 result._context.should.eql(_enqueue.args[0][1], "the transaction params should be persisted as the context of the visitor clone")37 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");38 _enqueue.args[0][0].should.equal("transaction");39 _enqueue.args[0][1].should.have.keys("ti")40 _enqueue.args[0][1].ti.should.equal(transaction);41 });42 it("should accept arguments (transaction, fn)", function () {43 var transaction = Math.random().toString();44 var fn = sinon.spy()45 ua().transaction(transaction, fn);46 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");47 _enqueue.args[0][0].should.equal("transaction");48 _enqueue.args[0][1].should.have.keys("ti")49 _enqueue.args[0][1].ti.should.equal(transaction);50 fn.calledOnce.should.equal(true, "callback should have been called once")51 });52 it("should accept arguments (transaction, revenue)", function () {53 var transaction = Math.random().toString();54 var revenue = Math.random();55 ua().transaction(transaction, revenue);56 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");57 _enqueue.args[0][0].should.equal("transaction");58 _enqueue.args[0][1].should.have.keys("ti", "tr")59 _enqueue.args[0][1].ti.should.equal(transaction);60 _enqueue.args[0][1].tr.should.equal(revenue);61 });62 it("should accept arguments (transaction, revenue, fn)", function () {63 var transaction = Math.random().toString();64 var revenue = Math.random();65 var fn = sinon.spy()66 ua().transaction(transaction, revenue, fn);67 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");68 _enqueue.args[0][0].should.equal("transaction");69 _enqueue.args[0][1].should.have.keys("ti", "tr")70 _enqueue.args[0][1].ti.should.equal(transaction);71 _enqueue.args[0][1].tr.should.equal(revenue);72 fn.calledOnce.should.equal(true, "callback should have been called once")73 });74 it("should accept arguments (transaction, revenue, shipping)", function () {75 var transaction = Math.random().toString();76 var revenue = Math.random();77 var shipping = Math.random();78 ua().transaction(transaction, revenue, shipping);79 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");80 _enqueue.args[0][0].should.equal("transaction");81 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts")82 _enqueue.args[0][1].ti.should.equal(transaction);83 _enqueue.args[0][1].tr.should.equal(revenue);84 _enqueue.args[0][1].ts.should.equal(shipping);85 });86 it("should accept arguments (transaction, revenue, shipping, fn)", function () {87 var transaction = Math.random().toString();88 var revenue = Math.random();89 var shipping = Math.random();90 var fn = sinon.spy()91 ua().transaction(transaction, revenue, shipping, fn);92 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");93 _enqueue.args[0][0].should.equal("transaction");94 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts")95 _enqueue.args[0][1].ti.should.equal(transaction);96 _enqueue.args[0][1].tr.should.equal(revenue);97 _enqueue.args[0][1].ts.should.equal(shipping);98 fn.calledOnce.should.equal(true, "callback should have been called once")99 });100 it("should accept arguments (transaction, revenue, shipping, tax)", function () {101 var transaction = Math.random().toString();102 var revenue = Math.random();103 var shipping = Math.random();104 var tax = Math.random();105 ua().transaction(transaction, revenue, shipping, tax);106 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");107 _enqueue.args[0][0].should.equal("transaction");108 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt")109 _enqueue.args[0][1].ti.should.equal(transaction);110 _enqueue.args[0][1].tr.should.equal(revenue);111 _enqueue.args[0][1].ts.should.equal(shipping);112 _enqueue.args[0][1].tt.should.equal(tax);113 });114 it("should accept arguments (transaction, revenue, shipping, tax, fn)", function () {115 var transaction = Math.random().toString();116 var revenue = Math.random();117 var shipping = Math.random();118 var tax = Math.random();119 var fn = sinon.spy()120 ua().transaction(transaction, revenue, shipping, tax, fn);121 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");122 _enqueue.args[0][0].should.equal("transaction");123 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt")124 _enqueue.args[0][1].ti.should.equal(transaction);125 _enqueue.args[0][1].tr.should.equal(revenue);126 _enqueue.args[0][1].ts.should.equal(shipping);127 _enqueue.args[0][1].tt.should.equal(tax);128 fn.calledOnce.should.equal(true, "callback should have been called once")129 });130 it("should accept arguments (transaction, revenue, shipping, tax, affiliation)", function () {131 var transaction = Math.random().toString();132 var revenue = Math.random();133 var shipping = Math.random();134 var tax = Math.random();135 var affiliation = Math.random().toString();136 ua().transaction(transaction, revenue, shipping, tax, affiliation);137 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");138 _enqueue.args[0][0].should.equal("transaction");139 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta")140 _enqueue.args[0][1].ti.should.equal(transaction);141 _enqueue.args[0][1].tr.should.equal(revenue);142 _enqueue.args[0][1].ts.should.equal(shipping);143 _enqueue.args[0][1].tt.should.equal(tax);144 _enqueue.args[0][1].ta.should.equal(affiliation);145 });146 it("should accept arguments (transaction, revenue, shipping, tax, affiliation, fn)", function () {147 var transaction = Math.random().toString();148 var revenue = Math.random();149 var shipping = Math.random();150 var tax = Math.random();151 var affiliation = Math.random().toString();152 var fn = sinon.spy()153 ua().transaction(transaction, revenue, shipping, tax, affiliation, fn);154 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");155 _enqueue.args[0][0].should.equal("transaction");156 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta")157 _enqueue.args[0][1].ti.should.equal(transaction);158 _enqueue.args[0][1].tr.should.equal(revenue);159 _enqueue.args[0][1].ts.should.equal(shipping);160 _enqueue.args[0][1].tt.should.equal(tax);161 _enqueue.args[0][1].ta.should.equal(affiliation);162 fn.calledOnce.should.equal(true, "callback should have been called once")163 });164 it("should accept arguments (transaction, revenue, shipping, tax, affiliation, params)", function () {165 var transaction = Math.random().toString();166 var revenue = Math.random();167 var shipping = Math.random();168 var tax = Math.random();169 var affiliation = Math.random().toString();170 var params = {p: Math.random().toString()}171 ua().transaction(transaction, revenue, shipping, tax, affiliation, params);172 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");173 _enqueue.args[0][0].should.equal("transaction");174 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta", "p")175 _enqueue.args[0][1].ti.should.equal(transaction);176 _enqueue.args[0][1].tr.should.equal(revenue);177 _enqueue.args[0][1].ts.should.equal(shipping);178 _enqueue.args[0][1].tt.should.equal(tax);179 _enqueue.args[0][1].ta.should.equal(affiliation);180 _enqueue.args[0][1].p.should.equal(params.p);181 });182 it("should accept arguments (transaction, revenue, shipping, tax, affiliation, params, fn)", function () {183 var transaction = Math.random().toString();184 var revenue = Math.random();185 var shipping = Math.random();186 var tax = Math.random();187 var affiliation = Math.random().toString();188 var params = {p: Math.random().toString()}189 var fn = sinon.spy()190 ua().transaction(transaction, revenue, shipping, tax, affiliation, params, fn);191 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");192 _enqueue.args[0][0].should.equal("transaction");193 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta", "p")194 _enqueue.args[0][1].ti.should.equal(transaction);195 _enqueue.args[0][1].tr.should.equal(revenue);196 _enqueue.args[0][1].ts.should.equal(shipping);197 _enqueue.args[0][1].tt.should.equal(tax);198 _enqueue.args[0][1].ta.should.equal(affiliation);199 _enqueue.args[0][1].p.should.equal(params.p);200 fn.calledOnce.should.equal(true, "callback should have been called once")201 });202 it("should accept arguments (params)", function () {203 var params = {204 ti: Math.random().toString(),205 tr: Math.random(),206 ts: Math.random(),207 tt: Math.random(),208 ta: Math.random().toString(),209 p: Math.random().toString(),210 empty: null // Should be removed211 };212 var json = JSON.stringify(params);213 var visitor = ua()214 var result = visitor.transaction(params);215 visitor._context = result._context;216 result.should.eql(visitor, "should return a visitor that is identical except for the context");217 result.should.be.instanceof(ua.Visitor);218 result._context.should.eql(_enqueue.args[0][1], "the transaction params should be persisted as the context of the visitor clone")219 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");220 _enqueue.args[0][0].should.equal("transaction");221 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta", "p")222 _enqueue.args[0][1].ti.should.equal(params.ti);223 _enqueue.args[0][1].tr.should.equal(params.tr);224 _enqueue.args[0][1].ts.should.equal(params.ts);225 _enqueue.args[0][1].tt.should.equal(params.tt);226 _enqueue.args[0][1].ta.should.equal(params.ta);227 _enqueue.args[0][1].p.should.equal(params.p);228 JSON.stringify(params).should.equal(json, "params should not have changed");229 });230 it("should accept arguments (params, fn)", function () {231 var params = {232 ti: Math.random().toString(),233 tr: Math.random(),234 ts: Math.random(),235 tt: Math.random(),236 ta: Math.random().toString(),237 p: Math.random().toString()238 };239 var fn = sinon.spy()240 var visitor = ua()241 var result = visitor.transaction(params, fn);242 visitor._context = result._context;243 result.should.eql(visitor, "should return a visitor that is identical except for the context");244 result.should.be.instanceof(ua.Visitor);245 result._context.should.eql(_enqueue.args[0][1], "the transaction params should be persisted as the context of the visitor clone")246 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");247 _enqueue.args[0][0].should.equal("transaction");248 _enqueue.args[0][1].should.have.keys("ti", "tr", "ts", "tt", "ta", "p")249 _enqueue.args[0][1].ti.should.equal(params.ti);250 _enqueue.args[0][1].tr.should.equal(params.tr);251 _enqueue.args[0][1].ts.should.equal(params.ts);252 _enqueue.args[0][1].tt.should.equal(params.tt);253 _enqueue.args[0][1].ta.should.equal(params.ta);254 _enqueue.args[0][1].p.should.equal(params.p);255 fn.calledOnce.should.equal(true, "callback should have been called once")256 });257 it("should fail without transaction ID", function () {258 var fn = sinon.spy()259 var visitor = ua()260 var result = visitor.transaction(null, fn);261 visitor._context = result._context;262 result.should.eql(visitor, "should return a visitor that is identical except for the context");263 result.should.be.instanceof(ua.Visitor);264 result._context.should.eql({}, "the transaction params should not be persisted")265 _enqueue.called.should.equal(false, "#_enqueue should have not been called once");266 fn.calledOnce.should.equal(true, "callback should have been called once");267 fn.args[0][0].should.be.instanceof(Error);268 fn.thisValues[0].should.equal(visitor);269 });270 });...

Full Screen

Full Screen

event.js

Source:event.js Github

copy

Full Screen

1var request = require("request");2var qs = require("querystring");3var uuid = require("uuid");4var should = require("should");5var sinon = require("sinon");6var url = require("url");7var ua = require("../lib/index.js");8var utils = require("../lib/utils.js")9var config = require("../lib/config.js")10describe("ua", function () {11 describe("#event", function () {12 var _enqueue;13 beforeEach(function () {14 _enqueue = sinon.stub(ua.Visitor.prototype, "_enqueue", function () {15 if (arguments.length === 3 && typeof arguments[2] === 'function') {16 arguments[2]();17 }18 return this;19 });20 });21 afterEach(function () {22 _enqueue.restore()23 });24 it("should be available via the #e shortcut", function () {25 var visitor = ua()26 visitor.e.should.equal(visitor.event)27 });28 it("should accept arguments (category, action)", function () {29 var category = Math.random().toString();30 var action = Math.random().toString();31 var visitor = ua()32 var result = visitor.event(category, action);33 visitor._context = result._context;34 result.should.eql(visitor, "should return a visitor that is identical except for the context");35 result.should.be.instanceof(ua.Visitor);36 result._context.should.eql(_enqueue.args[0][1], "the pageview params should be persisted as the context of the visitor clone")37 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");38 _enqueue.args[0][0].should.equal("event");39 _enqueue.args[0][1].should.have.keys("ec", "ea")40 _enqueue.args[0][1].ec.should.equal(category);41 _enqueue.args[0][1].ea.should.equal(action);42 });43 it("should accept arguments (category, action, fn)", function () {44 var category = Math.random().toString();45 var action = Math.random().toString();46 var fn = sinon.spy()47 ua().event(category, action, fn);48 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");49 _enqueue.args[0][0].should.equal("event");50 _enqueue.args[0][1].should.have.keys("ec", "ea")51 _enqueue.args[0][1].ec.should.equal(category);52 _enqueue.args[0][1].ea.should.equal(action);53 fn.calledOnce.should.equal(true, "callback should have been called once")54 });55 it("should accept arguments (category, action, label)", function () {56 var category = Math.random().toString();57 var action = Math.random().toString();58 var label = Math.random().toString();59 ua().event(category, action, label);60 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");61 _enqueue.args[0][0].should.equal("event");62 _enqueue.args[0][1].should.have.keys("ec", "ea", "el")63 _enqueue.args[0][1].ec.should.equal(category);64 _enqueue.args[0][1].ea.should.equal(action);65 _enqueue.args[0][1].el.should.equal(label);66 });67 it("should accept arguments (category, action, label, fn)", function () {68 var category = Math.random().toString();69 var action = Math.random().toString();70 var label = Math.random().toString();71 var fn = sinon.spy()72 ua().event(category, action, label, fn);73 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");74 _enqueue.args[0][0].should.equal("event");75 _enqueue.args[0][1].should.have.keys("ec", "ea", "el")76 _enqueue.args[0][1].ec.should.equal(category);77 _enqueue.args[0][1].ea.should.equal(action);78 _enqueue.args[0][1].el.should.equal(label);79 fn.calledOnce.should.equal(true, "callback should have been called once")80 });81 it("should accept arguments (category, action, label, value)", function () {82 var category = Math.random().toString();83 var action = Math.random().toString();84 var label = Math.random().toString();85 var value = Math.random();86 ua().event(category, action, label, value);87 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");88 _enqueue.args[0][0].should.equal("event");89 _enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev")90 _enqueue.args[0][1].ec.should.equal(category);91 _enqueue.args[0][1].ea.should.equal(action);92 _enqueue.args[0][1].el.should.equal(label);93 _enqueue.args[0][1].ev.should.equal(value);94 });95 it("should accept arguments (category, action, label, value, fn)", function () {96 var category = Math.random().toString();97 var action = Math.random().toString();98 var label = Math.random().toString();99 var value = Math.random();100 var fn = sinon.spy()101 ua().event(category, action, label, value, fn);102 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");103 _enqueue.args[0][0].should.equal("event");104 _enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev")105 _enqueue.args[0][1].ec.should.equal(category);106 _enqueue.args[0][1].ea.should.equal(action);107 _enqueue.args[0][1].el.should.equal(label);108 _enqueue.args[0][1].ev.should.equal(value);109 fn.calledOnce.should.equal(true, "callback should have been called once")110 });111 it("should accept arguments (category, action, label, value, params, fn)", function () {112 var category = Math.random().toString();113 var action = Math.random().toString();114 var label = Math.random().toString();115 var value = Math.random();116 var params = {"p": "/" + Math.random()}117 var fn = sinon.spy()118 ua().event(category, action, label, value, params, fn);119 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");120 _enqueue.args[0][0].should.equal("event");121 _enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")122 _enqueue.args[0][1].ec.should.equal(category);123 _enqueue.args[0][1].ea.should.equal(action);124 _enqueue.args[0][1].el.should.equal(label);125 _enqueue.args[0][1].ev.should.equal(value);126 _enqueue.args[0][1].p.should.equal(params.p);127 fn.calledOnce.should.equal(true, "callback should have been called once")128 });129 it("should accept arguments (params)", function () {130 var params = {131 ec: Math.random().toString(),132 ea: Math.random().toString(),133 el: Math.random().toString(),134 ev: Math.random(),135 "p": "/" + Math.random(),136 "empty": null137 }138 var json = JSON.stringify(params)139 ua().event(params);140 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");141 _enqueue.args[0][0].should.equal("event");142 _enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")143 _enqueue.args[0][1].ec.should.equal(params.ec);144 _enqueue.args[0][1].ea.should.equal(params.ea);145 _enqueue.args[0][1].el.should.equal(params.el);146 _enqueue.args[0][1].ev.should.equal(params.ev);147 _enqueue.args[0][1].p.should.equal(params.p);148 JSON.stringify(params).should.equal(json, "params should not have been modified")149 });150 it("should accept arguments (params, fn)", function () {151 var params = {152 ec: Math.random().toString(),153 ea: Math.random().toString(),154 el: Math.random().toString(),155 ev: Math.random(),156 "p": "/" + Math.random()157 }158 var fn = sinon.spy()159 ua().event(params, fn);160 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");161 _enqueue.args[0][0].should.equal("event");162 _enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")163 _enqueue.args[0][1].ec.should.equal(params.ec);164 _enqueue.args[0][1].ea.should.equal(params.ea);165 _enqueue.args[0][1].el.should.equal(params.el);166 _enqueue.args[0][1].ev.should.equal(params.ev);167 _enqueue.args[0][1].p.should.equal(params.p);168 fn.calledOnce.should.equal(true, "callback should have been called once")169 });170 it("should use the dp attribute as p for providing a event path", function () {171 var params = {172 ec: Math.random().toString(),173 ea: Math.random().toString(),174 "dp": "/" + Math.random(),175 }176 var json = JSON.stringify(params)177 ua().event(params);178 _enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");179 _enqueue.args[0][0].should.equal("event");180 _enqueue.args[0][1].should.have.keys("ec", "ea", "p")181 _enqueue.args[0][1].ec.should.equal(params.ec);182 _enqueue.args[0][1].ea.should.equal(params.ea);183 _enqueue.args[0][1].p.should.equal(params.dp);184 JSON.stringify(params).should.equal(json, "params should not have been modified")185 });186 it("should allow daisy-chaining and re-using parameters", function () {187 var params = {188 ec: Math.random().toString(),189 ea: Math.random().toString(),190 el: Math.random().toString(),191 ev: Math.random()192 }193 ua().event(params).event()194 _enqueue.calledTwice.should.equal(true, "#_enqueue should have been called twice, once for each event");195 _enqueue.args[0][0].should.equal(_enqueue.args[1][0]);196 _enqueue.args[0][1].ec.should.equal(_enqueue.args[1][1].ec);197 _enqueue.args[0][1].ea.should.equal(_enqueue.args[1][1].ea);198 _enqueue.args[0][1].el.should.equal(_enqueue.args[1][1].el);199 _enqueue.args[0][1].ev.should.equal(_enqueue.args[1][1].ev);200 });201 it("should extend and overwrite params when daisy-chaining", function () {202 var params = {203 ec: Math.random().toString(),204 ea: Math.random().toString(),205 el: Math.random().toString(),206 ev: Math.random()207 }208 var category = Math.random().toString();209 ua().event(params).event(category)210 _enqueue.calledTwice.should.equal(true, "#_enqueue should have been called twice, once for each event");211 _enqueue.args[0][0].should.equal(_enqueue.args[1][0]);212 _enqueue.args[0][1].ea.should.equal(_enqueue.args[1][1].ea);213 _enqueue.args[0][1].el.should.equal(_enqueue.args[1][1].el);214 _enqueue.args[0][1].ev.should.equal(_enqueue.args[1][1].ev);215 _enqueue.args[0][1].ec.should.equal(params.ec);216 _enqueue.args[1][1].ec.should.equal(category);217 });218 it("should re-use the path when daisy-chained to a pageview", function () {219 var path = "/" + Math.random()220 var params = {221 ec: Math.random().toString(),222 ea: Math.random().toString(),223 el: Math.random().toString(),224 ev: Math.random()225 }226 ua().pageview(path).event(params).event(params);227 _enqueue.calledThrice.should.equal(true, "#_enqueue should have been called twice, once for the pageview, once for the pageview");228 _enqueue.args[1][1].p.should.equal(path)229 _enqueue.args[2][1].p.should.equal(path)230 })231 it("should fail without event category", function () {232 var fn = sinon.spy()233 var action = Math.random().toString();234 var visitor = ua()235 var result = visitor.event(null, action, fn);236 visitor._context = result._context;237 result.should.eql(visitor, "should return a visitor that is identical except for the context");238 result.should.be.instanceof(ua.Visitor);239 result._context.should.eql({}, "the transaction params should not be persisted")240 _enqueue.called.should.equal(false, "#_enqueue should have not been called once");241 fn.calledOnce.should.equal(true, "callback should have been called once");242 fn.args[0][0].should.be.instanceof(Error);243 fn.thisValues[0].should.equal(visitor);244 });245 it("should fail without event action", function () {246 var fn = sinon.spy()247 var category = Math.random().toString();248 var visitor = ua()249 var result = visitor.event(category, null, fn);250 visitor._context = result._context;251 result.should.eql(visitor, "should return a visitor that is identical except for the context");252 result.should.be.instanceof(ua.Visitor);253 result._context.should.eql({}, "the transaction params should not be persisted")254 _enqueue.called.should.equal(false, "#_enqueue should have not been called once");255 fn.calledOnce.should.equal(true, "callback should have been called once");256 fn.args[0][0].should.be.instanceof(Error);257 fn.thisValues[0].should.equal(visitor);258 });259 });...

Full Screen

Full Screen

glados-ip4.js

Source:glados-ip4.js Github

copy

Full Screen

...8 alert(msg);9 };10 this.afterStartup = function() {11 // Force scrolling with a few 'help' commands.12 _KernelInputQueue.enqueue('h');13 _KernelInputQueue.enqueue('e');14 _KernelInputQueue.enqueue('l');15 _KernelInputQueue.enqueue('p');16 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);17 _KernelInputQueue.enqueue('h');18 _KernelInputQueue.enqueue('e');19 _KernelInputQueue.enqueue('l');20 _KernelInputQueue.enqueue('p');21 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);22 // Test the 'ver' command.23 _KernelInputQueue.enqueue('v');24 _KernelInputQueue.enqueue('e');25 _KernelInputQueue.enqueue('r');26 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);27 // Test the 'date' command.28 _KernelInputQueue.enqueue('d');29 _KernelInputQueue.enqueue('a');30 _KernelInputQueue.enqueue('t');31 _KernelInputQueue.enqueue('e');32 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);33 // Test the 'whereami' command.34 _KernelInputQueue.enqueue('w');35 _KernelInputQueue.enqueue('h');36 _KernelInputQueue.enqueue('e');37 _KernelInputQueue.enqueue('r');38 _KernelInputQueue.enqueue('e');39 _KernelInputQueue.enqueue('a');40 _KernelInputQueue.enqueue('m');41 _KernelInputQueue.enqueue('i');42 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);43 44 // Test the 'status' command.45 _KernelInputQueue.enqueue('S');46 _KernelInputQueue.enqueue('t');47 _KernelInputQueue.enqueue('A');48 _KernelInputQueue.enqueue('t');49 _KernelInputQueue.enqueue('U');50 _KernelInputQueue.enqueue('s');51 _KernelInputQueue.enqueue(' ');52 _KernelInputQueue.enqueue('F');53 _KernelInputQueue.enqueue('i');54 _KernelInputQueue.enqueue('N');55 _KernelInputQueue.enqueue('a');56 _KernelInputQueue.enqueue('L');57 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);58 59 // Load some invalid user program code60 document.getElementById("taProgramInput").value="This is NOT hex.";61 _KernelInputQueue.enqueue('l');62 _KernelInputQueue.enqueue('o');63 _KernelInputQueue.enqueue('a');64 _KernelInputQueue.enqueue('d');65 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);66 // Format the hard drive so we can load FOUR or more programs.67 _KernelInputQueue.enqueue('f');68 _KernelInputQueue.enqueue('o');69 _KernelInputQueue.enqueue('r');70 _KernelInputQueue.enqueue('m');71 _KernelInputQueue.enqueue('a');72 _KernelInputQueue.enqueue('t');73 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);74 // getschedule75 _KernelInputQueue.enqueue('g');76 _KernelInputQueue.enqueue('e');77 _KernelInputQueue.enqueue('t');78 _KernelInputQueue.enqueue('s');79 _KernelInputQueue.enqueue('c');80 _KernelInputQueue.enqueue('h');81 _KernelInputQueue.enqueue('e');82 _KernelInputQueue.enqueue('d');83 _KernelInputQueue.enqueue('u');84 _KernelInputQueue.enqueue('l');85 _KernelInputQueue.enqueue('e');86 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);87 // Load FOUR different valid user programs code and run them. . . . and here.88 var code1 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 03 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 61 00 61 64 6F 6E 65 00";89 var code2 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 06 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 62 00 62 64 6F 6E 65 00";90 var code3 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 09 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 63 00 63 64 6F 6E 65 00";91 var code4 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 0C AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 64 00 64 64 6F 6E 65 00";92 setTimeout(function(){ document.getElementById("taProgramInput").value = code1;93 _KernelInputQueue.enqueue('l');94 _KernelInputQueue.enqueue('o');95 _KernelInputQueue.enqueue('a');96 _KernelInputQueue.enqueue('d');97 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 98 }, 1000);99 setTimeout(function(){ document.getElementById("taProgramInput").value = code2;100 _KernelInputQueue.enqueue('l');101 _KernelInputQueue.enqueue('o');102 _KernelInputQueue.enqueue('a');103 _KernelInputQueue.enqueue('d');104 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 105 }, 2000);106 setTimeout(function(){ document.getElementById("taProgramInput").value = code3;107 _KernelInputQueue.enqueue('l');108 _KernelInputQueue.enqueue('o');109 _KernelInputQueue.enqueue('a');110 _KernelInputQueue.enqueue('d');111 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 112 }, 3000);113 setTimeout(function(){ document.getElementById("taProgramInput").value = code4;114 _KernelInputQueue.enqueue('l');115 _KernelInputQueue.enqueue('o');116 _KernelInputQueue.enqueue('a');117 _KernelInputQueue.enqueue('d');118 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 119 }, 3000);120 setTimeout(function(){ _KernelInputQueue.enqueue('r');121 _KernelInputQueue.enqueue('u');122 _KernelInputQueue.enqueue('n');123 _KernelInputQueue.enqueue('a');124 _KernelInputQueue.enqueue('l'); 125 _KernelInputQueue.enqueue('l'); 126 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 127 }, 4000);128 // Remind myself to test the file system.129 _KernelInputQueue.enqueue('S');130 _KernelInputQueue.enqueue('t');131 _KernelInputQueue.enqueue('A');132 _KernelInputQueue.enqueue('t');133 _KernelInputQueue.enqueue('U');134 _KernelInputQueue.enqueue('s');135 _KernelInputQueue.enqueue(' ');136 _KernelInputQueue.enqueue('T');137 _KernelInputQueue.enqueue('e');138 _KernelInputQueue.enqueue('s');139 _KernelInputQueue.enqueue('t');140 _KernelInputQueue.enqueue(' ');141 _KernelInputQueue.enqueue('t');142 _KernelInputQueue.enqueue('h');143 _KernelInputQueue.enqueue('e');144 _KernelInputQueue.enqueue(' ');145 _KernelInputQueue.enqueue('f');146 _KernelInputQueue.enqueue('i');147 _KernelInputQueue.enqueue('l');148 _KernelInputQueue.enqueue('e');149 _KernelInputQueue.enqueue(' ');150 _KernelInputQueue.enqueue('s');151 _KernelInputQueue.enqueue('y');152 _KernelInputQueue.enqueue('s');153 _KernelInputQueue.enqueue('t');154 _KernelInputQueue.enqueue('e');155 _KernelInputQueue.enqueue('m');156 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);157 };158 ...

Full Screen

Full Screen

queue_spec.js

Source:queue_spec.js Github

copy

Full Screen

...47 it('Should accept a single input parameter', () => {48 expect(queue.enqueue.length).to.equal(1);49 });50 it('Should create a new node with the value provided as input', () => {51 queue.enqueue('A');52 expect(queue.front.value).to.equal('A');53 });54 it('Should reassign both the front and back pointers when a new node is added to the back of an empty queue', () => {55 queue.enqueue('A');56 expect(queue.front.value).to.equal('A');57 expect(queue.back.value).to.equal('A');58 });59 it('Should reassign only the back pointer when new nodes are added to the back of the queue of size one or greater', () => {60 queue.enqueue('A');61 queue.enqueue('B');62 expect(queue.front.value).to.equal('A');63 expect(queue.back.value).to.equal('B');64 queue.enqueue('C');65 expect(queue.front.value).to.equal('A');66 expect(queue.back.value).to.equal('C');67 });68 it('Should point the next property of the front node to the node that follows it for queues of size one or greater', () => {69 queue.enqueue('A');70 queue.enqueue('B');71 expect(queue.front.next.value).to.eql('B');72 queue.enqueue('C');73 expect(queue.front.next.value).to.equal('B');74 });75 it('Should increment the queue\'s length by one each time a node is added to the queue', () => {76 expect(queue.length).to.equal(0);77 queue.enqueue('A');78 expect(queue.length).to.equal(1);79 queue.enqueue('B');80 expect(queue.length).to.equal(2);81 queue.enqueue('C');82 expect(queue.length).to.equal(3);83 });84 it('Should return the size of the queue after a new node is added to the queue', () => {85 expect(queue.enqueue('A')).to.equal(1);86 expect(queue.enqueue('B')).to.equal(2);87 });88 });89 describe('dequeue', () => {90 it('Should not accept any input parameters', () => {91 expect(queue.dequeue.length).to.equal(0);92 });93 it('Should not throw an error when calling dequeue on an empty queue', () => {94 expect(function () { queue.dequeue() }).to.not.throw();95 });96 it('Should return null if called on an empty queue', () => {97 expect(queue.dequeue()).to.be.equal(null);98 });99 it('Should reassign the front and back pointers to null if there is only one node in the queue', () => {100 queue.enqueue('A');101 expect(queue.front.value).to.equal('A');102 expect(queue.back.value).to.equal('A');103 queue.dequeue();104 expect(queue.front).to.equal(null);105 expect(queue.back).to.equal(null);106 });107 it('Should reassign the front pointer to the node just behind the front node for queues of size two or greater', () => {108 queue.enqueue('A');109 queue.enqueue('B');110 queue.enqueue('C');111 expect(queue.front.value).to.equal('A');112 queue.dequeue();113 expect(queue.front.value).to.equal('B');114 queue.dequeue();115 expect(queue.front.value).to.equal('C');116 });117 it('Should decrement the queue\'s length by one each time a node is removed from the queue', () => {118 queue.enqueue('A');119 queue.enqueue('B');120 queue.enqueue('C');121 expect(queue.length).to.equal(3);122 queue.dequeue();123 expect(queue.length).to.equal(2);124 queue.dequeue();125 expect(queue.length).to.equal(1);126 });127 it('Should return the value of the node removed from the queue', () => {128 queue.enqueue('A');129 queue.enqueue('B');130 expect(queue.dequeue()).to.equal('A');131 expect(queue.dequeue()).to.equal('B');132 });133 });134 describe('size', () => {135 it('Should return a size of 0 for a new queue', () => {136 expect(queue.size()).to.equal(0);137 });138 it('Should return a size of 2 after two nodes are added to the queue', () => {139 queue.enqueue('A');140 queue.enqueue('B');141 expect(queue.size()).to.equal(2);142 });143 it('Should return a size of 1 after two nodes are added and then one is removed', () => {144 queue.enqueue('A');145 queue.enqueue('B');146 queue.dequeue();147 expect(queue.size()).to.equal(1);148 });149 it('Should return a size of 0 after more nodes were removed than were added', () => {150 queue.enqueue('A');151 queue.dequeue();152 queue.dequeue();153 expect(queue.size()).to.equal(0);154 });155 });156 });157 describe('Queue Behavior', () => {158 it('Should remove the least recently added of three nodes (FIFO)', () => {159 queue.enqueue('A');160 queue.enqueue('B');161 queue.enqueue('C');162 expect(queue.dequeue()).to.equal('A');163 });164 it('Should remove the oldest node after newer nodes have already been added and others have been removed', () => {165 queue.enqueue('A');166 queue.enqueue('B');167 queue.enqueue('C');168 queue.enqueue('D');169 queue.dequeue()170 expect(queue.dequeue()).to.equal('B');171 });172 });...

Full Screen

Full Screen

glados-ip3.js

Source:glados-ip3.js Github

copy

Full Screen

...8 alert(msg);9 };10 this.afterStartup = function() {11 // Force scrolling with a few 'help' commands.12 _KernelInputQueue.enqueue('h');13 _KernelInputQueue.enqueue('e');14 _KernelInputQueue.enqueue('l');15 _KernelInputQueue.enqueue('p');16 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);17 _KernelInputQueue.enqueue('h');18 _KernelInputQueue.enqueue('e');19 _KernelInputQueue.enqueue('l');20 _KernelInputQueue.enqueue('p');21 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);22 // Test the 'ver' command.23 _KernelInputQueue.enqueue('v');24 _KernelInputQueue.enqueue('e');25 _KernelInputQueue.enqueue('r');26 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);27 // Test the 'date' command.28 _KernelInputQueue.enqueue('d');29 _KernelInputQueue.enqueue('a');30 _KernelInputQueue.enqueue('t');31 _KernelInputQueue.enqueue('e');32 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);33 // Test the 'whereami' command.34 _KernelInputQueue.enqueue('w');35 _KernelInputQueue.enqueue('h');36 _KernelInputQueue.enqueue('e');37 _KernelInputQueue.enqueue('r');38 _KernelInputQueue.enqueue('e');39 _KernelInputQueue.enqueue('a');40 _KernelInputQueue.enqueue('m');41 _KernelInputQueue.enqueue('i');42 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);43 44 // Test the 'status' command.45 _KernelInputQueue.enqueue('S');46 _KernelInputQueue.enqueue('t');47 _KernelInputQueue.enqueue('A');48 _KernelInputQueue.enqueue('t');49 _KernelInputQueue.enqueue('U');50 _KernelInputQueue.enqueue('s');51 _KernelInputQueue.enqueue(' ');52 _KernelInputQueue.enqueue('C');53 _KernelInputQueue.enqueue('a');54 _KernelInputQueue.enqueue('k');55 _KernelInputQueue.enqueue('e');56 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);57 58 // Load some invalid user program code59 document.getElementById("taProgramInput").value="This is NOT hex.";60 _KernelInputQueue.enqueue('l');61 _KernelInputQueue.enqueue('o');62 _KernelInputQueue.enqueue('a');63 _KernelInputQueue.enqueue('d');64 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);65 // Load THREE (slightly different) valid user programs code and run them. The differences are . . . . . . here . . . . . . and here.66 var code1 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 03 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 61 00 61 64 6F 6E 65 00";67 var code2 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 06 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 62 00 62 64 6F 6E 65 00";68 var code3 = "A9 00 8D 7B 00 A9 00 8D 7B 00 A9 00 8D 7C 00 A9 00 8D 7C 00 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 39 A0 7D A2 02 FF AC 7B 00 A2 01 FF AD 7B 00 8D 7A 00 A9 01 6D 7A 00 8D 7B 00 A9 09 AE 7B 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 01 EC 7A 00 D0 05 A9 01 8D 7C 00 A9 00 AE 7C 00 8D 7A 00 A9 00 EC 7A 00 D0 02 A9 01 8D 7A 00 A2 00 EC 7A 00 D0 AC A0 7F A2 02 FF 00 00 00 00 63 00 63 64 6F 6E 65 00";69 setTimeout(function(){ document.getElementById("taProgramInput").value = code1;70 _KernelInputQueue.enqueue('l');71 _KernelInputQueue.enqueue('o');72 _KernelInputQueue.enqueue('a');73 _KernelInputQueue.enqueue('d');74 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 75 }, 1000);76 setTimeout(function(){ document.getElementById("taProgramInput").value = code2;77 _KernelInputQueue.enqueue('l');78 _KernelInputQueue.enqueue('o');79 _KernelInputQueue.enqueue('a');80 _KernelInputQueue.enqueue('d');81 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 82 }, 2000);83 setTimeout(function(){ document.getElementById("taProgramInput").value = code3;84 _KernelInputQueue.enqueue('l');85 _KernelInputQueue.enqueue('o');86 _KernelInputQueue.enqueue('a');87 _KernelInputQueue.enqueue('d');88 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 89 }, 3000);90 setTimeout(function(){ _KernelInputQueue.enqueue('r');91 _KernelInputQueue.enqueue('u');92 _KernelInputQueue.enqueue('n');93 _KernelInputQueue.enqueue('a');94 _KernelInputQueue.enqueue('l'); 95 _KernelInputQueue.enqueue('l'); 96 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 97 }, 4000);98 };99 ...

Full Screen

Full Screen

glados-ip1.js

Source:glados-ip1.js Github

copy

Full Screen

...10 alert(msg);11 };12 this.afterStartup = function() {13 // Force scrolling with a few 'help' commands.14 _KernelInputQueue.enqueue('h');15 _KernelInputQueue.enqueue('e');16 _KernelInputQueue.enqueue('l');17 _KernelInputQueue.enqueue('p');18 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 19 _KernelInputQueue.enqueue('h');20 _KernelInputQueue.enqueue('e');21 _KernelInputQueue.enqueue('l');22 _KernelInputQueue.enqueue('p');23 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);24 // Test the 'ver' command.25 _KernelInputQueue.enqueue('v');26 _KernelInputQueue.enqueue('e');27 _KernelInputQueue.enqueue('r');28 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);29 // Test the 'date' command.30 _KernelInputQueue.enqueue('d');31 _KernelInputQueue.enqueue('a');32 _KernelInputQueue.enqueue('t');33 _KernelInputQueue.enqueue('e');34 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);35 // Test the 'whereami' command.36 _KernelInputQueue.enqueue('w');37 _KernelInputQueue.enqueue('h');38 _KernelInputQueue.enqueue('e');39 _KernelInputQueue.enqueue('r');40 _KernelInputQueue.enqueue('e');41 _KernelInputQueue.enqueue('a');42 _KernelInputQueue.enqueue('m');43 _KernelInputQueue.enqueue('i');44 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);45 46 // Test the 'status' command.47 _KernelInputQueue.enqueue('S');48 _KernelInputQueue.enqueue('t');49 _KernelInputQueue.enqueue('A');50 _KernelInputQueue.enqueue('t');51 _KernelInputQueue.enqueue('U');52 _KernelInputQueue.enqueue('s');53 _KernelInputQueue.enqueue(' ');54 _KernelInputQueue.enqueue('T');55 _KernelInputQueue.enqueue('h');56 _KernelInputQueue.enqueue('e');57 _KernelInputQueue.enqueue(' ');58 _KernelInputQueue.enqueue('C');59 _KernelInputQueue.enqueue('a');60 _KernelInputQueue.enqueue('k');61 _KernelInputQueue.enqueue('e');62 _KernelInputQueue.enqueue(' ');63 _KernelInputQueue.enqueue('i');64 _KernelInputQueue.enqueue('s');65 _KernelInputQueue.enqueue(' ');66 _KernelInputQueue.enqueue('a');67 _KernelInputQueue.enqueue(' ');68 _KernelInputQueue.enqueue('l');69 _KernelInputQueue.enqueue('i');70 _KernelInputQueue.enqueue('e');71 _KernelInputQueue.enqueue('!');72 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]); 73 // Try and load some invalid user program code.74 document.getElementById("taProgramInput").value = "This is NOT hex.";75 _KernelInputQueue.enqueue('l');76 _KernelInputQueue.enqueue('o');77 _KernelInputQueue.enqueue('a');78 _KernelInputQueue.enqueue('d');79 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);80 // Try and load NO user program code. That should still casue an error.81 document.getElementById("taProgramInput").value = "";82 _KernelInputQueue.enqueue('l');83 _KernelInputQueue.enqueue('o');84 _KernelInputQueue.enqueue('a');85 _KernelInputQueue.enqueue('d');86 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);87 88 // Try and load some valid user program code.89 var code = "A9 00 8D 00 00 A9 00 8D 4B 00 A9 00 8D 4B 00 A2 03 EC 4B 00 D0 07 A2 01 EC 00 00 D0 05 A2 00 EC 00 00 D0 26 A0 4C A2 02 FF AC 4B 00 A2 01 FF A9 01 6D 4B 00 8D 4B 00 A2 02 EC 4B 00 D0 05 A0 55 A2 02 FF A2 01 EC 00 00 D0 C5 00 00 63 6F 75 6E 74 69 6E 67 00 68 65 6C 6C 6F 20 77 6F 72 6C 64 00";90 document.getElementById("taProgramInput").value = code;91 _KernelInputQueue.enqueue('l');92 _KernelInputQueue.enqueue('o');93 _KernelInputQueue.enqueue('a');94 _KernelInputQueue.enqueue('d');95 TSOS.Kernel.prototype.krnInterruptHandler(KEYBOARD_IRQ, [13, false]);96 };...

Full Screen

Full Screen

heap.spec.js

Source:heap.spec.js Github

copy

Full Screen

...3describe('Heap tests', () => {4 context('Max heap', () => {5 it('Should push items to max-heap in expected order', () => {6 const heap = new Heap(false);7 heap.enqueue(33);8 expect(heap.getHeap()).to.eql([33]);9 heap.enqueue(30);10 expect(heap.getHeap()).to.eql([33, 30]);11 heap.enqueue(30);12 expect(heap.getHeap()).to.eql([33, 30, 30]);13 heap.enqueue(11);14 expect(heap.getHeap()).to.eql([33, 30, 30, 11]);15 });16 it('Should rebalance max-heap correctly after pushing an item', () => {17 const heap = new Heap(false);18 heap.enqueue(33);19 heap.enqueue(30);20 heap.enqueue(11);21 expect(heap.getHeap()).to.eql([33, 30, 11]);22 heap.enqueue(31);23 expect(heap.getHeap()).to.eql([33, 31, 11, 30]);24 heap.enqueue(34);25 expect(heap.getHeap()).to.eql([34, 33, 11, 30, 31]);26 heap.enqueue(22);27 expect(heap.getHeap()).to.eql([34, 33, 22, 30, 31, 11]);28 });29 it('Should rebalance max-heap correctly after pulling root', () => {30 const heap = new Heap(false);31 heap.enqueue(33);32 heap.enqueue(30);33 heap.enqueue(11);34 heap.enqueue(31);35 heap.enqueue(34);36 heap.enqueue(22);37 expect(heap.getHeap()).to.eql([34, 33, 22, 30, 31, 11]);38 let root = heap.dequeue();39 expect(root).to.be.eql(34);40 expect(heap.getHeap()).to.eql([33, 31, 22, 30, 11]);41 root = heap.dequeue();42 expect(root).to.be.eql(33);43 expect(heap.getHeap()).to.eql([31, 30, 22, 11]);44 root = heap.dequeue();45 expect(root).to.be.eql(31);46 expect(heap.getHeap()).to.eql([30, 11, 22]);47 root = heap.dequeue();48 expect(root).to.be.eql(30);49 expect(heap.getHeap()).to.eql([22, 11]);50 root = heap.dequeue();51 expect(root).to.be.eql(22);52 expect(heap.getHeap()).to.eql([11]);53 root = heap.dequeue();54 expect(root).to.be.eql(11);55 expect(heap.getHeap()).to.eql([]);56 root = heap.dequeue();57 expect(root).to.be.eql(undefined);58 expect(heap.getHeap()).to.eql([]);59 });60 });61 context('Min heap', () => {62 it('Should push items to min-heap in expected order', () => {63 const heap = new Heap(true);64 heap.enqueue(33);65 expect(heap.getHeap()).to.eql([33]);66 heap.enqueue(30);67 expect(heap.getHeap()).to.eql([30, 33]);68 heap.enqueue(30);69 expect(heap.getHeap()).to.eql([30, 33, 30]);70 heap.enqueue(11);71 expect(heap.getHeap()).to.eql([11, 30, 30, 33]);72 });73 it('Should rebalance min-heap correctly after pushing an item', () => {74 const heap = new Heap(true);75 heap.enqueue(33);76 heap.enqueue(30);77 heap.enqueue(11);78 expect(heap.getHeap()).to.eql([11, 33, 30]);79 heap.enqueue(31);80 expect(heap.getHeap()).to.eql([11, 31, 30, 33]);81 heap.enqueue(34);82 expect(heap.getHeap()).to.eql([11, 31, 30, 33, 34]);83 heap.enqueue(22);84 expect(heap.getHeap()).to.eql([11, 31, 22, 33, 34, 30]);85 });86 it('Should rebalance min-heap correctly after pulling root', () => {87 const heap = new Heap(true);88 heap.enqueue(33);89 heap.enqueue(30);90 heap.enqueue(11);91 heap.enqueue(31);92 heap.enqueue(34);93 heap.enqueue(22);94 expect(heap.getHeap()).to.eql([11, 31, 22, 33, 34, 30]);95 let root = heap.dequeue();96 expect(root).to.be.eql(11);97 expect(heap.getHeap()).to.eql([22, 31, 30, 33, 34]);98 root = heap.dequeue();99 expect(root).to.be.eql(22);100 expect(heap.getHeap()).to.eql([30, 31, 34, 33]);101 root = heap.dequeue();102 expect(root).to.be.eql(30);103 expect(heap.getHeap()).to.eql([31, 33, 34]);104 root = heap.dequeue();105 expect(root).to.be.eql(31);106 expect(heap.getHeap()).to.eql([33, 34]);107 root = heap.dequeue();...

Full Screen

Full Screen

QueueSpec.js

Source:QueueSpec.js Github

copy

Full Screen

...4 beforeEach(function() {5 queue = new Queue();6 });7 it('can enqueue and dequeue items', function() {8 queue.enqueue(1);9 queue.enqueue('a');10 queue.enqueue(null);11 expect(queue.dequeue()).toEqual(1);12 expect(queue.dequeue()).toEqual('a');13 expect(queue.dequeue()).toEqual(null);14 });15 it('returns undefined when dequeueing while empty', function() {16 expect(queue.dequeue()).toBeUndefined();17 });18 it('updates length when enqueuing and dequeuing', function() {19 expect(queue.length).toEqual(0);20 queue.enqueue('a');21 expect(queue.length).toEqual(1);22 queue.dequeue();23 expect(queue.length).toEqual(0);24 });25 it('compacts underlying array', function() {26 var i;27 for (i = 0; i < 1000; i++) {28 queue.enqueue(i);29 }30 for (i = 0; i < 1000; i++) {31 queue.dequeue();32 }33 expect(queue._array.length).toBeLessThan(1000);34 });35 it('can peek at the item at the head of the queue', function() {36 queue.enqueue(1);37 queue.enqueue(2);38 expect(queue.peek()).toEqual(1);39 expect(queue.length).toEqual(2);40 });41 it('returns undefined when peeking while empty', function() {42 expect(queue.peek()).toBeUndefined();43 });44 it('can check if it contains an item', function() {45 queue.enqueue(1);46 expect(queue.contains(1)).toEqual(true);47 expect(queue.contains(2)).toEqual(false);48 });49 it('can clear items', function() {50 queue.enqueue(1);51 queue.enqueue(2);52 queue.clear();53 expect(queue.length).toEqual(0);54 });55 it('can sort items', function() {56 queue.enqueue(99);57 queue.enqueue(6);58 queue.enqueue(1);59 queue.enqueue(53);60 queue.enqueue(4);61 queue.enqueue(0);62 queue.dequeue(); //remove 9963 queue.sort(function(a, b) {64 return a - b;65 });66 expect(queue.dequeue()).toEqual(0);67 expect(queue.dequeue()).toEqual(1);68 expect(queue.dequeue()).toEqual(4);69 expect(queue.dequeue()).toEqual(6);70 expect(queue.dequeue()).toEqual(53);71 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptQueue = require('wpt-queue');2 console.log(data);3});4var wptQueue = require('wpt-queue');5 console.log(data);6});7{ message: 'Test added to queue' }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = new wptools('Barack Obama');3wp.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');7var wp = new wptools('Barack Obama');8wp.get(function(err, resp) {9 console.log(resp);10});11var wptools = require('wptools');12var wp = new wptools('Barack Obama');13wp.get(function(err, resp) {14 console.log(resp

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Barack Obama');3wp.enqueue(function(err, resp, infobox) {4 console.log(infobox);5});6* [Simple](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var queue = new wptools.queue();3queue.enqueue('en.wikipedia.org/wiki/India', function (err, data) {4 console.log(data);5});6queue.enqueue('en.wikipedia.org/wiki/United_States', function (err, data) {7 console.log(data);8});9queue.enqueue('en.wikipedia.org/wiki/China', function (err, data) {10 console.log(data);11});12queue.start();13var wptools = require('wptools');14var queue = new wptools.queue();15queue.enqueue('en.wikipedia.org/wiki/India', function (err, data) {16 console.log(data);17});18queue.enqueue('en.wikipedia.org/wiki/United_States', function (err, data) {19 console.log(data);20});21queue.enqueue('en.wikipedia.org/wiki/China', function (err, data) {22 console.log(data);23});24queue.start();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var category = 'Category:Lists_of_companies_of_the_United_States';4var pages = [];5var counter = 0;6var w = wptools.category(category);7w.get(function(err, res) {8 if (err) {9 console.log(err);10 } else {11 pages = res.pages;12 counter = pages.length;13 fs.writeFile('test.json', JSON.stringify(pages, null, 4), function(err) {14 if (err) {15 console.log(err);16 } else {17 console.log('File successfully written!');18 }19 });20 }21});22w.enqueue(function(err, res) {23 if (err) {24 console.log(err);25 } else {26 pages = pages.concat(res.pages);27 counter += res.pages.length;28 if (counter < 10) {29 w.enqueue();30 } else {31 fs.writeFile('test.json', JSON.stringify(pages, null, 4), function(err) {32 if (err) {33 console.log(err);34 } else {35 console.log('File successfully written!');36 }37 });38 }39 }40});41[ { title: 'Lists of companies of the United States by state',42 categories: [ [Object] ] },43 { title: 'Lists of companies of the United States by industry',44 categories: [ [Object] ] },45 { title: 'Lists of companies of the United States by location',46 categories: [ [Object] ] },47 { title: 'Lists of companies of the United States by year',48 categories: [ [Object] ] },49 { title: 'Lists of companies of the United States by type',

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 wpt 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