How to use standardSetup method in wpt

Best JavaScript code snippet using wpt

angular-table.js

Source:angular-table.js Github

copy

Full Screen

1// author: Samuel Mueller 2// version: 1.0.7 3// license: MIT 4// homepage: http://github.com/samu/angular-table 5(function() {6 var ColumnConfiguration, PageSequence, PaginatedSetup, ScopeConfigWrapper, Setup, StandardSetup, Table, TableConfiguration, configurationVariableNames, paginationTemplate,7 __hasProp = {}.hasOwnProperty,8 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };9 angular.module("angular-table", []);10 ColumnConfiguration = (function() {11 function ColumnConfiguration(bodyMarkup, headerMarkup) {12 this.attribute = bodyMarkup.attribute;13 this.title = bodyMarkup.title;14 this.sortable = bodyMarkup.sortable;15 this.width = bodyMarkup.width;16 this.initialSorting = bodyMarkup.initialSorting;17 if (headerMarkup) {18 this.customContent = headerMarkup.customContent;19 this.attributes = headerMarkup.attributes;20 }21 }22 ColumnConfiguration.prototype.createElement = function() {23 var th;24 return th = angular.element(document.createElement("th"));25 };26 ColumnConfiguration.prototype.renderTitle = function(element) {27 return element.html(this.customContent || this.title);28 };29 ColumnConfiguration.prototype.renderAttributes = function(element) {30 var attribute, _i, _len, _ref, _results;31 if (this.customContent) {32 _ref = this.attributes;33 _results = [];34 for (_i = 0, _len = _ref.length; _i < _len; _i++) {35 attribute = _ref[_i];36 _results.push(element.attr(attribute.name, attribute.value));37 }38 return _results;39 }40 };41 ColumnConfiguration.prototype.renderSorting = function(element) {42 var icon;43 if (this.sortable) {44 element.attr("ng-click", "predicate = '" + this.attribute + "'; descending = !descending;");45 icon = angular.element("<i style='margin-left: 10px;'></i>");46 icon.attr("ng-class", "getSortIcon('" + this.attribute + "', predicate, descending)");47 return element.append(icon);48 }49 };50 ColumnConfiguration.prototype.renderWidth = function(element) {51 return element.attr("width", this.width);52 };53 ColumnConfiguration.prototype.renderHtml = function() {54 var th;55 th = this.createElement();56 this.renderTitle(th);57 this.renderAttributes(th);58 this.renderSorting(th);59 this.renderWidth(th);60 return th;61 };62 return ColumnConfiguration;63 })();64 configurationVariableNames = (function() {65 function configurationVariableNames(configObjectName) {66 this.configObjectName = configObjectName;67 this.itemsPerPage = "" + this.configObjectName + ".itemsPerPage";68 this.sortContext = "" + this.configObjectName + ".sortContext";69 this.fillLastPage = "" + this.configObjectName + ".fillLastPage";70 this.maxPages = "" + this.configObjectName + ".maxPages";71 this.currentPage = "" + this.configObjectName + ".currentPage";72 this.orderBy = "" + this.configObjectName + ".orderBy";73 this.paginatorLabels = "" + this.configObjectName + ".paginatorLabels";74 }75 return configurationVariableNames;76 })();77 ScopeConfigWrapper = (function() {78 function ScopeConfigWrapper(scope, configurationVariableNames, listName) {79 this.scope = scope;80 this.configurationVariableNames = configurationVariableNames;81 this.listName = listName;82 }83 ScopeConfigWrapper.prototype.getList = function() {84 return this.scope.$eval(this.listName);85 };86 ScopeConfigWrapper.prototype.getItemsPerPage = function() {87 return this.scope.$eval(this.configurationVariableNames.itemsPerPage) || 10;88 };89 ScopeConfigWrapper.prototype.getCurrentPage = function() {90 return this.scope.$eval(this.configurationVariableNames.currentPage) || 0;91 };92 ScopeConfigWrapper.prototype.getMaxPages = function() {93 return this.scope.$eval(this.configurationVariableNames.maxPages) || void 0;94 };95 ScopeConfigWrapper.prototype.getSortContext = function() {96 return this.scope.$eval(this.configurationVariableNames.sortContext) || 'global';97 };98 ScopeConfigWrapper.prototype.setCurrentPage = function(currentPage) {99 return this.scope.$eval("" + this.configurationVariableNames.currentPage + "=" + currentPage);100 };101 ScopeConfigWrapper.prototype.getOrderBy = function() {102 return this.scope.$eval(this.configurationVariableNames.orderBy) || 'orderBy';103 };104 ScopeConfigWrapper.prototype.getPaginatorLabels = function() {105 var paginatorLabelsDefault;106 paginatorLabelsDefault = {107 stepBack: '‹',108 stepAhead: '›',109 jumpBack: '«',110 jumpAhead: '»',111 first: 'First',112 last: 'Last'113 };114 return this.scope.$eval(this.configurationVariableNames.paginatorLabels) || paginatorLabelsDefault;115 };116 return ScopeConfigWrapper;117 })();118 TableConfiguration = (function() {119 function TableConfiguration(tableElement, attributes) {120 this.tableElement = tableElement;121 this.attributes = attributes;122 this.id = this.attributes.id;123 this.config = this.attributes.atConfig;124 this.paginated = this.attributes.atPaginated != null;125 this.list = this.attributes.atList;126 this.createColumnConfigurations();127 }128 TableConfiguration.prototype.capitaliseFirstLetter = function(string) {129 if (string) {130 return string.charAt(0).toUpperCase() + string.slice(1);131 } else {132 return "";133 }134 };135 TableConfiguration.prototype.extractWidth = function(classes) {136 var width;137 width = /([0-9]+px)/i.exec(classes);138 if (width) {139 return width[0];140 } else {141 return "";142 }143 };144 TableConfiguration.prototype.isSortable = function(classes) {145 var sortable;146 sortable = /(sortable)/i.exec(classes);147 if (sortable) {148 return true;149 } else {150 return false;151 }152 };153 TableConfiguration.prototype.getInitialSorting = function(td) {154 var initialSorting;155 initialSorting = td.attr("at-initial-sorting");156 if (initialSorting) {157 if (initialSorting === "asc" || initialSorting === "desc") {158 return initialSorting;159 }160 throw "Invalid value for initial-sorting: " + initialSorting + ". Allowed values are 'asc' or 'desc'.";161 }162 return void 0;163 };164 TableConfiguration.prototype.collectHeaderMarkup = function(table) {165 var customHeaderMarkups, th, tr, _i, _len, _ref;166 customHeaderMarkups = {};167 tr = table.find("tr");168 _ref = tr.find("th");169 for (_i = 0, _len = _ref.length; _i < _len; _i++) {170 th = _ref[_i];171 th = angular.element(th);172 customHeaderMarkups[th.attr("at-attribute")] = {173 customContent: th.html(),174 attributes: th[0].attributes175 };176 }177 return customHeaderMarkups;178 };179 TableConfiguration.prototype.collectBodyMarkup = function(table) {180 var attribute, bodyDefinition, initialSorting, sortable, td, title, width, _i, _len, _ref;181 bodyDefinition = [];182 _ref = table.find("td");183 for (_i = 0, _len = _ref.length; _i < _len; _i++) {184 td = _ref[_i];185 td = angular.element(td);186 attribute = td.attr("at-attribute");187 title = td.attr("at-title") || this.capitaliseFirstLetter(td.attr("at-attribute"));188 sortable = td.attr("at-sortable") !== void 0 || this.isSortable(td.attr("class"));189 width = this.extractWidth(td.attr("class"));190 initialSorting = this.getInitialSorting(td);191 bodyDefinition.push({192 attribute: attribute,193 title: title,194 sortable: sortable,195 width: width,196 initialSorting: initialSorting197 });198 }199 return bodyDefinition;200 };201 TableConfiguration.prototype.createColumnConfigurations = function() {202 var bodyMarkup, headerMarkup, i, _i, _len;203 headerMarkup = this.collectHeaderMarkup(this.tableElement);204 bodyMarkup = this.collectBodyMarkup(this.tableElement);205 this.columnConfigurations = [];206 for (_i = 0, _len = bodyMarkup.length; _i < _len; _i++) {207 i = bodyMarkup[_i];208 this.columnConfigurations.push(new ColumnConfiguration(i, headerMarkup[i.attribute]));209 }210 };211 return TableConfiguration;212 })();213 Setup = (function() {214 function Setup() {}215 Setup.prototype.setupTr = function(element, repeatString) {216 var tbody, tr;217 tbody = element.find("tbody");218 tr = tbody.find("tr");219 tr.attr("ng-repeat", repeatString);220 return tbody;221 };222 return Setup;223 })();224 StandardSetup = (function(_super) {225 __extends(StandardSetup, _super);226 function StandardSetup(configurationVariableNames, list) {227 this.list = list;228 this.repeatString = "item in " + this.list + " | orderBy:predicate:descending";229 }230 StandardSetup.prototype.compile = function(element, attributes, transclude) {231 return this.setupTr(element, this.repeatString);232 };233 StandardSetup.prototype.link = function() {};234 return StandardSetup;235 })(Setup);236 PaginatedSetup = (function(_super) {237 __extends(PaginatedSetup, _super);238 function PaginatedSetup(configurationVariableNames) {239 this.configurationVariableNames = configurationVariableNames;240 this.repeatString = "item in sortedAndPaginatedList";241 }242 PaginatedSetup.prototype.compile = function(element) {243 var fillerTr, tbody, td, tdString, tds, _i, _len;244 tbody = this.setupTr(element, this.repeatString);245 tds = element.find("td");246 tdString = "";247 for (_i = 0, _len = tds.length; _i < _len; _i++) {248 td = tds[_i];249 tdString += "<td><span>&nbsp;</span></td>";250 }251 fillerTr = angular.element(document.createElement("tr"));252 fillerTr.attr("ng-show", this.configurationVariableNames.fillLastPage);253 fillerTr.html(tdString);254 fillerTr.attr("ng-repeat", "item in fillerArray");255 tbody.append(fillerTr);256 };257 PaginatedSetup.prototype.link = function($scope, $element, $attributes, $filter) {258 var cvn, getFillerArray, getSortedAndPaginatedList, update, w;259 cvn = this.configurationVariableNames;260 w = new ScopeConfigWrapper($scope, cvn, $attributes.atList);261 getSortedAndPaginatedList = function(list, currentPage, itemsPerPage, orderBy, sortContext, predicate, descending, $filter) {262 var fromPage, val;263 if (list) {264 val = list;265 fromPage = itemsPerPage * currentPage - list.length;266 if (sortContext === "global") {267 val = $filter(orderBy)(val, predicate, descending);268 val = $filter("limitTo")(val, fromPage);269 val = $filter("limitTo")(val, itemsPerPage);270 } else {271 val = $filter("limitTo")(val, fromPage);272 val = $filter("limitTo")(val, itemsPerPage);273 val = $filter(orderBy)(val, predicate, descending);274 }275 return val;276 } else {277 return [];278 }279 };280 getFillerArray = function(list, currentPage, numberOfPages, itemsPerPage) {281 var fillerLength, itemCountOnLastPage, x, _i, _j, _ref, _ref1, _ref2, _results, _results1;282 itemsPerPage = parseInt(itemsPerPage);283 if (list.length <= 0) {284 _results = [];285 for (x = _i = 0, _ref = itemsPerPage - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; x = 0 <= _ref ? ++_i : --_i) {286 _results.push(x);287 }288 return _results;289 } else if (currentPage === numberOfPages - 1) {290 itemCountOnLastPage = list.length % itemsPerPage;291 if (itemCountOnLastPage !== 0) {292 fillerLength = itemsPerPage - itemCountOnLastPage - 1;293 _results1 = [];294 for (x = _j = _ref1 = list.length, _ref2 = list.length + fillerLength; _ref1 <= _ref2 ? _j <= _ref2 : _j >= _ref2; x = _ref1 <= _ref2 ? ++_j : --_j) {295 _results1.push(x);296 }297 return _results1;298 } else {299 return [];300 }301 }302 };303 update = function() {304 var nop;305 $scope.sortedAndPaginatedList = getSortedAndPaginatedList(w.getList(), w.getCurrentPage(), w.getItemsPerPage(), w.getOrderBy(), w.getSortContext(), $scope.predicate, $scope.descending, $filter);306 nop = Math.ceil(w.getList().length / w.getItemsPerPage());307 return $scope.fillerArray = getFillerArray(w.getList(), w.getCurrentPage(), nop, w.getItemsPerPage());308 };309 $scope.$watch(cvn.currentPage, function() {310 return update();311 });312 $scope.$watch(cvn.itemsPerPage, function() {313 return update();314 });315 $scope.$watch(cvn.sortContext, function() {316 return update();317 });318 $scope.$watchCollection($attributes.atList, function() {319 return update();320 });321 $scope.$watch("" + $attributes.atList + ".length", function() {322 $scope.numberOfPages = Math.ceil(w.getList().length / w.getItemsPerPage());323 return update();324 });325 $scope.$watch("predicate", function() {326 return update();327 });328 return $scope.$watch("descending", function() {329 return update();330 });331 };332 return PaginatedSetup;333 })(Setup);334 Table = (function() {335 function Table(element, tableConfiguration, configurationVariableNames) {336 this.element = element;337 this.tableConfiguration = tableConfiguration;338 this.configurationVariableNames = configurationVariableNames;339 }340 Table.prototype.constructHeader = function() {341 var i, tr, _i, _len, _ref;342 tr = angular.element(document.createElement("tr"));343 _ref = this.tableConfiguration.columnConfigurations;344 for (_i = 0, _len = _ref.length; _i < _len; _i++) {345 i = _ref[_i];346 tr.append(i.renderHtml());347 }348 return tr;349 };350 Table.prototype.setupHeader = function() {351 var header, thead, tr;352 thead = this.element.find("thead");353 if (thead) {354 header = this.constructHeader();355 tr = angular.element(thead).find("tr");356 tr.remove();357 return thead.append(header);358 }359 };360 Table.prototype.getSetup = function() {361 if (this.tableConfiguration.paginated) {362 return new PaginatedSetup(this.configurationVariableNames);363 } else {364 return new StandardSetup(this.configurationVariableNames, this.tableConfiguration.list);365 }366 };367 Table.prototype.compile = function() {368 this.setupHeader();369 this.setup = this.getSetup();370 return this.setup.compile(this.element);371 };372 Table.prototype.setupInitialSorting = function($scope) {373 var bd, _i, _len, _ref, _results;374 _ref = this.tableConfiguration.columnConfigurations;375 _results = [];376 for (_i = 0, _len = _ref.length; _i < _len; _i++) {377 bd = _ref[_i];378 if (bd.initialSorting) {379 if (!bd.attribute) {380 throw "initial-sorting specified without attribute.";381 }382 $scope.predicate = bd.attribute;383 _results.push($scope.descending = bd.initialSorting === "desc");384 } else {385 _results.push(void 0);386 }387 }388 return _results;389 };390 Table.prototype.post = function($scope, $element, $attributes, $filter) {391 this.setupInitialSorting($scope);392 if (!$scope.getSortIcon) {393 $scope.getSortIcon = function(predicate, currentPredicate, descending) {394 if (predicate !== $scope.predicate) {395 return "glyphicon glyphicon-minus";396 }397 if (descending) {398 return "glyphicon glyphicon-chevron-down";399 } else {400 return "glyphicon glyphicon-chevron-up";401 }402 };403 }404 return this.setup.link($scope, $element, $attributes, $filter);405 };406 return Table;407 })();408 PageSequence = (function() {409 function PageSequence(lowerBound, upperBound, start, length) {410 this.lowerBound = lowerBound != null ? lowerBound : 0;411 this.upperBound = upperBound != null ? upperBound : 1;412 if (start == null) {413 start = 0;414 }415 this.length = length != null ? length : 1;416 if (this.length > (this.upperBound - this.lowerBound)) {417 throw "sequence is too long";418 }419 this.data = this.generate(start);420 }421 PageSequence.prototype.generate = function(start) {422 var x, _i, _ref, _results;423 if (start > (this.upperBound - this.length)) {424 start = this.upperBound - this.length;425 } else if (start < this.lowerBound) {426 start = this.lowerBound;427 }428 _results = [];429 for (x = _i = start, _ref = parseInt(start) + parseInt(this.length) - 1; start <= _ref ? _i <= _ref : _i >= _ref; x = start <= _ref ? ++_i : --_i) {430 _results.push(x);431 }432 return _results;433 };434 PageSequence.prototype.resetParameters = function(lowerBound, upperBound, length) {435 this.lowerBound = lowerBound;436 this.upperBound = upperBound;437 this.length = length;438 if (this.length > (this.upperBound - this.lowerBound)) {439 throw "sequence is too long";440 }441 return this.data = this.generate(this.data[0]);442 };443 PageSequence.prototype.relocate = function(distance) {444 var newStart;445 newStart = this.data[0] + distance;446 return this.data = this.generate(newStart, newStart + this.length);447 };448 PageSequence.prototype.realignGreedy = function(page) {449 var newStart;450 if (page < this.data[0]) {451 newStart = page;452 return this.data = this.generate(newStart);453 } else if (page > this.data[this.length - 1]) {454 newStart = page - (this.length - 1);455 return this.data = this.generate(newStart);456 }457 };458 PageSequence.prototype.realignGenerous = function(page) {};459 return PageSequence;460 })();461 paginationTemplate = "<div style='margin: 0px;'> <ul class='pagination'> <li ng-class='{disabled: getCurrentPage() <= 0}'> <a href='' ng-click='stepPage(-numberOfPages)'>{{getPaginatorLabels().first}}</a> </li> <li ng-show='showSectioning()' ng-class='{disabled: getCurrentPage() <= 0}'> <a href='' ng-click='jumpBack()'>{{getPaginatorLabels().jumpBack}}</a> </li> <li ng-class='{disabled: getCurrentPage() <= 0}'> <a href='' ng-click='stepPage(-1)'>{{getPaginatorLabels().stepBack}}</a> </li> <li ng-class='{active: getCurrentPage() == page}' ng-repeat='page in pageSequence.data'> <a href='' ng-click='goToPage(page)' ng-bind='page + 1'></a> </li> <li ng-class='{disabled: getCurrentPage() >= numberOfPages - 1}'> <a href='' ng-click='stepPage(1)'>{{getPaginatorLabels().stepAhead}}</a> </li> <li ng-show='showSectioning()' ng-class='{disabled: getCurrentPage() >= numberOfPages - 1}'> <a href='' ng-click='jumpAhead()'>{{getPaginatorLabels().jumpAhead}}</a> </li> <li ng-class='{disabled: getCurrentPage() >= numberOfPages - 1}'> <a href='' ng-click='stepPage(numberOfPages)'>{{getPaginatorLabels().last}}</a> </li> </ul> </div>";462 angular.module("angular-table").directive("atTable", [463 "$filter", function($filter) {464 return {465 restrict: "AC",466 scope: true,467 compile: function(element, attributes, transclude) {468 var cvn, table, tc;469 tc = new TableConfiguration(element, attributes);470 cvn = new configurationVariableNames(attributes.atConfig);471 table = new Table(element, tc, cvn);472 table.compile();473 return {474 post: function($scope, $element, $attributes) {475 return table.post($scope, $element, $attributes, $filter);476 }477 };478 }479 };480 }481 ]);482 angular.module("angular-table").directive("atPagination", [483 function() {484 return {485 restrict: "E",486 scope: true,487 replace: true,488 template: paginationTemplate,489 link: function($scope, $element, $attributes) {490 var cvn, getNumberOfPages, keepInBounds, setNumberOfPages, update, w;491 cvn = new configurationVariableNames($attributes.atConfig);492 w = new ScopeConfigWrapper($scope, cvn, $attributes.atList);493 keepInBounds = function(val, min, max) {494 val = Math.max(min, val);495 return Math.min(max, val);496 };497 getNumberOfPages = function() {498 return $scope.numberOfPages;499 };500 setNumberOfPages = function(numberOfPages) {501 return $scope.numberOfPages = numberOfPages;502 };503 update = function(reset) {504 var newNumberOfPages, pagesToDisplay;505 if (w.getList()) {506 if (w.getList().length > 0) {507 newNumberOfPages = Math.ceil(w.getList().length / w.getItemsPerPage());508 setNumberOfPages(newNumberOfPages);509 if ($scope.showSectioning()) {510 pagesToDisplay = w.getMaxPages();511 } else {512 pagesToDisplay = newNumberOfPages;513 }514 $scope.pageSequence.resetParameters(0, newNumberOfPages, pagesToDisplay);515 w.setCurrentPage(keepInBounds(w.getCurrentPage(), 0, getNumberOfPages() - 1));516 return $scope.pageSequence.realignGreedy(w.getCurrentPage());517 } else {518 setNumberOfPages(1);519 $scope.pageSequence.resetParameters(0, 1, 1);520 w.setCurrentPage(0);521 return $scope.pageSequence.realignGreedy(0);522 }523 }524 };525 $scope.showSectioning = function() {526 return w.getMaxPages() && getNumberOfPages() > w.getMaxPages();527 };528 $scope.getCurrentPage = function() {529 return w.getCurrentPage();530 };531 $scope.getPaginatorLabels = function() {532 return w.getPaginatorLabels();533 };534 $scope.stepPage = function(step) {535 step = parseInt(step);536 w.setCurrentPage(keepInBounds(w.getCurrentPage() + step, 0, getNumberOfPages() - 1));537 return $scope.pageSequence.realignGreedy(w.getCurrentPage());538 };539 $scope.goToPage = function(page) {540 return w.setCurrentPage(page);541 };542 $scope.jumpBack = function() {543 return $scope.stepPage(-w.getMaxPages());544 };545 $scope.jumpAhead = function() {546 return $scope.stepPage(w.getMaxPages());547 };548 $scope.pageSequence = new PageSequence();549 $scope.$watch(cvn.itemsPerPage, function() {550 return update();551 });552 $scope.$watch(cvn.maxPages, function() {553 return update();554 });555 $scope.$watch($attributes.atList, function() {556 return update();557 });558 $scope.$watch("" + $attributes.atList + ".length", function() {559 return update();560 });561 return update();562 }563 };564 }565 ]);566 angular.module("angular-table").directive("atImplicit", [567 function() {568 return {569 restrict: "AC",570 compile: function(element, attributes, transclude) {571 var attribute;572 attribute = element.attr("at-attribute");573 if (!attribute) {574 throw "at-implicit specified without at-attribute: " + (element.html());575 }576 return element.append("<span ng-bind='item." + attribute + "'></span>");577 }578 };579 }580 ]);...

