How to use hasProperty method in chai

Best JavaScript code snippet using chai

request-handler.js

Source:request-handler.js Github

copy

Full Screen

1const endpoints = require("./endpoints");2const logger = require("./logger");3const ratelimit = require("./ratelimits");4function hasProperty(obj, prop) {5 return Object.prototype.hasOwnProperty.call(obj, prop);6}7const converter = {8 channel(channel) {9 return {10 id: channel.id,11 type: channel.type,12 guildId: channel.guild_id,13 position: channel.position,14 permissionOverwrites: (channel.permission_overwrites || []).map(overwrite => converter.overwrite(overwrite)),15 name: channel.name,16 topic: channel.topic,17 nsfw: channel.nsfw,18 bitrate: channel.bitrate,19 userLimit: channel.user_limit,20 parentId: channel.parent_id21 };22 },23 overwrite(overwrite) {24 return {25 id: overwrite.id,26 type: overwrite.type,27 allow: overwrite.allow,28 deny: overwrite.deny29 };30 },31 message(message) {32 return {33 id: message.id,34 channelId: message.channel_id,35 guildId: message.guild_id,36 authorId: message.author.id,37 content: message.content,38 attachments: message.attachments.map(attachment => converter.attachment(attachment)),39 pinned: message.pinned,40 reactions: (message.reactions || []).map(reaction => converter.reaction(reaction))41 };42 },43 attachment(attachment) {44 return {45 id: attachment.id,46 filename: attachment.filename,47 size: attachment.size,48 url: attachment.proxy_url,49 height: attachment.height,50 width: attachment.width51 };52 },53 reaction(reaction) {54 return {55 count: reaction.count,56 emojiId: reaction.emoji.id,57 emojiName: reaction.emoji.name58 };59 },60 guild(guild) {61 return {62 id: guild.id,63 name: guild.name,64 icon: guild.icon,65 splash: guild.splash,66 ownerId: guild.owner_id,67 permissions: guild.permission,68 region: guild.region,69 approximatememberCount: guild.approximate_member_count,70 approximatePresenceCount: guild.approximate_presence_count,71 roles: guild.roles.map(role => converter.role(role)),72 members: (guild.members || []).map(member => converter.member(member)),73 channels: (guild.channels || []).map(channel => converter.channel(channel))74 };75 },76 ban(ban) {77 return {78 user: converter.user(ban.user),79 reason: ban.reason80 };81 },82 member(member) {83 return {84 user: converter.user(member.user),85 nick: member.nick,86 roles: member.roles,87 joinedAt: member.joined_at88 };89 },90 user(user) {91 return {92 id: user.id,93 username: user.username,94 discriminator: user.discriminator,95 avatar: user.avatar,96 bot: !!user.bot97 };98 },99 role(role) {100 return {101 id: role.id,102 name: role.name,103 color: role.color,104 hoist: role.hoist,105 position: role.position,106 permissions: role.permissions,107 mentionable: role.mentionable108 };109 }110};111const embedConverter = data => {112 const embed = {};113 if(hasProperty(data, "title")) embed.title = data.title;114 if(hasProperty(data, "description")) embed.description = data.description;115 if(hasProperty(data, "url")) embed.url = data.url;116 if(hasProperty(data, "timestamp")) embed.timestamp = data.timestamp;117 if(hasProperty(data, "color")) embed.color = data.color;118 if(hasProperty(data, "image")) embed.image = { url: data.image.url };119 if(hasProperty(data, "thumbnail")) embed.thumbnail = { url: data.thumbnail.url };120 if(hasProperty(data, "footer")) {121 embed.footer = { text: data.footer.text };122 if(hasProperty(data.footer, "iconUrl")) embed.footer.icon_url = data.footer.iconUrl;123 }124 if(hasProperty(data, "author")) {125 embed.author = {};126 if(hasProperty(data.author, "name")) embed.author.name = data.author.name;127 if(hasProperty(data.author, "url")) embed.author.url = data.author.url;128 if(hasProperty(data.author, "iconUrl")) embed.author.icon_url = data.author.iconUrl;129 }130 if(hasProperty(data, "fields")) {131 embed.fields = data.fields.map(field => ({132 name: field.name,133 value: field.value,134 inline: field.inline135 }));136 }137 return embed;138};139const handle = async (requestType, data) => {140 logger.debug(`Handling a ${requestType} request`);141 switch(requestType) {142 case "GetGateway": {143 const request = endpoints.getGateway();144 const resp = await ratelimit(request);145 return {146 responseType: "discord.gateway.Response",147 data: {148 url: resp.body.url,149 shards: resp.body.shards,150 sessionStartLimit: {151 total: resp.body.session_start_limit.total,152 remaining: resp.body.session_start_limit.remaining,153 resetAfter: resp.body.session_start_limit.reset_after154 },155 maxConcurrency: resp.body.session_start_limit.max_concurrency156 }157 };158 }159 case "GetChannel": {160 const request = endpoints.getChannel(data.channelId);161 const resp = await ratelimit(request);162 return {163 responseType: "discord.types.Channel",164 data: converter.channel(resp.body)165 };166 }167 case "EditChannel": {168 const request = endpoints.editChannel(data.channelId);169 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);170 const body = {};171 if(hasProperty(data, "name")) body.name = data.name;172 if(hasProperty(data, "position")) body.position = data.position;173 if(hasProperty(data, "topic")) body.topic = data.topic;174 if(hasProperty(data, "nsfw")) body.nsfw = data.nsfw;175 if(hasProperty(data, "rateLimitPerUser")) body.rate_limit_per_user = data.rateLimitPerUser;176 if(hasProperty(data, "bitrate")) body.bitrate = data.bitrate;177 if(hasProperty(data, "userLimit")) body.user_limit = data.userLimit;178 if(hasProperty(data, "permissionOverwrites")) {179 body.permission_overwrites = data.permissionOverwrites.map(overwrite => ({180 id: overwrite.id,181 type: overwrite.type,182 allow: Number(overwrite.allow),183 deny: Number(overwrite.deny)184 }));185 }186 if(hasProperty(data, "parentId")) body.parent_id = data.parentId;187 request.send(body);188 const resp = await ratelimit(request);189 return {190 responseType: "discord.types.Channel",191 data: converter.channel(resp.body)192 };193 }194 case "DeleteChannel": {195 const request = endpoints.deleteChannel(data.channelId);196 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);197 const resp = await ratelimit(request);198 return {199 responseType: "discord.types.Channel",200 data: converter.channel(resp.body)201 };202 }203 case "GetChannelMessage": {204 const request = endpoints.getChannelMessage(data.channelId, data.messageId);205 const resp = await ratelimit(request);206 return {207 responseType: "discord.types.Message",208 data: converter.message(resp.body)209 };210 }211 case "GetChannelMessages": {212 const request = endpoints.getChannelMessages(data.channelId);213 if(hasProperty(data, "around")) request.query({ around: data.around });214 else if(hasProperty(data, "before")) request.query({ before: data.before });215 else if(hasProperty(data, "after")) request.query({ after: data.after });216 if(hasProperty(data, "limit")) request.query({ limit: data.limit });217 const resp = await ratelimit(request);218 return {219 responseType: "discord.channels.getMessages.Response",220 data: { messages: resp.body.map(message => converter.message(message)) }221 };222 }223 case "CreateChannelMessage": {224 const request = endpoints.createChannelMessage(data.channelId);225 const body = {226 content: data.content,227 tts: false228 };229 if(hasProperty(data, "embed")) body.embed = embedConverter(body.embed);230 if(hasProperty(data, "allowedMentions")) body.allowedMnetions = data.allowedMentions;231 if(hasProperty(data, "file")) {232 request.type("form")233 .attach("file", data.file.file, data.file.name)234 .field("payload_json", JSON.stringify(body));235 } else {236 request.send(body);237 }238 const resp = await ratelimit(request);239 return {240 responseType: "discord.types.Message",241 data: converter.message(resp.body)242 };243 }244 case "CreateReaction": {245 const request = endpoints.createReaction(data.channelId, data.messageId, data.emoji);246 await ratelimit(request);247 return {248 responseType: "discord.types.Empty",249 data: {}250 };251 }252 case "DeleteReaction": {253 const request = endpoints.deleteReaction(data.channelId, data.messageId, data.emoji, data.userId);254 await ratelimit(request);255 return {256 responseType: "discord.types.Empty",257 data: {}258 };259 }260 case "GetReactions": {261 const request = endpoints.getReactions(data.channelId, data.messageId, data.emoji);262 if(hasProperty(data, "before")) request.query({ before: data.before });263 else if(hasProperty(data, "after")) request.query({ after: data.after });264 if(hasProperty(data, "limit")) request.query({ limit: data.limit });265 const resp = await ratelimit(request);266 return {267 responseType: "discord.channels.getReactions.Request",268 data: { reactions: resp.body.map(reaction => converter.reaction(reaction)) }269 };270 }271 case "DeleteAllReactions": {272 const request = endpoints.deleteAllReactions(data.channelId, data.messageId);273 await ratelimit(request);274 return {275 responseType: "discord.types.Empty",276 data: {}277 };278 }279 case "EditMessage": {280 const request = endpoints.editMessage(data.channelId, data.messageId);281 const body = {};282 if(hasProperty(data, "content")) body.content = data.content;283 if(hasProperty(data, "embed")) body.embed = embedConverter(body.embed);284 if(hasProperty(data, "allowedMentions")) body.allowedMnetions = data.allowedMentions;285 request.send(body);286 const resp = await ratelimit(request);287 return {288 responseType: "discord.types.Message",289 data: converter.message(resp.body)290 };291 }292 case "DeleteMessage": {293 const request = endpoints.deleteMessage(data.channelId, data.messageId);294 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);295 await ratelimit(request);296 return {297 responseType: "discord.types.Empty",298 data: {}299 };300 }301 case "BulkDeleteMessages": {302 const request = endpoints.bulkDeleteMessages(data.channelId);303 request.send({ messages: data.messages });304 await ratelimit(request);305 return {306 responseType: "discord.types.Empty",307 data: {}308 };309 }310 case "EditChannelPermission": {311 const request = endpoints.editChannelPermission(data.channelId, data.overwriteId);312 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);313 request.send({314 allow: Number(data.allow),315 deny: Number(data.deny),316 type: data.type317 });318 await ratelimit(request);319 return {320 responseType: "discord.types.Empty",321 data: {}322 };323 }324 case "DeleteChannelPermission": {325 const request = endpoints.deleteChannelPermission(data.channelId, data.overwriteId);326 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);327 await ratelimit(request);328 return {329 responseType: "discord.types.Empty",330 data: {}331 };332 }333 case "TriggerTypingIndicator": {334 const request = endpoints.triggerTypingIndicator(data.channelId);335 await ratelimit(request);336 return {337 responseType: "discord.types.Empty",338 data: {}339 };340 }341 case "GetGuild": {342 const request = endpoints.getGuild(data.guildId);343 const resp = await ratelimit(request);344 return {345 responseType: "discord.types.Guild",346 data: converter.guild(resp.body)347 };348 }349 case "EditGuild": {350 const request = endpoints.editGuild(data.guildId);351 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);352 const body = {};353 if(hasProperty(data, "name")) body.name = data.name;354 if(hasProperty(data, "region")) body.region = data.region;355 if(hasProperty(data, "verificationLevel")) body.verification_level = data.verificationLevel;356 if(hasProperty(data, "explicitContentFilter")) body.explicit_content_filter = data.explicitContentFilter;357 if(hasProperty(data, "afkChannelId")) body.afk_channel_id = data.afkChannelId;358 if(hasProperty(data, "afkTimeout")) body.afk_timeout = data.afkTimeout;359 if(hasProperty(data, "icon")) body.icon = data.icon;360 if(hasProperty(data, "ownerId")) body.owner_id = data.ownerId;361 if(hasProperty(data, "splash")) body.splash = data.splash;362 if(hasProperty(data, "systemChannelId")) body.system_channel_id = data.systemChannelId;363 if(hasProperty(data, "defaultMessageNotifications")) {364 body.default_message_notifications = data.defaultMessageNotifications;365 }366 request.send(body);367 const resp = await ratelimit(request);368 return {369 responseType: "discord.types.Guild",370 data: converter.guild(resp.body)371 };372 }373 case "GetGuildChannels": {374 const request = endpoints.getGuildChannels(data.guildId);375 const resp = await ratelimit(request);376 return {377 responseType: "discord.guilds.getChannels.Response",378 data: { channels: resp.body.map(channel => converter.channel(channel)) }379 };380 }381 case "CreateGuildChannel": {382 const request = endpoints.createGuildChannel(data.guildId);383 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);384 const body = { name: data.name };385 if(hasProperty(data, "type")) body.type = data.type;386 if(hasProperty(data, "topic")) body.topic = data.topic;387 if(hasProperty(data, "bitrate")) body.bitrate = data.bitrate;388 if(hasProperty(data, "userLimit")) body.user_limit = data.userLimit;389 if(hasProperty(data, "rateLimitPerUser")) body.rate_limit_per_user = data.rateLimitPerUser;390 if(hasProperty(data, "position")) body.position = data.position;391 if(hasProperty(data, "parentId")) body.parent_id = data.parentId;392 if(hasProperty(data, "nsfw")) body.nsfw = data.nsfw;393 if(hasProperty(data, "permissionOverwrites")) {394 body.permission_overwrites = data.permissionOverwrites.map(overwrite => ({395 id: overwrite.id,396 type: overwrite.type,397 allow: Number(overwrite.allow),398 deny: Number(overwrite.deny)399 }));400 }401 request.send(body);402 const resp = await ratelimit(request);403 return {404 responseType: "discord.types.Channel",405 data: converter.channel(resp.body)406 };407 }408 case "GetGuildMember": {409 const request = endpoints.getGuildMember(data.guildId, data.userId);410 const resp = await ratelimit(request);411 return {412 responseType: "discord.types.Member",413 data: converter.member(resp.body)414 };415 }416 case "GetGuildMembers": {417 const request = endpoints.getGuildMembers(data.guildId);418 if(hasProperty(data, "limit")) request.query({ limit: data.limit });419 if(hasProperty(data, "after")) request.query({ after: data.after });420 const resp = await ratelimit(request);421 return {422 responseType: "discord.guilds.getMembers.Response",423 data: { members: resp.body.forEach(member => converter.member(member)) }424 };425 }426 case "EditGuildMember": {427 const request = endpoints.editGuildMember(data.guildId, data.userId);428 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);429 const body = {};430 if(hasProperty(data, "nick")) body.nick = data.nick;431 if(hasProperty(data, "mute")) body.mute = data.mute;432 if(hasProperty(data, "deaf")) body.deaf = data.deaf;433 if(hasProperty(data, "channelId")) body.channel_id = data.channelId;434 request.send(body);435 const resp = await ratelimit(request);436 return {437 responseType: "discord.types.Member",438 data: converter.member(resp.body)439 };440 }441 case "AddGuildMemberRole": {442 const request = endpoints.addGuildMemberRole(data.guildId, data.userId, data.roleId);443 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);444 await ratelimit(request);445 return {446 responseType: "discord.types.Empty",447 data: {}448 };449 }450 case "RemoveGuildMemberRole": {451 const request = endpoints.removeGuildMemberRole(data.guildId, data.userId, data.roleId);452 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);453 await ratelimit(request);454 return {455 responseType: "discord.types.Empty",456 data: {}457 };458 }459 case "KickGuildMember": {460 const request = endpoints.kickGuildMember(data.guildId, data.userId);461 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);462 await ratelimit(request);463 return {464 responseType: "discord.types.Empty",465 data: {}466 };467 }468 case "GetGuildBans": {469 const request = endpoints.getGuildBans(data.guildId);470 const resp = await ratelimit(request);471 return {472 responseType: "discord.guilds.getBans.Response",473 data: { bans: resp.body.map(ban => converter.ban(ban)) }474 };475 }476 case "GetGuildBan": {477 const request = endpoints.getGuildBan(data.guildId, data.userId);478 const resp = await ratelimit(request);479 return {480 responseType: "discord.types.Ban",481 data: converter.ban(resp.body)482 };483 }484 case "BanGuildMember": {485 const request = endpoints.banGuildMember(data.guildId, data.userId);486 request.set("X-Audit-Log-Reason", data.reason);487 request.send({488 reason: data.reason,489 "delete-message-days": data.deleteMessageDays490 });491 await ratelimit(request);492 return {493 responseType: "discord.types.Empty",494 data: {}495 };496 }497 case "UnbanGuildMember": {498 const request = endpoints.unbanGuildMember(data.guildId, data.userId);499 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);500 await ratelimit(request);501 return {502 responseType: "discord.types.Empty",503 data: {}504 };505 }506 case "GetGuildRoles": {507 const request = endpoints.getGuildRoles(data.guildId);508 const resp = await ratelimit(request);509 return {510 responseType: "discord.guilds.getRoles.Response",511 data: { roles: resp.body.map(role => converter.role(role)) }512 };513 }514 case "CreateGuildRole": {515 const request = endpoints.createGuildRole(data.guildId);516 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);517 const body = {};518 if(hasProperty(data, "name")) body.name = data.name;519 if(hasProperty(data, "permissions")) body.permissions = Number(data.permissions);520 if(hasProperty(data, "position")) body.position = data.position;521 if(hasProperty(data, "color")) body.color = data.color;522 if(hasProperty(data, "hoist")) body.hoist = data.hoist;523 if(hasProperty(data, "mentionable")) body.mentionable = data.mentionable;524 request.send(body);525 const resp = await ratelimit(request);526 return {527 responseType: "discord.types.Role",528 data: converter.role(resp.body)529 };530 }531 case "EditGuildRole": {532 const request = endpoints.editGuildRole(data.guildId, data.roleId);533 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);534 const body = {};535 if(hasProperty(data, "name")) body.name = data.name;536 if(hasProperty(data, "permissions")) body.permissions = Number(data.permissions);537 if(hasProperty(data, "position")) body.position = data.position;538 if(hasProperty(data, "color")) body.color = data.color;539 if(hasProperty(data, "hoist")) body.hoist = data.hoist;540 if(hasProperty(data, "mentionable")) body.mentionable = data.mentionable;541 request.send(body);542 const resp = await ratelimit(request);543 return {544 responseType: "discord.types.Role",545 data: converter.role(resp.body)546 };547 }548 case "DeleteGuildRole": {549 const request = endpoints.deleteGuildRole(data.guildId, data.roleId);550 if(hasProperty(data, "reason")) request.set("X-Audit-Log-Reason", data.reason);551 await ratelimit(request);552 return {553 responseType: "discord.types.Empty",554 data: {}555 };556 }557 case "GetUser": {558 const request = endpoints.getUser(data.userId);559 const resp = await ratelimit(request);560 return {561 responseType: "discord.types.User",562 data: converter.user(resp.body)563 };564 }565 case "CreateDM": {566 const request = endpoints.createDM();567 request.send({ recipient_id: data.recipientId });568 const resp = await ratelimit(request);569 return {570 responseType: "discord.types.User",571 data: converter.user(resp.body)572 };573 }574 default: {575 return {576 responseType: "discord.types.Empty",577 data: {}578 };579 }580 }581};582module.exports = async (requestType, data) => {583 try {584 return await handle(requestType, data);585 } catch(error) {586 if(hasProperty(error, Symbol.for("DiscordError"))) {587 return {588 responseType: "discord.types.HTTPError",589 data: {590 code: error.code,591 status: error.status,592 message: error.message593 }594 };595 } else {596 throw error;597 }598 }...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

...29 30 switch(dbName){31 case 'kang':32 bgColor = arrayColor[0];33 if(!Ti.App.Properties.hasProperty('hidead')){34 if(osname == 'iphone' || osname =='ipad'){35 Titanium.App.Properties.setString('hidead', 'hideAd_kango');36 }else{37 Titanium.App.Properties.setString('hidead', 'hidead_kango');38 }39 }40 //解説準備OK41 arrayPurchase = [ Titanium.App.Properties.getString('hidead'), 'kang100a'];42 43 arrayTest = [];44 45 for(i=99; i<=103; i++){46 if(i<=99){47 arrayTest.push(dbName + '0' + i + 'a');48 arrayTest.push(dbName + '0' + i + 'b');49 }else{50 arrayTest.push(dbName + i + 'a');51 arrayTest.push(dbName + i + 'b');52 }53 }54 55 for(i=0; i<arrayTest.length; i++){56 if (!Titanium.App.Properties.hasProperty('Purchased-'+arrayTest[i])) {57 Titanium.App.Properties.setBool('Purchased-'+arrayTest[i], false);58 }59 }60 61 if (!Titanium.App.Properties.hasProperty('test')) {62 Titanium.App.Properties.setString('test', 'kang099a');//最初のデータにする idMin / idMax を合わせること63 }64 //最初の問題番号65 if (!Titanium.App.Properties.hasProperty('min')) {66 Titanium.App.Properties.setInt('min', 1);67 }68 //最後の問題番号69 if (!Titanium.App.Properties.hasProperty('max')) {70 Titanium.App.Properties.setInt('max', 120);71 }72 //最初のid番号73 if (!Titanium.App.Properties.hasProperty('idMin')) {74 Titanium.App.Properties.setInt('idMin', 1);75 }76 //最後のid番号77 if (!Titanium.App.Properties.hasProperty('idMax')) {78 Titanium.App.Properties.setInt('idMax', 120);79 }80 81 if (!Titanium.App.Properties.hasProperty('nend_spotid')) {82 Ti.App.Properties.setInt('nend_spotid_android', 152489);83 Ti.App.Properties.setInt('nend_spotid', 23892);84 Titanium.App.Properties.setString('nend_appkey_android', '9645b08bb5bbf949467490fb8a41ecb237cb62b5');85 Titanium.App.Properties.setString('nend_appkey', '0fce157894e6a599e105a743e79b47f452535e96');86 }87 88 if(!Ti.App.Properties.hasProperty('inAppBillingPublicKey')){89 Titanium.App.Properties.setString('inAppBillingPublicKey', 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuoKhGc4Ifp6ZEK0m2kiXnWto38UazMuw1kpO7zdjeAQezlnG3+D+BSOW5TJUFuzpO0fEXgPD2TUq/u2gbbXVAXeJsiO4a9mdPJWPWy/awWUw+NdIJPSraBwK86jQanE5akvuQs0V8ct10NUJv7VXACMH19rANFTPMmLLEjfybdFicyXOfRL9ZQWYe7Fqgvn1enx0+9cBKvZ+ED3GkKdl2VZwjRINefhLLt32HSefN7YkAegMdML9HiOrNauZJxKNf3tZPU8AyA/npGeOIbmXOj+Wko7QQ6vDHEilPo7i/adIOdfG8gjGJgqQbhdl5IjZKFxU6Ladl3xEsk2nFMve4wIDAQAB');90 }91 break;92 case 'kaig':93 bgColor = arrayColor[11];94 if(!Ti.App.Properties.hasProperty('hidead')){95 Titanium.App.Properties.setString('hidead', 'hidead_kaigo');96 }97 //解説準備OK98 arrayPurchase = [ Titanium.App.Properties.getString('hidead')];99 100 arrayTest = [];101 102 for(i=21; i<=26; i++){103 if(i<=99){104 arrayTest.push(dbName + '0' + i + 'a');105 arrayTest.push(dbName + '0' + i + 'b');106 }else{107 arrayTest.push(dbName + i + 'a');108 arrayTest.push(dbName + i + 'b');109 }110 }111 112 for(i=0; i<arrayTest.length; i++){113 if (!Titanium.App.Properties.hasProperty('Purchased-'+arrayTest[i])) {114 Titanium.App.Properties.setBool('Purchased-'+arrayTest[i], false);115 }116 }117 118 if (!Titanium.App.Properties.hasProperty('test')) {119 Titanium.App.Properties.setString('test', 'kaig021a');//最初のデータにする idMin / idMax を合わせること120 }121 //最初の問題番号122 if (!Titanium.App.Properties.hasProperty('min')) {123 Titanium.App.Properties.setInt('min', 1);124 }125 //最後の問題番号126 if (!Titanium.App.Properties.hasProperty('max')) {127 Titanium.App.Properties.setInt('max', 56);128 }129 //最初のid番号130 if (!Titanium.App.Properties.hasProperty('idMin')) {131 Titanium.App.Properties.setInt('idMin', 1);132 }133 //最後のid番号134 if (!Titanium.App.Properties.hasProperty('idMax')) {135 Titanium.App.Properties.setInt('idMax', 56);136 }137 138 if (!Titanium.App.Properties.hasProperty('nend_spotid')) {139 Ti.App.Properties.setInt('nend_spotid_android', 164637);140 Ti.App.Properties.setInt('nend_spotid', 58358);141 Titanium.App.Properties.setString('nend_appkey_android', 'f5b15bfdc1e80b78fa6ea2c7d4e789a97ffd0601');142 Titanium.App.Properties.setString('nend_appkey', '6d4785a59a457742a4e7e2c80eb423ab24ee9cb8');143 }144 145 if(!Ti.App.Properties.hasProperty('inAppBillingPublicKey')){146 Titanium.App.Properties.setString('inAppBillingPublicKey', 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5Q6fJiNt5VCoTYmhQxl7cVYU4aaQKmpBMDxaHanMoQvCQ8PlVxwI6sa+cTHTmFjRFcdwpikATn/FuXTlS7w0arkOe9YNRcW5ZYTA0RCen9260ZMByLMZBWYcSF6s7rSKeP2jIy/EZ+DAcqgi4oNjNsMbtRaOPz9ek6W4R2HLuEKTjtte0nVss7SN8Sbb2ZHVB6n/0y3kr/TYwTk7jzUMrLsQveX1SyTOEdYxXdj0OZ701h3gbgbyGqxZAagNv6k8FGJgAYlVDhi12iga+eXM7QH26So90n9P/9iqJlPAZqjZnsnGe6ylTaUyEhkwsW8XGA3/S4o4rXfLHsfdH2bxxwIDAQAB');147 }148 break;149 case 'care':150 bgColor = arrayColor[3];151 if(!Ti.App.Properties.hasProperty('hidead')){152 Titanium.App.Properties.setString('hidead', 'hidead_caremane');153 }154 //解説準備OK155 arrayPurchase = [ Titanium.App.Properties.getString('hidead')];156 157 arrayTest = [];158 159 for(i=11; i<=16; i++){160 if(i<=99){161 arrayTest.push(dbName + '0' + i + 'a');162 //arrayTest.push(dbName + '0' + i + 'b');163 }else{164 arrayTest.push(dbName + i + 'a');165 //arrayTest.push(dbName + i + 'b');166 }167 }168 169 for(i=0; i<arrayTest.length; i++){170 if (!Titanium.App.Properties.hasProperty('Purchased-'+arrayTest[i])) {171 Titanium.App.Properties.setBool('Purchased-'+arrayTest[i], false);172 }173 }174 175 if (!Titanium.App.Properties.hasProperty('test')) {176 Titanium.App.Properties.setString('test', 'care011a');//最初のデータにする idMin / idMax を合わせること177 }178 //最初の問題番号179 if (!Titanium.App.Properties.hasProperty('min')) {180 Titanium.App.Properties.setInt('min', 1);181 }182 //最後の問題番号183 if (!Titanium.App.Properties.hasProperty('max')) {184 Titanium.App.Properties.setInt('max', 60);185 }186 //最初のid番号187 if (!Titanium.App.Properties.hasProperty('idMin')) {188 Titanium.App.Properties.setInt('idMin', 1);189 }190 //最後のid番号191 if (!Titanium.App.Properties.hasProperty('idMax')) {192 Titanium.App.Properties.setInt('idMax', 60);193 }194 195 if (!Titanium.App.Properties.hasProperty('nend_spotid')) {196 Ti.App.Properties.setInt('nend_spotid_android', 164638);197 Ti.App.Properties.setInt('nend_spotid', 58361);198 Titanium.App.Properties.setString('nend_appkey_android', '6ac3912d368b54da0bcf161f1e0caaf6747ee9e5');199 Titanium.App.Properties.setString('nend_appkey', '8880285e4a92d0c2a1aa3d155dd13add20bd2786');200 }201 202 if(!Ti.App.Properties.hasProperty('inAppBillingPublicKey')){203 Titanium.App.Properties.setString('inAppBillingPublicKey', 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvEWe2u779oHOdhO6hsqTetyIHUg47YG3CXapf86G3r9Lr5O/2yyu6hrlmx+7XQ+KUfcgFgaFAsig2ft6GQxglpylKq4p9MVL3Ur0jUqKFiOplmQ0NoYdhQnEEtJP8kqAkI8yUh9J51bpvIOcvPR8pgljJaWNbW0HnQTwZXAHpcLnFo31AOZLVm4prmowtggZ/hwOW/LONAIAQwgKdRMQnz4QCib058CNycLzkGz7HBe3sJ2tnrWIIMFbmp5hN5ppkLNqlEAghoKBe7gpKcN39VI/o2KGW/dbQkdAaRnuQGaayAA+FgEbnniR6JDJBYahQxbY/qFgcysK5k7eqyUMfwIDAQAB');204 }205 break;206 default:207 bgColor = '#000';208 if(!Ti.App.Properties.hasProperty('hidead')){209 Titanium.App.Properties.setString('hidead', 'hidead');210 }211 break;212 }213 214 /////////////////215 //Ti.API.info('rowHeight: ' + rowHeight);216 217 for(i=0; i<arrayBool.length; i++){218 if (!Titanium.App.Properties.hasProperty(arrayBool[i])) {219 if(osname=='android' && arrayBool[i]=='noVoice'){220 Titanium.App.Properties.setBool(arrayBool[i], true);221 }else{222 Titanium.App.Properties.setBool(arrayBool[i], false);223 }224 }225 }226 227 //in-app purchase setting228 if (!Titanium.App.Properties.hasProperty('Purchased-' + Titanium.App.Properties.getString('hidead'))) {229 Titanium.App.Properties.setBool('Purchased-' + Titanium.App.Properties.getString('hidead'), false);230 }231 232 if(!Ti.App.Properties.hasProperty('recordIds')){233 Titanium.App.Properties.setString('recordIds', '');234 }235 236 if(!Ti.App.Properties.hasProperty('recordSearch')){237 Titanium.App.Properties.setString('recordSearch', '');238 }239 240 if (!Titanium.App.Properties.hasProperty('serachMode')) {241 Titanium.App.Properties.setBool('serachMode', false);242 }243 244 if (!Titanium.App.Properties.hasProperty('from')) {245 Titanium.App.Properties.setInt('from', 1);246 }247 //出題範囲248 if (!Titanium.App.Properties.hasProperty('range')) {249 Titanium.App.Properties.setInt('range', 10);250 }251 252 if (!Titanium.App.Properties.hasProperty('timer')) {253 Titanium.App.Properties.setInt('timer', 0);254 }255 256 if(!Ti.App.Properties.hasProperty('mode')){257 Titanium.App.Properties.setString('mode', 'normal');258 }259 260 if (!Titanium.App.Properties.hasProperty('bgm')) {261 Titanium.App.Properties.setBool('bgm', true);262 }263 264 if (!Titanium.App.Properties.hasProperty('hint')) {265 Titanium.App.Properties.setBool('hint', true);266 }267 268 if (!Titanium.App.Properties.hasProperty('testMode')) {269 Titanium.App.Properties.setBool('testMode', false);270 }271 272 if(!Ti.App.Properties.hasProperty('setDatabase')){273 Ti.App.Properties.setInt('setDatabase', 0);274 }275 276 if(!Ti.App.Properties.hasProperty('mail')){277 Titanium.App.Properties.setString('mail', 'dev.kokucy@gmail.com');278 }279 280 if(!Ti.App.Properties.hasProperty('level')){281 Titanium.App.Properties.setInt('level', 1);282 }283 284 if(!Ti.App.Properties.hasProperty('hintCounter')){285 Titanium.App.Properties.setInt('hintCounter', 10);286 }287 288 if(!Ti.App.Properties.hasProperty('bgColor')){289 Titanium.App.Properties.setString('bgColor', '#000');290 }291 292 if(!Ti.App.Properties.hasProperty('color')){293 Titanium.App.Properties.setString('color', '#fff');294 }295 296 if(!Ti.App.Properties.hasProperty('zoom')){//for webview297 Titanium.App.Properties.setDouble('zoom', 1);298 }299 300 if(!Ti.App.Properties.hasProperty('speed')){//spech301 if(osname=='android'){302 Titanium.App.Properties.setDouble('speed', 1);303 }else{304 Titanium.App.Properties.setDouble('speed', 0.3);305 }306 }307 308 if(!Ti.App.Properties.hasProperty('selfZoom')){309 Titanium.App.Properties.setDouble('selfZoom', 1);310 }311 312 //if(!Ti.App.Properties.hasProperty('osZoom')){313 if(osname == 'ipad'){314 Titanium.App.Properties.setDouble('osZoom', 0.6);315 }else if(osname == 'android'){316 Titanium.App.Properties.setDouble('osZoom', 0.6);317 }else{318 Titanium.App.Properties.setDouble('osZoom', 1);319 }320 //}321 322 //database create323 require('lib/db').createDatabase(dbName);324 //render appropriate components based on the platform and form factor325 //considering tablets to have width over 720px and height over 600px - you can define your own326 function checkTablet() {...

Full Screen

Full Screen

Object.hasProperty.js

Source:Object.hasProperty.js Github

copy

Full Screen

...13 expect = required.expect;14 describe('Object.hasProperty', function () {15 it('object, enumerable bugged properties', function () {16 var testObj = [];17 expect(reiterate.$.hasProperty(testObj, 'toString')).to.be.ok();18 expect(reiterate.$.hasProperty(testObj, 'toLocaleString')).to.be.ok();19 expect(reiterate.$.hasProperty(testObj, 'valueOf')).to.be.ok();20 expect(reiterate.$.hasProperty(testObj, 'hasOwnProperty')).to.be.ok();21 expect(reiterate.$.hasProperty(testObj, 'isPrototypeOf')).to.be.ok();22 expect(reiterate.$.hasProperty(testObj, 'propertyIsEnumerable'))23 .to.be.ok();24 expect(reiterate.$.hasProperty(testObj, 'constructor')).to.be.ok();25 });26 it('array, enumerable bugged properties', function () {27 var testArr = [];28 expect(reiterate.$.hasProperty(testArr, 'toString')).to.be.ok();29 expect(reiterate.$.hasProperty(testArr, 'toLocaleString')).to.be.ok();30 expect(reiterate.$.hasProperty(testArr, 'valueOf')).to.be.ok();31 expect(reiterate.$.hasProperty(testArr, 'hasOwnProperty')).to.be.ok();32 expect(reiterate.$.hasProperty(testArr, 'isPrototypeOf')).to.be.ok();33 expect(reiterate.$.hasProperty(testArr, 'propertyIsEnumerable'))34 .to.be.ok();35 expect(reiterate.$.hasProperty(testArr, 'constructor')).to.be.ok();36 });37 it('function prototype property', function () {38 expect(reiterate.$.hasProperty(function () {39 return;40 }, 'prototype')).to.be.ok();41 });42 it('string index, literal and object', function () {43 var testStr = 'abc',44 testObj = Object(testStr);45 expect(reiterate.$.hasProperty(testStr, 0)).to.be.ok();46 expect(reiterate.$.hasProperty(testStr, 3)).to.not.be.ok();47 expect(reiterate.$.hasProperty(testObj, 0)).to.be.ok();48 expect(reiterate.$.hasProperty(testObj, 3)).to.not.be.ok();49 });50 it('array index', function () {51 var testArr = ['a', 'b', 'c'];52 expect(reiterate.$.hasProperty(testArr, 0)).to.be.ok();53 expect(reiterate.$.hasProperty(testArr, 3)).to.not.be.ok();54 });55 it('arguments index', function () {56 var testArg = reiterate.$.returnArgs('a', 'b', 'c');57 expect(reiterate.$.hasProperty(testArg, 0)).to.be.ok();58 expect(reiterate.$.hasProperty(testArg, 3)).to.not.be.ok();59 });60 it('array prototype methods', function () {61 var testArr = [];62 expect(reiterate.$.hasProperty(testArr, 'push')).to.be.ok();63 expect(reiterate.$.hasProperty(testArr, 'pop')).to.be.ok();64 expect(reiterate.$.hasProperty(testArr, 'foo')).to.not.be.ok();65 expect(reiterate.$.hasProperty(testArr, 'bar')).to.not.be.ok();66 expect(reiterate.$.hasProperty(testArr, 'fuz')).to.not.be.ok();67 });68 it('object direct properties', function () {69 var testObj = {70 foo: undefined,71 bar: null72 };73 if (testObj.getPrototypeOf) {74 expect(reiterate.$.hasProperty(testObj, 'getPrototypeOf')).to.be.ok();75 }76 expect(reiterate.$.hasProperty(testObj, 'foo')).to.be.ok();77 expect(reiterate.$.hasProperty(testObj, 'bar')).to.be.ok();78 expect(reiterate.$.hasProperty(testObj, 'fuz')).to.not.be.ok();79 });80 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const expect = require('chai').expect;2const app = require('../app');3describe('App', function() {4 it('app should return hello', function() {5 let result = app.sayHello();6 expect(result).to.equal('hello');7 });8 it('app should return type string', function() {9 let result = app.sayHello();10 expect(result).to.be.a('string');11 });12 it('addNumbers should be above 5', function() {13 let result = app.addNumbers(5,5);14 expect(result).to.be.above(5);15 });16 it('addNumbers should return type number', function() {17 let result = app.addNumbers(5,5);18 expect(result).to.be.a('number');19 });20 it('addNumbers should return 10', function() {21 let result = app.addNumbers(5,5);22 expect(result).to.equal(10);23 });24 it('addNumbers should return 10', function() {25 let result = app.addNumbers(5,5);26 expect(result).to.equal(10);27 });28 it('addNumbers should return 10', function() {29 let result = app.addNumbers(5,5);30 expect(result).to.equal(10);31 });32 it('addNumbers should return 10', function() {33 let result = app.addNumbers(5,5);34 expect(result).to.equal(10);35 });36 it('addNumbers should return 10', function() {37 let result = app.addNumbers(5,5);38 expect(result).to.equal(10);39 });40 it('addNumbers should return 10', function() {41 let result = app.addNumbers(5,5);42 expect(result).to.equal(10);43 });44 it('addNumbers should return 10', function() {45 let result = app.addNumbers(5,5);46 expect(result).to.equal(10);47 });48});49const sayHello = () =>

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('chai').expect;2var obj = {name: 'RajiniKanth', age: 33, hasPets : false};3var prop = 'age';4describe('hasProperty', function() {5 it('should check if the object has a particular property', function() {6 expect(obj).to.have.property(prop);7 });8});9var expect = require('chai').expect;10var obj = {name: 'RajiniKanth', age: 33, hasPets : false};11var prop = 'age';12describe('hasOwnProperty', function() {13 it('should check if the object has a particular property', function() {14 expect(obj).to.have.ownProperty(prop);15 });16});17var expect = require('chai').expect;18var obj = {name: 'RajiniKanth', age: 33, hasPets : false};19var prop = 'age';20describe('deep.property', function() {21 it('should check if the object has a particular property', function() {22 expect(obj).to.have.deep.property(prop);23 });24});25var expect = require('chai').expect;26var obj = {name: 'RajiniKanth', age: 33, hasPets : false};27var prop = 'age';28describe('deep.property', function() {29 it('should check if the object has a particular property', function() {30 expect(obj).to.have.deep.property(prop);31 });32});33var expect = require('chai').expect;34var obj = {name: 'RajiniKanth', age: 33, hasPets : false};35var prop = 'age';36describe('deep.property', function() {37 it('should check if the object has a particular property', function() {38 expect(obj).to.have.deep.property(prop);39 });40});41var expect = require('chai').expect;42var obj = {name: 'RajiniKanth', age: 33, hasPets : false};43var prop = 'age';44describe('deep.property', function() {45 it('should check if the object has a particular property', function() {46 expect(obj).to.have.deep.property(prop);

Full Screen

Using AI Code Generation

copy

Full Screen

1var chai = require('chai');2var expect = chai.expect;3var assert = chai.assert;4var should = chai.should();5var obj = {a: 'a'};6var arr = ['a', 'b', 'c'];7var str = 'test';8var num = 1;9var bool = false;10var nul = null;11var undef;12expect(obj).to.have.property('a');13expect(arr).to.have.property('2');14expect(str).to.have.property('3');15expect(num).to.have.property('toString');16expect(bool).to.have.property('toString');17expect(nul).to.have.property('toString');18expect(undef).to.have.property('toString');19var chai = require('chai');20var expect = chai.expect;21var assert = chai.assert;22var should = chai.should();23var obj = {a: 'a'};24var arr = ['a', 'b', 'c'];25var str = 'test';26var num = 1;27var bool = false;28var nul = null;29var undef;30expect(obj).to.have.ownProperty('a');31expect(arr).to.not.have.ownProperty('2');32expect(str).to.not.have.ownProperty('3');33expect(num).to.not.have.ownProperty('toString');34expect(bool).to.not.have.ownProperty('toString');35expect(nul).to.not.have.ownProperty('toString');36expect(undef).to.not.have.ownProperty('toString');

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('chai').assert;2var expect = require('chai').expect;3var should = require('chai').should();4var person = {5};6describe('person', function () {7 it('should have property name', function () {8 expect(person).to.have.property('name');9 assert.property(person, 'name');10 person.should.have.property('name');11 });12 it('should have property age', function () {13 expect(person).to.have.property('age');14 assert.property(person, 'age');15 person.should.have.property('age');16 });17});18var assert = require('chai').assert;19var expect = require('chai').expect;20var should = require('chai').should();21var person = {22};23describe('person', function () {24 it('should have property name', function () {25 expect(person).to.have.property('name');26 assert.property(person, 'name');27 person.should.have.property('name');28 });29 it('should have property name with length 4', function () {30 expect(person.name).to.have.lengthOf(4);31 assert.lengthOf(person.name, 4);32 person.name.should.have.lengthOf(4);33 });34 it('should have property age', function () {35 expect(person).to.have.property('age');36 assert.property(person, 'age');37 person.should.have.property('age');38 });39 it('should have property age with value 20', function () {40 expect(person.age).to.equal(20);41 assert.equal(person.age, 20);42 person.age.should.equal(20);43 });44});45var assert = require('chai').assert;46var expect = require('chai').expect;47var should = require('chai').should();48var person = {49};50describe('person', function () {51 it('should have property name', function () {52 expect(person).to.have.property('name');53 assert.property(person, 'name');54 person.should.have.property('name');55 });56 it('should have property name with length 4', function () {57 expect(person.name).to.have.length

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('chai').expect;2var obj = {3}4var obj2 = {5}6var obj3 = {7}8var obj4 = {9}10describe('hasProperty method', function() {11 it('should return true if the object has the property', function() {12 expect(obj).to.have.property('name');13 })14 it('should return true if the object has the property', function() {15 expect(obj2).to.have.property('name', 'John');16 })17 it('should return true if the object has the property', function() {18 expect(obj3).to.have.property('name').to.be.a('string');19 })20 it('should return true if the object has the property', function() {21 expect(obj4).to.have.property('name').to.equal('John');22 })23})24var expect = require('chai').expect;25var obj = {26}27var obj2 = {28}29var obj3 = {30}31var obj4 = {32}33describe('hasOwnProperty method', function() {34 it('should return true if the object has the property', function() {35 expect(obj).to.have.ownProperty('name');36 })37 it('should return true if the object has the property', function() {38 expect(obj2).to.have.ownProperty('name', 'John');39 })40 it('should return true if the object has the property', function() {41 expect(obj3).to.have.ownProperty('name').to.be.a('string');42 })43 it('should return true if the object has the property', function() {44 expect(obj4).to.have.ownProperty('name').to.equal('John');45 })46})47var expect = require('chai').expect;48var obj = {49}50var obj2 = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('chai').expect;2var obj = { name: 'john', age: 25 };3var obj2 = { name: 'john', age: 25 };4expect(obj).to.have.property('name');5expect(obj).to.have.property('name').to.be.a('string');6expect(obj).to.have.property('name').to.be.equal('john');7expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string');8expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string').to.have.lengthOf(4);9expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string').to.have.lengthOf(4).to.have.lengthOf(4);10expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string').to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4);11expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string').to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4);12expect(obj).to.have.property('name').to.be.equal('john').to.be.a('string').to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4).to.have.lengthOf(4);13expect(obj).to.have.property('name').to.be.equal('john').to.be.a('st

Full Screen

Using AI Code Generation

copy

Full Screen

1const chai = require('chai');2const expect = chai.expect;3const assert = chai.assert;4const should = chai.should();5describe('Test Suite', function () {6 it('Test Case', function () {7 var obj = {8 };9 expect(obj).to.have.property('name');10 expect(obj).to.have.property('name').to.equal('John');11 expect(obj).to.have.property('name').to.equal('John').to.be.a('string');12 assert.property(obj, 'name');13 assert.property(obj, 'name', 'John');14 assert.property(obj, 'name', 'John').to.be.a('string');15 obj.should.have.property('name');16 obj.should.have.property('name', 'John');17 obj.should.have.property('name', 'John').to.be.a('string');18 });19});

Full Screen

Using AI Code Generation

copy

Full Screen

1const chai = require('chai');2const expect = chai.expect;3const assert = chai.assert;4describe('Test', () => {5 it('should test', () => {6 let obj = {7 }8 assert.hasProperty(obj, 'name', 'has property name');9 assert.hasProperty(obj, 'age', 'has property age');10 assert.hasProperty(obj, 'location', 'has property location');11 });12});13AssertionError: expected { Object (name, age) } to have property 'location'14 at Context.<anonymous> (test.js:16:22)15 at processImmediate (internal/timers.js:456:21)

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