How to use empty method in ng-mocks

Best JavaScript code snippet using ng-mocks

pagesModel.ts

Source:pagesModel.ts Github

copy

Full Screen

1export interface Pages {2 pages: Page[];3 showCompletedPage: boolean;4 showQuestionNumbers: string;5 showProgressBar: string;6 goNextPageAutomatic: boolean;7 pagePrevText: string;8 pageNextText: string;9 requiredText: string;10}11export interface Page {12 name: string;13 elements: PageElement[];14}15export interface PageElement {16 type: ElementType;17 name: string;18 elements?: PurpleElement[];19 visibleIf?: string;20 html?: string;21 title?: string;22}23export interface PurpleElement {24 type: ElementType;25 name: string;26 html?: string;27 visibleIf?: string;28 titleLocation?: TitleLocation;29 choices?: PurpleChoice[];30 elements?: FluffyElement[];31 title?: string;32 isRequired?: boolean;33 description?: Description;34 validators?: Validator[];35 defaultValue?: DefaultValue;36 placeHolder?: DefaultValue;37 inputType?: string;38 columns?: Column[];39 cellType?: CellType;40 rows?: Row[];41}42export enum CellType {43 Boolean = "boolean",44 Text = "text",45}46export interface PurpleChoice {47 value: string;48 text: string;49 visibleIf?: string;50}51export interface Column {52 name: Name;53 title: Title;54 cellType: CellType;55 validators?: Validator[];56 placeHolder?: DefaultValue;57 enableIf?: EnableIf;58 defaultValue?: string;59}60export enum EnableIf {61 BROTHERDEATHAGEEmptyAndRowEndEmpty = "{BROTHER_DEATH_AGE} empty and {row.end} empty",62 DAUGHTERDEATHAGEEmptyAndRowEndEmpty = "{DAUGHTER_DEATH_AGE} empty and {row.end} empty",63 FATHERDEATHAGEEmptyAndRowEndEmpty = "{FATHER_DEATH_AGE} empty and {row.end} empty",64 MATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",65 MATERNALGRANDFATHERDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",66 MATERNALGRANDMOTHERDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",67 MATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",68 MOTHERDEATHAGEEmptyAndRowEndEmpty = "{MOTHER_DEATH_AGE} empty and {row.end} empty",69 PATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",70 PATERNALGRANDFATHERDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",71 PATERNALGRANDMOTHERDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",72 PATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",73 RowEndEmpty = "{row.end} empty",74 RowOngoingFalse = "{row.ongoing} = false",75 SECONDBROTHERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_BROTHER_DEATH_AGE} empty and {row.end} empty",76 SECONDDAUGHTERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_DAUGHTER_DEATH_AGE} empty and {row.end} empty",77 SECONDMATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",78 SECONDMATERNALUNCLEAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_UNCLE_AUNT_DEATH_AGE} empty and {row.end} empty",79 SECONDMATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{SECOND_MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",80 SECONDPATERNALAUNTDEATHAGEEmptyAndRowEndEmpty = "{SECOND_PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",81 SECONDPATERNALUNCLEDEATHAGEEmptyAndRowEndEmpty = "{SECOND_PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",82 SECONDSISTERDEATHAGEEmptyAndRowEndEmpty = "{SECOND_SISTER_DEATH_AGE} empty and {row.end} empty",83 SECONDSONDEATHAGEEmptyAndRowEndEmpty = "{SECOND_SON_DEATH_AGE} empty and {row.end} empty",84 SISTERDEATHAGEEmptyAndRowEndEmpty = "{SISTER_DEATH_AGE} empty and {row.end} empty",85 SONDEATHAGEEmptyAndRowEndEmpty = "{SON_DEATH_AGE} empty and {row.end} empty",86}87export enum Name {88 End = "end",89 Ongoing = "ongoing",90 Start = "start",91}92export enum DefaultValue {93 Yyyy = "YYYY",94}95export enum Title {96 End = "End",97 Ongoing = "Ongoing",98 Start = "Start",99}100export interface Validator {101 type: ValidatorType;102 text: Text;103 expression: string;104}105export enum Text {106 PleaseEnterAValidAge = "Please enter a valid age",107 PleaseEnterAValidYear = "Please enter a valid year",108 PleaseEnterAValidYearOfEndIllness = "Please enter a valid year of end Illness",109 PleaseEnterAValidYearOfStartIllness = "Please enter a valid year of start Illness",110}111export enum ValidatorType {112 Expression = "expression",113}114export enum Description {115 IfYouDonTKnowGiveYourBestGuess = "If you don't know, give your best guess",116 SelectAllThatApply = "Select all that apply.",117}118export interface FluffyElement {119 type: ElementType;120 name: string;121 visibleIf: string;122 title: string;123 choices: FluffyChoice[];124}125export interface FluffyChoice {126 value: string;127 text: string;128}129export enum ElementType {130 Checkbox = "checkbox",131 HTML = "html",132 Matrixdropdown = "matrixdropdown",133 Panel = "panel",134 Radiogroup = "radiogroup",135 Text = "text",136}137export interface Row {138 value: number | string;139 text: string;140 visibleIf: string;141}142export enum TitleLocation {143 Hidden = "hidden",144}145// Converts JSON strings to/from your types146// and asserts the results of JSON.parse at runtime147export class Convert {148 public static toPages(json: string): Pages {149 return cast(JSON.parse(json), r("Pages"));150 }151 public static pagesToJson(value: Pages): string {152 return JSON.stringify(uncast(value, r("Pages")), null, 2);153 }154}155function invalidValue(typ: any, val: any, key: any = ''): never {156 if (key) {157 throw Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`);158 }159 throw Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`, );160}161function jsonToJSProps(typ: any): any {162 if (typ.jsonToJS === undefined) {163 const map: any = {};164 typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });165 typ.jsonToJS = map;166 }167 return typ.jsonToJS;168}169function jsToJSONProps(typ: any): any {170 if (typ.jsToJSON === undefined) {171 const map: any = {};172 typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });173 typ.jsToJSON = map;174 }175 return typ.jsToJSON;176}177function transform(val: any, typ: any, getProps: any, key: any = ''): any {178 function transformPrimitive(typ: string, val: any): any {179 if (typeof typ === typeof val) return val;180 return invalidValue(typ, val, key);181 }182 function transformUnion(typs: any[], val: any): any {183 // val must validate against one typ in typs184 const l = typs.length;185 for (let i = 0; i < l; i++) {186 const typ = typs[i];187 try {188 return transform(val, typ, getProps);189 } catch (_) {}190 }191 return invalidValue(typs, val);192 }193 function transformEnum(cases: string[], val: any): any {194 if (cases.indexOf(val) !== -1) return val;195 return invalidValue(cases, val);196 }197 function transformArray(typ: any, val: any): any {198 // val must be an array with no invalid elements199 if (!Array.isArray(val)) return invalidValue("array", val);200 return val.map(el => transform(el, typ, getProps));201 }202 function transformDate(val: any): any {203 if (val === null) {204 return null;205 }206 const d = new Date(val);207 if (isNaN(d.valueOf())) {208 return invalidValue("Date", val);209 }210 return d;211 }212 function transformObject(props: { [k: string]: any }, additional: any, val: any): any {213 if (val === null || typeof val !== "object" || Array.isArray(val)) {214 return invalidValue("object", val);215 }216 const result: any = {};217 Object.getOwnPropertyNames(props).forEach(key => {218 const prop = props[key];219 const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;220 result[prop.key] = transform(v, prop.typ, getProps, prop.key);221 });222 Object.getOwnPropertyNames(val).forEach(key => {223 if (!Object.prototype.hasOwnProperty.call(props, key)) {224 result[key] = transform(val[key], additional, getProps, key);225 }226 });227 return result;228 }229 if (typ === "any") return val;230 if (typ === null) {231 if (val === null) return val;232 return invalidValue(typ, val);233 }234 if (typ === false) return invalidValue(typ, val);235 while (typeof typ === "object" && typ.ref !== undefined) {236 typ = typeMap[typ.ref];237 }238 if (Array.isArray(typ)) return transformEnum(typ, val);239 if (typeof typ === "object") {240 return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)241 : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)242 : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)243 : invalidValue(typ, val);244 }245 // Numbers can be parsed by Date but shouldn't be.246 if (typ === Date && typeof val !== "number") return transformDate(val);247 return transformPrimitive(typ, val);248}249function cast<T>(val: any, typ: any): T {250 return transform(val, typ, jsonToJSProps);251}252function uncast<T>(val: T, typ: any): any {253 return transform(val, typ, jsToJSONProps);254}255function a(typ: any) {256 return { arrayItems: typ };257}258function u(...typs: any[]) {259 return { unionMembers: typs };260}261function o(props: any[], additional: any) {262 return { props, additional };263}264function m(additional: any) {265 return { props: [], additional };266}267function r(name: string) {268 return { ref: name };269}270const typeMap: any = {271 "Pages": o([272 { json: "pages", js: "pages", typ: a(r("Page")) },273 { json: "showCompletedPage", js: "showCompletedPage", typ: true },274 { json: "showQuestionNumbers", js: "showQuestionNumbers", typ: "" },275 { json: "showProgressBar", js: "showProgressBar", typ: "" },276 { json: "goNextPageAutomatic", js: "goNextPageAutomatic", typ: true },277 { json: "pagePrevText", js: "pagePrevText", typ: "" },278 { json: "pageNextText", js: "pageNextText", typ: "" },279 { json: "requiredText", js: "requiredText", typ: "" },280 ], false),281 "Page": o([282 { json: "name", js: "name", typ: "" },283 { json: "elements", js: "elements", typ: a(r("PageElement")) },284 ], false),285 "PageElement": o([286 { json: "type", js: "type", typ: r("ElementType") },287 { json: "name", js: "name", typ: "" },288 { json: "elements", js: "elements", typ: u(undefined, a(r("PurpleElement"))) },289 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },290 { json: "html", js: "html", typ: u(undefined, "") },291 { json: "title", js: "title", typ: u(undefined, "") },292 ], false),293 "PurpleElement": o([294 { json: "type", js: "type", typ: r("ElementType") },295 { json: "name", js: "name", typ: "" },296 { json: "html", js: "html", typ: u(undefined, "") },297 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },298 { json: "titleLocation", js: "titleLocation", typ: u(undefined, r("TitleLocation")) },299 { json: "choices", js: "choices", typ: u(undefined, a(r("PurpleChoice"))) },300 { json: "elements", js: "elements", typ: u(undefined, a(r("FluffyElement"))) },301 { json: "title", js: "title", typ: u(undefined, "") },302 { json: "isRequired", js: "isRequired", typ: u(undefined, true) },303 { json: "description", js: "description", typ: u(undefined, r("Description")) },304 { json: "validators", js: "validators", typ: u(undefined, a(r("Validator"))) },305 { json: "defaultValue", js: "defaultValue", typ: u(undefined, r("DefaultValue")) },306 { json: "placeHolder", js: "placeHolder", typ: u(undefined, r("DefaultValue")) },307 { json: "inputType", js: "inputType", typ: u(undefined, "") },308 { json: "columns", js: "columns", typ: u(undefined, a(r("Column"))) },309 { json: "cellType", js: "cellType", typ: u(undefined, r("CellType")) },310 { json: "rows", js: "rows", typ: u(undefined, a(r("Row"))) },311 ], false),312 "PurpleChoice": o([313 { json: "value", js: "value", typ: "" },314 { json: "text", js: "text", typ: "" },315 { json: "visibleIf", js: "visibleIf", typ: u(undefined, "") },316 ], false),317 "Column": o([318 { json: "name", js: "name", typ: r("Name") },319 { json: "title", js: "title", typ: r("Title") },320 { json: "cellType", js: "cellType", typ: r("CellType") },321 { json: "validators", js: "validators", typ: u(undefined, a(r("Validator"))) },322 { json: "placeHolder", js: "placeHolder", typ: u(undefined, r("DefaultValue")) },323 { json: "enableIf", js: "enableIf", typ: u(undefined, r("EnableIf")) },324 { json: "defaultValue", js: "defaultValue", typ: u(undefined, "") },325 ], false),326 "Validator": o([327 { json: "type", js: "type", typ: r("ValidatorType") },328 { json: "text", js: "text", typ: r("Text") },329 { json: "expression", js: "expression", typ: "" },330 ], false),331 "FluffyElement": o([332 { json: "type", js: "type", typ: r("ElementType") },333 { json: "name", js: "name", typ: "" },334 { json: "visibleIf", js: "visibleIf", typ: "" },335 { json: "title", js: "title", typ: "" },336 { json: "choices", js: "choices", typ: a(r("FluffyChoice")) },337 ], false),338 "FluffyChoice": o([339 { json: "value", js: "value", typ: "" },340 { json: "text", js: "text", typ: "" },341 ], false),342 "Row": o([343 { json: "value", js: "value", typ: u(0, "") },344 { json: "text", js: "text", typ: "" },345 { json: "visibleIf", js: "visibleIf", typ: "" },346 ], false),347 "CellType": [348 "boolean",349 "text",350 ],351 "EnableIf": [352 "{BROTHER_DEATH_AGE} empty and {row.end} empty",353 "{DAUGHTER_DEATH_AGE} empty and {row.end} empty",354 "{FATHER_DEATH_AGE} empty and {row.end} empty",355 "{MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",356 "{MATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",357 "{MATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",358 "{MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",359 "{MOTHER_DEATH_AGE} empty and {row.end} empty",360 "{PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",361 "{PATERNAL_GRANDFATHER_DEATH_AGE} empty and {row.end} empty",362 "{PATERNAL_GRANDMOTHER_DEATH_AGE} empty and {row.end} empty",363 "{PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",364 "{row.end} empty",365 "{row.ongoing} = false",366 "{SECOND_BROTHER_DEATH_AGE} empty and {row.end} empty",367 "{SECOND_DAUGHTER_DEATH_AGE} empty and {row.end} empty",368 "{SECOND_MATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",369 "{SECOND_MATERNAL_UNCLE_AUNT_DEATH_AGE} empty and {row.end} empty",370 "{SECOND_MATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",371 "{SECOND_PATERNAL_AUNT_DEATH_AGE} empty and {row.end} empty",372 "{SECOND_PATERNAL_UNCLE_DEATH_AGE} empty and {row.end} empty",373 "{SECOND_SISTER_DEATH_AGE} empty and {row.end} empty",374 "{SECOND_SON_DEATH_AGE} empty and {row.end} empty",375 "{SISTER_DEATH_AGE} empty and {row.end} empty",376 "{SON_DEATH_AGE} empty and {row.end} empty",377 ],378 "Name": [379 "end",380 "ongoing",381 "start",382 ],383 "DefaultValue": [384 "YYYY",385 ],386 "Title": [387 "End",388 "Ongoing",389 "Start",390 ],391 "Text": [392 "Please enter a valid age",393 "Please enter a valid year",394 "Please enter a valid year of end Illness",395 "Please enter a valid year of start Illness",396 ],397 "ValidatorType": [398 "expression",399 ],400 "Description": [401 "If you don't know, give your best guess",402 "Select all that apply.",403 ],404 "ElementType": [405 "checkbox",406 "html",407 "matrixdropdown",408 "panel",409 "radiogroup",410 "text",411 ],412 "TitleLocation": [413 "hidden",414 ],...

Full Screen

Full Screen

argument-types.js

Source:argument-types.js Github

copy

Full Screen

1description("Tests the acceptable types for arguments to Geolocation methods.");2function shouldNotThrow(expression)3{4 try {5 eval(expression);6 testPassed(expression + " did not throw exception.");7 } catch(e) {8 testFailed(expression + " should not throw exception. Threw exception " + e);9 }10}11function test(expression, expressionShouldThrow, expectedException) {12 if (expressionShouldThrow) {13 if (expectedException)14 shouldThrow(expression, '(function() { return "' + expectedException + '"; })();');15 else16 shouldThrow(expression, '(function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();');17 } else {18 shouldNotThrow(expression);19 }20}21var emptyFunction = function() {};22function ObjectThrowingException() {};23ObjectThrowingException.prototype.valueOf = function() {24 throw new Error('valueOf threw exception');25}26ObjectThrowingException.prototype.__defineGetter__("enableHighAccuracy", function() {27 throw new Error('enableHighAccuracy getter exception');28});29var objectThrowingException = new ObjectThrowingException();30test('navigator.geolocation.getCurrentPosition()', true);31test('navigator.geolocation.getCurrentPosition(undefined)', true);32test('navigator.geolocation.getCurrentPosition(null)', true);33test('navigator.geolocation.getCurrentPosition({})', true);34test('navigator.geolocation.getCurrentPosition(objectThrowingException)', true);35test('navigator.geolocation.getCurrentPosition(emptyFunction)', false);36//test('navigator.geolocation.getCurrentPosition(Math.abs)', false);37test('navigator.geolocation.getCurrentPosition(true)', true);38test('navigator.geolocation.getCurrentPosition(42)', true);39test('navigator.geolocation.getCurrentPosition(Infinity)', true);40test('navigator.geolocation.getCurrentPosition(-Infinity)', true);41test('navigator.geolocation.getCurrentPosition("string")', true);42test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);43test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', false);44test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true);45test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true);46test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', false);47//test('navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs)', false);48test('navigator.geolocation.getCurrentPosition(emptyFunction, true)', true);49test('navigator.geolocation.getCurrentPosition(emptyFunction, 42)', true);50test('navigator.geolocation.getCurrentPosition(emptyFunction, Infinity)', true);51test('navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity)', true);52test('navigator.geolocation.getCurrentPosition(emptyFunction, "string")', true);53test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined)', false);54test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null)', false);55test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {})', false);56test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectThrowingException)', true, 'Error: enableHighAccuracy getter exception');57test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction)', false);58test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true)', false);59test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42)', false);60test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity)', false);61test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity)', false);62test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string")', false);63test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined})', false);64test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:null})', false);65test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:{}})', false);66test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:objectThrowingException})', false);67test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction})', false);68test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true})', false);69test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42})', false);70test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity})', false);71test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity})', false);72test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"})', false);73test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined})', false);74test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:null})', false);75test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:{}})', false);76test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:objectThrowingException})', false);77test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction})', false);78test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true})', false);79test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42})', false);80test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity})', false);81test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity})', false);82test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"})', false);83test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined})', false);84test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:null})', false);85test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:{}})', false);86test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:objectThrowingException})', true, 'Error: valueOf threw exception');87test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction})', false);88test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true})', false);89test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42})', false);90test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity})', false);91test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity})', false);92test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"})', false);93test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined})', false);94test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:null})', false);95test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:{}})', false);96test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:objectThrowingException})', true, 'Error: valueOf threw exception');97test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction})', false);98test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true})', false);99test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42})', false);100test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity})', false);101test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity})', false);102test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"})', false);103window.jsTestIsAsync = false;...

Full Screen

Full Screen

patternfly.dataTables.pfEmpty.js

Source:patternfly.dataTables.pfEmpty.js Github

copy

Full Screen

1/**2 * @summary pfEmpty for DataTables3 * @description A collection of API methods providing functionality to hide and show elements when DataTables is empty.4 * This ensures DataTables meets the Patternfly design pattern with a toolbar and empty state.5 *6 * When DataTable is redrawn and data length is zero, controls under the toolbar-pf-actions and toolbar-pf-results7 * classes are disabled; including the filter drop down, filter input, action buttons, kebab, find, etc. (You may8 * re-enable specific controls via the DataTables "draw.dt" event.) In addition, the DataTables empty table header and9 * row are hidden while the empty state (i.e., blank slate) layout is shown.10 *11 * The toolbar and empty state layouts are expected to contain the classes as shown in the example below.12 *13 * Example:14 *15 * <!-- NOTE: Some configuration may be omitted for clarity -->16 * <div class="row toolbar-pf table-view-pf-toolbar" id="toolbar1">17 * <div class="col-sm-12">18 * <form class="toolbar-pf-actions">19 * ...20 * </form>21 * <div class="row toolbar-pf-results">22 * ...23 * </div>24 * </div>25 * </div>26 * <table class="table table-striped table-bordered table-hover" id="table1">27 * <thead>28 * <tr>29 * <th><input type="checkbox" name="selectAll"></th>30 * <th>Rendering Engine</th>31 * <th>Browser</th>32 * </tr>33 * </thead>34 * </table>35 * <div class="blank-slate-pf table-view-pf-empty hidden" id="emptyState1">36 * <div class="blank-slate-pf-icon">37 * <span class="pficon pficon pficon-add-circle-o"></span>38 * </div>39 * <h1>Empty State Title</h1>40 * ...41 * </div>42 * <script>43 * // NOTE: Some properties may be omitted for clarity44 * $(document).ready(function() {45 * var dt = $("#table1").DataTable({46 * columns: [47 * { data: null, ... },48 * { data: "engine" },49 * { data: "browser" }50 * ],51 * data: null,52 * dom: "t",53 * pfConfig: {54 * emptyStateSelector: "#{{include.emptyStateId}}",55 * ...56 * toolbarSelector: "#{{include.toolbarId}}"57 * }58 * });59 * dt.table().pfEmpty.updateState(); // Optional API to force update60 * });61 * </script>62 *63 * Note: This functionality requires the following Javascript library files to be loaded:64 *65 * https://cdn.datatables.net/select/1.2.0/js/dataTables.select.min.js66 */67(function (factory) {68 "use strict";69 if (typeof define === "function" && define.amd ) {70 // AMD71 define (["jquery", "datatables.net"], function ($) {72 return factory ($, window, document);73 });74 } else if (typeof exports === "object") {75 // CommonJS76 module.exports = function (root, $) {77 if (!root) {78 root = window;79 }80 if (!$ || !$.fn.dataTable) {81 $ = require("datatables.net")(root, $).$;82 }83 return factory($, root, root.document);84 };85 } else {86 // Browser87 factory(jQuery, window, document);88 }89}(function ($, window, document, undefined) {90 "use strict";91 var DataTable = $.fn.dataTable;92 var ACTIONS_SELECTOR = ".toolbar-pf-actions"; // Toolbar actions93 var RESULTS_SELECTOR = ".toolbar-pf-results"; // Toolbar results row94 DataTable.pfEmpty = {};95 /**96 * Initialize97 *98 * @param {DataTable.Api} dt DataTable99 * @private100 */101 DataTable.pfEmpty.init = function (dt) {102 var ctx = dt.settings()[0];103 var opts = (ctx.oInit.pfConfig) ? ctx.oInit.pfConfig : {};104 ctx._pfEmpty = {};105 ctx._pfEmpty.emptyState = $(opts.emptyStateSelector); // Empty state (Blank slate)106 ctx._pfEmpty.isEmptyState = false; // Flag indicating DatTable entered an empty state107 ctx._pfEmpty.tbody = $("tbody", dt.table().container()); // Table body108 ctx._pfEmpty.thead = $("thead", dt.table().container()); // Table head109 ctx._pfEmpty.toolbarActions = $(ACTIONS_SELECTOR, opts.toolbarSelector); // Toolbar actions110 ctx._pfEmpty.toolbarResults = $(RESULTS_SELECTOR, opts.toolbarSelector); // Toolbar results row111 // Update table on DataTables draw event112 dt.on("draw.dt", function () {113 updateState(dt);114 });115 // Initialize116 updateState(dt);117 };118 // Local functions119 /**120 * Disable and hide elements when DataTables has no data121 *122 * @param {DataTable.Api} dt DataTable123 * @private124 */125 function updateEmptyState (dt) {126 var ctx = dt.settings()[0];127 // Show blank slate128 if (ctx._pfEmpty.emptyState !== undefined && ctx._pfEmpty.emptyState.length !== 0) {129 ctx._pfEmpty.emptyState.removeClass("hidden");130 }131 // Hide zero records message132 if (ctx._pfEmpty.tbody !== undefined && ctx._pfEmpty.tbody.length !== 0) {133 ctx._pfEmpty.tbody.addClass("hidden");134 }135 // Hide column headers136 if (ctx._pfEmpty.thead !== undefined && ctx._pfEmpty.thead.length !== 0) {137 ctx._pfEmpty.thead.addClass("hidden");138 }139 // Disable all buttons140 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {141 $("button", ctx._pfEmpty.toolbarActions).prop("disabled", true);142 }143 // Disable all inputs144 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {145 $("input", ctx._pfEmpty.toolbarActions).prop("disabled", true);146 }147 // Hide results container148 if (ctx._pfEmpty.toolbarResults !== undefined && ctx._pfEmpty.toolbarResults.length !== 0) {149 ctx._pfEmpty.toolbarResults.children().addClass("hidden");150 }151 // Enable on empty152 if (ctx._pfEmpty.enableOnEmpty !== undefined) {153 $(ctx._pfEmpty.enableOnEmpty).prop("disabled", false);154 }155 // Enable on empty156 if (ctx._pfEmpty.enableOnEmpty !== undefined) {157 $(ctx._pfEmpty.enableOnEmpty).prop("disabled", false);158 }159 }160 /**161 * Enable and show elements when DataTables has data162 *163 * @param {DataTable.Api} dt DataTable164 * @private165 */166 function updateNonEmptyState (dt) {167 var ctx = dt.settings()[0];168 // Hide blank slate169 if (ctx._pfEmpty.emptyState !== undefined && ctx._pfEmpty.emptyState.length !== 0) {170 ctx._pfEmpty.emptyState.addClass("hidden");171 }172 // Show table body173 if (ctx._pfEmpty.tbody !== undefined && ctx._pfEmpty.tbody.length !== 0) {174 ctx._pfEmpty.tbody.removeClass("hidden");175 }176 // Show column headers177 if (ctx._pfEmpty.thead !== undefined && ctx._pfEmpty.thead.length !== 0) {178 ctx._pfEmpty.thead.removeClass("hidden");179 }180 // Enable all buttons181 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {182 $("button", ctx._pfEmpty.toolbarActions).prop("disabled", false);183 }184 // Enable all inputs185 if (ctx._pfEmpty.toolbarActions !== undefined && ctx._pfEmpty.toolbarActions.length !== 0) {186 $("input", ctx._pfEmpty.toolbarActions).prop("disabled", false);187 }188 // Show results container189 if (ctx._pfEmpty.toolbarResults !== undefined && ctx._pfEmpty.toolbarResults.length !== 0) {190 ctx._pfEmpty.toolbarResults.children().removeClass("hidden");191 }192 }193 /**194 * Update elements upon empty DataTable state195 *196 * @param {DataTable.Api} dt DataTable197 * @private198 */199 function updateState (dt) {200 var ctx = dt.settings()[0];201 // Don't enable or show elements unless DataTable was empty202 if (dt.data().length === 0) {203 ctx._pfEmpty.isEmptyState = true;204 updateEmptyState(dt);205 } else if (ctx._pfEmpty.isEmptyState === true) {206 ctx._pfEmpty.isEmptyState = false;207 updateNonEmptyState(dt);208 }209 }210 // DataTables API211 /**212 * Update state upon empty or non-empty DataTable213 *214 * Example: dt.table().pfEmpty.updateState();215 */216 DataTable.Api.register("pfEmpty.updateState()", function () {217 return this.iterator("table", function (ctx) {218 update(new DataTable.Api(ctx));219 });220 });221 // DataTables creation222 $(document).on("init.dt", function (e, ctx, json) {223 if (e.namespace !== "dt") {224 return;225 }226 DataTable.pfEmpty.init(new DataTable.Api(ctx));227 });228 return DataTable.pfEmpty;...

Full Screen

Full Screen

validate.py

Source:validate.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import re3class validate:4 def __init__(self):5 pass6 def phone(self, value, isEmpty=False):7 "validate phone"8 reg = '^1[3458]\d{9}$'9 p = re.compile(reg)10 return (value == '' and isEmpty) or p.match(value)11 def mobile(self, value, isEmpty=False):12 "validate mobile"13 reg = '^(\d{3}-|\d{4}-)?(\d{8}|\d{7})$'14 p = re.compile(reg)15 return (value == '' and isEmpty) or p.match(value)16 def contact1(self, value, isEmpty=False):17 "validate contact"18 reg = '^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$'19 p = re.compile(reg)20 return (value == '' and isEmpty) or p.match(value)21 def contact(self, value, isEmpty=False):22 "validate contact"23 return self.phone(value, isEmpty) or self.mobile(value, isEmpty)24 def qq(self, value, isEmpty=False):25 "validate qq"26 reg = '^[1-9]\d{4,12}$'27 p = re.compile(reg)28 return (value == '' and isEmpty) or p.match(str(value))29 def url(self, value, isEmpty=False):30 "validate url"31 reg = '^(http|https):\/\/[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]{2,}[A-Za-z0-9\.\/=\?%\-&_~`@[\]:+!;]*$'32 p = re.compile(reg)33 return (value == '' and isEmpty) or p.match(value)34 def ip(self, value, isEmpty=False):35 "validate ip"36 reg = '^(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5]).(0|[1-9]\d?|[0-1]\d{2}|2[0-4]\d|25[0-5])$'37 p = re.compile(reg)38 return (value == '' and isEmpty) or p.match(value)39 def int(self, value, isEmpty=False):40 "validate int"41 reg = '^\-?\d+$'42 p = re.compile(reg)43 return (value == '' and isEmpty) or p.match(value)44 def mac(self, value, isEmpty=False):45 "validate mac"46 reg_1 = '[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}'47 reg_2 = '[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}-[A-F\d]{2}'48 p_1 = re.compile(reg_1)49 p_2 = re.compile(reg_2)50 return (value == '' and isEmpty) or p_1.match(value) or p_2.match(value)51 def plus(self, value, isEmpty=False):52 "validate plus"53 reg = '^[1-9]\d*$'54 p = re.compile(reg)55 return (value == '' and isEmpty) or p.match(value)56 def number(self, value, isEmpty=False):57 "validate number"58 reg = '^[0-9]+$'59 p = re.compile(reg)60 return (value == '' and isEmpty) or p.match(value)61 def notsc(self, value, isEmpty=False):62 "validate notsc"63 reg = ur'^[-a-zA-Z0-9_\u4e00-\u9fa5\s]+$'64 p = re.compile(reg)65 return (value == '' and isEmpty) or p.match(value)66 def letter(self, value, isEmpty=False):67 "validate letter"68 reg = '^[a-zA-Z]+$'69 p = re.compile(reg)70 return (value == '' and isEmpty) or p.match(value)71 def letterOrNum(self, value, isEmpty=False):72 "validate letter or number"73 reg = '^[0-9a-zA-Z]+$'74 p = re.compile(reg)75 return (value == '' and isEmpty) or p.match(value)76 def legalityName(self, value, isEmpty=False):77 "validate legalityName"78 reg = '^[-a-zA-Z0-9_]+$'79 p = re.compile(reg)80 return (value == '' and isEmpty) or p.match(value)81 def email(self, value, isEmpty=False):82 "validate email"83 #reg=r"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$"84 reg = r"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"85 p = re.compile(reg)86 return (value == '' and isEmpty) or p.match(value)87 def email1(self, value, isEmpty=False):88 reg = ur'^[_a-zA-Z\d@.-]+$';89 p = re.compile(reg)90 return (value == '' and isEmpty) or p.match(value)91 def period(self, value, isEmpty=False):92 va = value.split(':')93 if len(va) != 2: return False94 try:95 return not (int(va[0]) > 23 or int(va[1]) > 59 or int(va[1]) < 0)96 except:97 return False98 return True99 def onlyLetterUrl(self, value, isEmpty=False):100 "validate onlyLetterUrl"101 reg = r"^[a-zA-Z0-9.:/?#=]+$"102 p = re.compile(reg)...

Full Screen

Full Screen

gridworld.py

Source:gridworld.py Github

copy

Full Screen

1ZOMBIE = "z"2CAR = "c"3ICE_CREAM = "i"4EMPTY = "*"5ZOMBIE_CAR = "zc"6CAR_ZOMBIE = "cz"7ICE_CREAM_CAR = "ic"8ITEMS = {9 ZOMBIE: 'ZOMBIE', 10 CAR: 'CAR', 11 ICE_CREAM: 'ICE_CREAM', 12 EMPTY: '',13 ZOMBIE_CAR : 'YOU DIE',14 CAR_ZOMBIE : 'YOU DIE',15 ICE_CREAM_CAR: 'YOU WIN'16}17'''18 Create the environment19'''20def create_grid_world():21 grid = [22 [ZOMBIE, EMPTY, EMPTY, EMPTY, EMPTY],23 [EMPTY, EMPTY, ZOMBIE, ZOMBIE, EMPTY],24 [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],25 [EMPTY, EMPTY, EMPTY, EMPTY, ICE_CREAM],26 [CAR, ZOMBIE, EMPTY, ZOMBIE, EMPTY]27 ]28 car_position = [4, 0]29 return grid, car_position30'''31 Make the movement of the zombies32'''33def update_zombies(grid):34 if grid[0][0] == ZOMBIE:35 grid[0][0] = EMPTY36 if grid[1][0] == EMPTY: grid[1][0] = ZOMBIE37 else: grid[1][0] += ZOMBIE38 else:39 grid[1][0] = EMPTY40 if grid[0][0] == EMPTY: grid[0][0] = ZOMBIE41 else: grid[0][0] += ZOMBIE42 if grid[1][2] == ZOMBIE:43 grid[1][2] = EMPTY44 if grid[2][2] == EMPTY: grid[2][2] = ZOMBIE45 else: grid[2][2] += ZOMBIE46 else:47 grid[2][2] = EMPTY48 if grid[1][2] == EMPTY: grid[1][2] = ZOMBIE49 else: grid[1][2] += ZOMBIE50 if grid[4][1] == ZOMBIE:51 grid[4][1] = EMPTY52 if grid[3][1] == EMPTY: grid[3][1] = ZOMBIE53 else: grid[3][1] += ZOMBIE54 else:55 grid[3][1] = EMPTY56 if grid[4][1] == EMPTY: grid[4][1] = ZOMBIE57 else: grid[4][1] += ZOMBIE58 if grid[4][3] == ZOMBIE:59 grid[4][3] = EMPTY60 if grid[3][3] == EMPTY: grid[3][3] = ZOMBIE61 else: grid[3][3] += ZOMBIE62 else:63 grid[3][3] = EMPTY64 if grid[4][3] == EMPTY: grid[4][3] = ZOMBIE65 else: grid[4][3] += ZOMBIE66'''67 Print the GridWorld68'''69def print_grid(grid):70 horizontal_wall = ('%10s' * 10) % ('----------', '----------', '----------', '----------', '----------', '----------', '----------', '----------', '----------', '----------')71 print(horizontal_wall)72 for line in grid:73 s = ('%10s' * 10) % (ITEMS[line[0]], '|', ITEMS[line[1]], '|', ITEMS[line[2]], '|', ITEMS[line[3]], '|', ITEMS[line[4]], '|')74 print(s)75 print(horizontal_wall)...

Full Screen

Full Screen

problem_319.py

Source:problem_319.py Github

copy

Full Screen

1FINAL_STATE = [2 [1, 2, 3],3 [4, 5, 6],4 [7, 8, None]5]6class Coord:7 def __init__(self, x, y):8 self.x = x9 self.y = y10 def __hash__(self):11 return hash((self.x, self.y))12 def __eq__(self, other):13 return self.x == other.x and self.y == other.y14 def __repr__(self):15 return "({}, {})".format(self.x, self.y)16def get_adj_nums(empty_pos, num_rows, num_cols):17 adj_nums = set()18 if empty_pos.x > 0:19 if empty_pos.y > 0:20 adj_nums.add(Coord(empty_pos.x - 1, empty_pos.y - 1))21 if empty_pos.y < num_cols - 1:22 adj_nums.add(Coord(empty_pos.x - 1, empty_pos.y + 1))23 if empty_pos.y < num_rows - 1:24 if empty_pos.y > 0:25 adj_nums.add(Coord(empty_pos.x + 1, empty_pos.y - 1))26 if empty_pos.y < num_cols - 1:27 adj_nums.add(Coord(empty_pos.x + 1, empty_pos.y + 1))28 return adj_nums29def play(grid, empty_pos, num_rows, num_cols):30 if grid == FINAL_STATE:31 return32 adj_nums = get_adj_nums(empty_pos, num_rows, num_cols)33 for adj_num in adj_nums:34 new_grid = grid.copy()35 new_grid[empty_pos.x][empty_pos.y] = grid[adj_num.x][adj_num.y]36 new_grid[adj_num.x][adj_num.y] = None37 return play(new_grid, adj_num, num_rows, num_cols)38def win_game(grid):39 empty_pos = None40 for x, row in enumerate(grid):41 for y, val in enumerate(row):42 if not val:43 empty_pos = Coord(x, y)44 play(grid, empty_pos, len(start), len(start[0]))45# Tests46start = [47 [1, 2, 3],48 [4, 5, None],49 [7, 8, 6]50]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('TestComponent', () => {2 let component: TestComponent;3 let fixture: ComponentFixture<TestComponent>;4 beforeEach(async(() => {5 TestBed.configureTestingModule({6 })7 .compileComponents();8 }));9 beforeEach(() => {10 fixture = TestBed.createComponent(TestComponent);11 component = fixture.componentInstance;12 fixture.detectChanges();13 });14 it('should create', () => {15 expect(component).toBeTruthy();16 });17});18import { Component, OnInit } from '@angular/core';19@Component({20})21export class TestComponent implements OnInit {22 constructor() { }23 ngOnInit() {24 }25}26import { async, ComponentFixture, TestBed } from '@angular/core/testing';27import { TestComponent } from './test.component';28import { MockBuilder, MockRender } from 'ng-mocks';29describe('TestComponent', () => {30 beforeEach(() => MockBuilder(TestComponent));31 it('should create', () => {32 expect(MockRender(TestComponent)).toBeDefined();33 });34});35h1 {36 color: red;37}38import { async, ComponentFixture, TestBed } from '@angular/core/testing';39import { TestComponent } from './test.component';40import { MockBuilder, MockRender } from 'ng-mocks';41describe('TestComponent', () => {42 beforeEach(() => MockBuilder(TestComponent));43 it('should create', () => {44 expect(MockRender(TestComponent)).toBeDefined();45 });46});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppComponent } from './app.component';3import { AppModule } from './app.module';4describe('AppComponent', () => {5 beforeEach(() => MockBuilder(AppComponent, AppModule));6 it('should create the app', () => {7 const fixture = MockRender(AppComponent);8 const app = fixture.point.componentInstance;9 expect(app).toBeTruthy();10 });11});12import { MockBuilder, MockRender } from 'ng-mocks';13import { AppComponent } from './app.component';14import { AppModule } from './app.module';15describe('AppComponent', () => {16 beforeEach(() => MockBuilder(AppComponent, AppModule));17 it('should create the app', () => {18 const fixture = MockRender(AppComponent);19 const app = fixture.point.componentInstance;20 expect(app).toBeTruthy();21 });22});23import { Component } from '@angular/core';24@Component({25})26export class AppComponent {27 title = 'app';28}29import { BrowserModule } from '@angular/platform-browser';30import { NgModule } from '@angular/core';31import { AppComponent } from './app.component';32@NgModule({33 imports: [34})35export class AppModule { }36 {{title}}37/* You can add global styles to this file, and also import other style files */38h1 {39 color: #369;40 font-family: Arial, Helvetica, sans-serif;41 font-size: 250%;42}43import { async, ComponentFixture, TestBed } from '@angular/core/testing';44import { AppComponent } from './app.component';45describe('AppComponent', () => {46 let component: AppComponent;47 let fixture: ComponentFixture<AppComponent>;48 beforeEach(async(() => {49 TestBed.configureTestingModule({50 })51 .compileComponents();52 }));53 beforeEach(() => {54 fixture = TestBed.createComponent(AppComponent);55 component = fixture.componentInstance;56 fixture.detectChanges();57 });58 it('should create the app', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockRender } from 'ng-mocks';2import { AppComponent } from './app.component';3describe('AppComponent', () => {4 beforeEach(() => MockRender(AppComponent));5 it('should create the app', () => {6 const fixture = MockRender(AppComponent);7 const app = fixture.debugElement.componentInstance;8 expect(app).toBeTruthy();9 });10 it(`should have as title 'app'`, () => {11 const fixture = MockRender(AppComponent);12 const app = fixture.debugElement.componentInstance;13 expect(app.title).toEqual('app');14 });15 it('should render title in a h1 tag', () => {16 const fixture = MockRender(AppComponent);17 fixture.detectChanges();18 const compiled = fixture.debugElement.nativeElement;19 expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');20 });21});22import { MockRender } from 'ng-mocks';23import { AppComponent } from './app.component';24describe('AppComponent', () => {25 beforeEach(() => MockRender(AppComponent));26 it('should create the app', () => {27 const fixture = MockRender(AppComponent);28 const app = fixture.debugElement.componentInstance;29 expect(app).toBeTruthy();30 });31 it(`should have as title 'app'`, () => {32 const fixture = MockRender(AppComponent);33 const app = fixture.debugElement.componentInstance;34 expect(app.title).toEqual('app');35 });36 it('should render title in a h1 tag', () => {37 const fixture = MockRender(AppComponent);38 fixture.detectChanges();39 const compiled = fixture.debugElement.nativeElement;40 expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');41 });42});43import { Component } from '@angular/core';44@Component({45})46export class AppComponent {47 title = 'app';48}49import { NgModule } from '@angular/core';50import { BrowserModule } from '@angular/platform-browser';51import { FormsModule } from '@

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockedComponentFixture, MockRender, ngMocks } from 'ng-mocks';2describe('AppComponent', () => {3 ngMocks.faster();4 let component: AppComponent;5 let fixture: MockedComponentFixture<AppComponent>;6 beforeEach(() => MockBuilder(AppComponent));7 beforeEach(() => {8 fixture = MockRender(AppComponent);9 component = fixture.point.componentInstance;10 });11 it('should create', () => {12 expect(component).toBeTruthy();13 });14 it('should have 0 items', () => {15 expect(component.items.length).toBe(0);16 });17 it('should have 0 items', () => {18 expect(ngMocks.empty('app-item')).toBeTruthy();19 });20});21import { Component, OnInit } from '@angular/core';22@Component({23})24export class AppComponent implements OnInit {25 items: string[] = [];26 ngOnInit() {27 setTimeout(() => {28 this.items = ['test'];29 }, 1000);30 }31}32import { Component, Input, OnInit } from '@angular/core';33@Component({34})35export class ItemComponent implements OnInit {36 @Input() item: string;37 ngOnInit() {38 }39}40<p>{{ item }}</p>41p {42 color: red;43}44import { MockBuilder, MockedComponentFixture, MockRender, ngMocks } from 'ng-mocks';45describe('ItemComponent', () => {46 ngMocks.faster();47 let component: ItemComponent;48 let fixture: MockedComponentFixture<ItemComponent>;49 beforeEach(() => MockBuilder(ItemComponent));50 beforeEach(() => {51 fixture = MockRender(ItemComponent);52 component = fixture.point.componentInstance;53 });54 it('should create', () => {55 expect(component).toBeTruthy();56 });57 it('should have 0 items', () => {58 expect(component.item).toBeFalsy();59 });60 it('should have 0 items', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { empty } from 'ng-mocks';2@Component({3 .test {4 color: red;5 }6})7class TestComponent {}8describe('TestComponent', () => {9 let component: TestComponent;10 let fixture: ComponentFixture<TestComponent>;11 beforeEach(async(() => {12 TestBed.configureTestingModule({13 })14 .compileComponents();15 }));16 beforeEach(() => {17 fixture = TestBed.createComponent(TestComponent);18 component = fixture.componentInstance;19 fixture.detectChanges();20 });21 it('should create', () => {22 expect(component).toBeTruthy();23 });24 it('should have a div with class test', () => {25 const div = fixture.debugElement.query(By.css('div.test'));26 expect(div).toBeTruthy();27 });28 it('should have a div with class test', () => {29 const div = fixture.debugElement.query(By.css('div.test'));30 expect(div).toBeTruthy();31 });32 it('should have a div with class test', () => {33 const div = fixture.debugElement.query(By.css('div.test'));34 expect(div).toBeTruthy();35 });36 it('should have a div with class test', () => {37 const div = fixture.debugElement.query(By.css('div.test'));38 expect(div).toBeTruthy();39 });40 it('should have a div with class test', () => {41 const div = fixture.debugElement.query(By.css('div.test'));42 expect(div).toBeTruthy();43 });44 it('should have a div with class test', () => {45 const div = fixture.debugElement.query(By.css('div.test'));46 expect(div).toBeTruthy();47 });48 it('should have a div with class test', () => {49 const div = fixture.debugElement.query(By.css('div.test'));50 expect(div).toBeTruthy();51 });52 it('should have a div with class test', () => {53 const div = fixture.debugElement.query(By.css('div.test'));54 expect(div).toBeTruthy();55 });56 it('should have a div with class test', () => {57 const div = fixture.debugElement.query(By.css('div.test'));58 expect(div).toBeTruthy();59 });60 it('should have a div with class test', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { empty } from 'ng-mocks';2it('should return an empty observable', () => {3 const service = TestBed.get(Service);4 const spy = spyOn(service, 'getData').and.callThrough();5 const result = service.getData();6 expect(spy).toHaveBeenCalled();7 expect(result).toEqual(empty());8});

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should use empty() method of ng-mocks', () => {2 const fixture = TestBed.createComponent(HomeComponent);3 const component = fixture.componentInstance;4 component.ngOnInit();5 expect(component.users).toBeEmpty();6});7it('should use empty() method of jasmine', () => {8 const fixture = TestBed.createComponent(HomeComponent);9 const component = fixture.componentInstance;10 component.ngOnInit();11 expect(component.users.length).toBe(0);12});13it('should use empty() method of jasmine', () => {14 const fixture = TestBed.createComponent(HomeComponent);15 const component = fixture.componentInstance;16 component.ngOnInit();17 expect(component.users.length).toBe(0);18});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('ng-mocks', () => {2 it('should be able to use empty method', () => {3 const mock = ngMocks.empty('myService');4 expect(mock).toBeDefined();5 });6});7describe('ng-mocks', () => {8 it('should be able to use empty method', () => {9 const mock = ngMocks.empty('myService');10 expect(mock).toBeDefined();11 });12});13describe('ng-mocks', () => {14 it('should be able to use empty method', () => {15 const mock = ngMocks.empty('myService');16 expect(mock).toBeDefined();17 });18});19describe('ng-mocks', () => {20 it('should be able to use empty method', () => {21 const mock = ngMocks.empty('myService');22 expect(mock).toBeDefined();23 });24});25describe('ng-mocks', () => {26 it('should be able to use empty method', () => {27 const mock = ngMocks.empty('myService');28 expect(mock).toBeDefined();29 });30});31describe('ng-mocks', () => {32 it('should be able to use empty method', () => {33 const mock = ngMocks.empty('myService');34 expect(mock).toBeDefined();35 });36});37describe('ng-mocks', () => {38 it('should be able to use empty method', () => {39 const mock = ngMocks.empty('myService');40 expect(mock).toBeDefined();41 });42});43describe('ng-mocks', () => {44 it('should be able to use empty method', () => {45 const mock = ngMocks.empty('myService');46 expect(mock).toBeDefined();47 });48});49describe('ng-mocks', () => {50 it('should be able to use empty method', () => {51 const mock = ngMocks.empty('myService');52 expect(mock).toBeDefined();53 });54});55describe('ng-mocks', () => {56 it('should

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 ng-mocks 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