Full Screen

Full Screen

Toby.spec.ts

Source:Toby.spec.ts Github

copy

Full Screen

...51 mystery: MysteryCard;52 option: TobyOption;53 toby: TobyInspectorStrategy;54}55function standardSetup(56 investigationMarker = 10,57 evidenceType: EvidenceType = EvidenceType.Clue,58 witnessEvidenceValue = 0,59): TobyStandardTest {60 const clue6 = evidence(6, evidenceType);61 const mystery = new MysteryCard([evidenceType], [ 1, 6 ]);62 const toby = strategy();63 const option = toby.buildOptions(turn(investigationMarker, witnessEvidenceValue), bot([mystery]))[0];64 expect(option).is.not.undefined;65 const bottomOrTop = option.action.onReveal(clue6);66 if (bottomOrTop === BottomOrTop.Top) {67 expect(toby.rememberedEvidence).deep.equals(clue6);68 } else {69 expect(toby.rememberedEvidence).is.undefined;70 }71 return { bottomOrTop, clue6, mystery, option, toby };72}73describe("TobyInspectorStrategy", function () {74 describe("buildTobyOnReveal", function () {75 it("puts the card on top if it would complete the investigation", function () {76 const { bottomOrTop } = standardSetup(14);77 expect(bottomOrTop).equals(BottomOrTop.Top);78 });79 it("puts the card on the bottom if it's too big", function () {80 const { bottomOrTop } = standardSetup(15);81 expect(bottomOrTop).equals(BottomOrTop.Bottom);82 });83 it("puts the card on the top if it could be used with a lead", function () {84 const { bottomOrTop } = standardSetup(15, EvidenceType.Witness);85 expect(bottomOrTop).equals(BottomOrTop.Top);86 });87 it("puts the card on the bottom if it would be too big for the lead", function () {88 const { bottomOrTop } = standardSetup(10, EvidenceType.Witness, 5);89 expect(bottomOrTop).equals(BottomOrTop.Bottom);90 });91 });92 describe("addCard", function () {93 it("updates the hand and resets rememberedEvidence", function () {94 const { clue6, mystery, toby } = standardSetup();95 expect(mystery.possibleCount).equals(2);96 expect(mystery.possibleValues).deep.equals([ 1, 6 ]);97 const before = toby.addCard(0, undefined, true, mystery);98 expect(before).deep.equals(clue6);99 expect(toby.rememberedEvidence).is.undefined;100 expect(mystery.possibleCount).equals(1);101 expect(mystery.possibleValues).deep.equals([6]);102 });103 });104 describe("sawEvidenceDealt", function () {105 it("resets rememberedEvidence", function () {106 const { toby } = standardSetup();107 expect(toby.rememberedEvidence).is.not.undefined;108 toby.sawEvidenceDealt();109 expect(toby.rememberedEvidence).is.undefined;110 });111 });112 describe("sawEvidenceReturned", function () {113 it("resets rememberedEvidence on shuffle", function () {114 const { toby } = standardSetup();115 expect(toby.rememberedEvidence).is.not.undefined;116 toby.sawEvidenceReturned([], BottomOrTop.Bottom, true);117 expect(toby.rememberedEvidence).is.undefined;118 });119 it("resets rememberedEvidence on Top+new evidence", function () {120 const { toby } = standardSetup();121 expect(toby.rememberedEvidence).is.not.undefined;122 toby.sawEvidenceReturned([evidence(5, EvidenceType.Witness)], BottomOrTop.Top, false);123 expect(toby.rememberedEvidence).is.undefined;124 });125 it("resets rememberedEvidence on Top+no evidence", function () {126 const { toby } = standardSetup();127 expect(toby.rememberedEvidence).is.not.undefined;128 toby.sawEvidenceReturned([], BottomOrTop.Top, false);129 expect(toby.rememberedEvidence).is.undefined;130 });131 it("resets rememberedEvidence on Bottom+seen evidence", function () {132 const { clue6, toby } = standardSetup();133 expect(toby.rememberedEvidence).is.not.undefined;134 toby.sawEvidenceReturned([clue6], BottomOrTop.Bottom, false);135 expect(toby.rememberedEvidence).is.undefined;136 });137 it("keeps rememberedEvidence on Top+seen evidence", function () {138 const { clue6, toby } = standardSetup();139 expect(toby.rememberedEvidence).is.not.undefined;140 toby.sawEvidenceReturned([clue6], BottomOrTop.Top, false);141 expect(toby.rememberedEvidence).deep.equals(clue6);142 });143 });...

Full Screen

Full Screen

standard.js

Source:standard.js Github

copy

Full Screen

1//======================================================================================================================2// IMPORTS3import { Deck } from "../../deck.js";4import { TileAdjacencyList } from "../tileadjacencylist.js";5import { TileType, Ports } from "../board.js";6//======================================================================================================================7//======================================================================================================================8/**9 * @file standard.js10 * @author cammatsui11 * @date 202112 */13//======================================================================================================================14//======================================================================================================================15/**16 * Objects describing the standard board setup.17 */18var standardSetup = {19//======================================================================================================================20 //==================================================================================================================21 /**22 * The structure for the standard setup.23 */24 boardStructure : {25 tileAdjacencies : [26 new TileAdjacencyList([-1, 1, 12, 11, -1, -1]), // 027 new TileAdjacencyList([-1, 2, 13, 12, 0, -1]), // 128 new TileAdjacencyList([-1, -1, 3, 13, 1, -1]), // 229 new TileAdjacencyList([-1, -1, 4, 14, 13, 2]), // 330 new TileAdjacencyList([-1, -1, -1, 5, 14, 3]), // 431 new TileAdjacencyList([4, -1, -1, 6, 15, 14]), // 532 new TileAdjacencyList([5, -1, -1, -1, 7, 15]), // 633 new TileAdjacencyList([15, 6, -1, -1, 8, 16]), // 734 new TileAdjacencyList([16, 7, -1, -1, -1, 9]), // 835 new TileAdjacencyList([17, 16, 8, -1, -1, 10]), // 936 new TileAdjacencyList([11, 17, 9, -1, -1, -1]), // 1037 new TileAdjacencyList([0, 12, 17, 10, -1, -1]), // 1138 new TileAdjacencyList([1, 13, 18, 17, 11, 0]), // 1239 new TileAdjacencyList([2, 3, 14, 18, 12, 1]), // 1340 new TileAdjacencyList([3, 4, 5, 15, 18, 13]), // 1441 new TileAdjacencyList([14, 5, 6, 7, 16, 18]), // 1542 new TileAdjacencyList([18, 15, 7, 8, 9, 17]), // 1643 new TileAdjacencyList([12, 18, 16, 9, 10, 11]), // 1744 new TileAdjacencyList([12, 13, 14, 15, 16, 17]) // 1845 ],46 deserts : [18],47 portSpots : [48 [0, 5],49 [1, 0],50 [3, 0],51 [4, 1],52 [5, 2],53 [7, 2],54 [8, 3],55 [9, 4],56 [11, 4]57 ]58 } // boardStructure59 //==================================================================================================================60//======================================================================================================================61}; // var standardSetup62//======================================================================================================================63//======================================================================================================================64/**65 * Populate the <code>Deck</code>s for <code>boardPieces</code> and return <code>standardSetup</code>.66 * 67 * @returns The <code>standardSetup</code> object.68 */69export function getStandardSetup() {70 standardSetup.boardPieces = {71 tileDeck : Deck.deckFromArr([72 TileType.BRICK, TileType.BRICK, TileType.BRICK, 73 TileType.LUMBER, TileType.LUMBER, TileType.LUMBER, TileType.LUMBER,74 TileType.WOOL, TileType.WOOL, TileType.WOOL, TileType.WOOL,75 TileType.GRAIN, TileType.GRAIN, TileType.GRAIN, TileType.GRAIN,76 TileType.ORE, TileType.ORE, TileType.ORE,77 ]),78 numberDeck : Deck.deckFromArr([2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12]),79 portDeck : Deck.deckFromArr([80 Ports.MYSTERY, Ports.WOOL, Ports.MYSTERY, Ports.MYSTERY, Ports.BRICK, Ports.LUMBER, Ports.MYSTERY,81 Ports.GRAIN, Ports.ORE82 ])83 };84 return standardSetup;85} // getStandardSetup ()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var options = {3};4wptools.standardSetup(options);5var page = wptools.page('Albert Einstein');6page.get(function(err, info) {7 console.log(info);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptClient = wpt('www.webpagetest.org');3 console.log(data);4});5var wpt = require('webpagetest');6var wptClient = wpt('www.webpagetest.org');7 console.log(data);8});9var wpt = require('webpagetest');10var wptClient = wpt('www.webpagetest.org');11 console.log(data);12});13var wpt = require('webpagetest');14var wptClient = wpt('www.webpagetest.org');15 console.log(data);16});17var wpt = require('webpagetest');18var wptClient = wpt('www.webpagetest.org');19 console.log(data);20});21var wpt = require('webpagetest');22var wptClient = wpt('www.webpagetest.org');23 console.log(data);24});25var wpt = require('webpagetest');26var wptClient = wpt('www.webpagetest.org');27 console.log(data);28});29var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt-api').create('API_KEY');2wpt.standardSetup(url, function(err, data) {3 if (err) return console.error(err);4 console.log(data);5});6### wpt.standardSetup(url, options, callback)7var wpt = require('wpt-api').create('API_KEY');8var options = {9};10wpt.standardSetup(url, options, function(err, data) {11 if (err) return console.error(err);12 console.log(data);13});14### wpt.getTestResults(testId, callback)15var wpt = require('wpt-api').create('API_KEY');16var testId = 'XXXXX';17wpt.getTestResults(testId, function(err, data) {18 if (err) return console.error(err);19 console.log(data);20});21### wpt.getTestStatus(testId, callback)22var wpt = require('wpt-api').create('API_KEY');23var testId = 'XXXXX';24wpt.getTestStatus(testId, function(err, data) {25 if (err) return console.error(err);26 console.log(data);27});28### wpt.getLocations(callback)29var wpt = require('wpt-api').create('API_KEY');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webpagetest = wpt(options);5var params = {6};7webpagetest.runTest(url, params, function(err, data) {8 if (err) return console.error(err);9 console.log('Test status:', data.statusText);10 console.log('Test ID:', data.data.testId);11 console.log('Test results available at:', data.data.userUrl);12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.75e1f7b8a0c1b9d6f9c6b7e8e0d6f7d6');3var options = {4};5 if (err) return console.error(err);6 console.log('Test submitted successfully. View your test at: %s', data.data.userUrl);7});

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